//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.ComponentModel { using System; using System.Collections; using System.ComponentModel.Design.Serialization; using System.Reflection; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.RelyingParty; /// /// A design-time helper to give an OpenID Identifier property an auto-complete functionality /// listing the OP Identifiers in the class. /// public class IdentifierConverter : ConverterBase { /// /// Initializes a new instance of the class. /// [Obsolete("This class is meant for design-time use within an IDE, and not meant to be used directly by runtime code.")] public IdentifierConverter() { } /// /// Converts a value from its string representation to its strongly-typed object. /// /// The value. /// The strongly-typed object. protected override Identifier ConvertFrom(string value) { return value; } /// /// Creates the reflection instructions for recreating an instance later. /// /// The value to recreate later. /// /// The description of how to recreate an instance. /// protected override InstanceDescriptor CreateFrom(Identifier value) { if (value == null) { return null; } MemberInfo identifierParse = typeof(Identifier).GetMethod("Parse", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(string) }, null); return CreateInstanceDescriptor(identifierParse, new object[] { value.ToString() }); } /// /// Converts the strongly-typed value to a string. /// /// The value to convert. /// The string representation of the object. protected override string ConvertToString(Identifier value) { return value; } /// /// Gets the standard values to suggest with Intellisense in the designer. /// /// A collection of the standard values. protected override ICollection GetStandardValuesForCache() { return SuggestedStringsConverter.GetStandardValuesForCacheShared(typeof(WellKnownProviders)); } } }