summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OpenId/OpenId
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.OpenId/OpenId')
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs13
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Realm.cs12
2 files changed, 25 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs b/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs
index 305976a..2d919ea 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs
@@ -12,6 +12,7 @@ namespace DotNetOpenAuth.OpenId {
using System.Diagnostics.Contracts;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId.RelyingParty;
+ using DotNetOpenAuth.Messaging.Reflection;
/// <summary>
/// An Identifier is either a "http" or "https" URI, or an XRI.
@@ -22,6 +23,18 @@ namespace DotNetOpenAuth.OpenId {
[ContractClass(typeof(IdentifierContract))]
public abstract class Identifier {
/// <summary>
+ /// Initializes the <see cref="Identifier"/> class.
+ /// </summary>
+ static Identifier() {
+ Func<string, Identifier> safeIdentifier = str => {
+ Contract.Assume(str != null);
+ ErrorUtilities.VerifyFormat(str.Length > 0, MessagingStrings.NonEmptyStringExpected);
+ return Identifier.Parse(str, true);
+ };
+ MessagePart.Map<Identifier>(id => id.SerializedString, id => id.OriginalString, safeIdentifier);
+ }
+
+ /// <summary>
/// Initializes a new instance of the <see cref="Identifier"/> class.
/// </summary>
/// <param name="originalString">The original string before any normalization.</param>
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Realm.cs b/src/DotNetOpenAuth.OpenId/OpenId/Realm.cs
index 98e3598..0b4205b 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Realm.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Realm.cs
@@ -18,6 +18,7 @@ namespace DotNetOpenAuth.OpenId {
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Xrds;
using DotNetOpenAuth.Yadis;
+ using DotNetOpenAuth.Messaging.Reflection;
/// <summary>
/// A trust root to validate requests and match return URLs against.
@@ -58,6 +59,17 @@ namespace DotNetOpenAuth.OpenId {
private Uri uri;
/// <summary>
+ /// Initializes the <see cref="Realm"/> class.
+ /// </summary>
+ static Realm() {
+ Func<string, Realm> safeRealm = str => {
+ Contract.Assume(str != null);
+ return new Realm(str);
+ };
+ MessagePart.Map<Realm>(realm => realm.ToString(), realm => realm.OriginalString, safeRealm);
+ }
+
+ /// <summary>
/// Initializes a new instance of the <see cref="Realm"/> class.
/// </summary>
/// <param name="realmUrl">The realm URL to use in the new instance.</param>