summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs')
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs13
1 files changed, 13 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>