/// <summary> /// Returns the <see cref="LiveJournalSecurityType"/> enumeration value that corresponds to the specified access level name. /// </summary> /// <param name="name">The name of the access level.</param> /// <returns>A <see cref="LiveJournalSecurityType"/> enumeration value that corresponds to the specified string, otherwise returns <b>LiveJournalSecurityType.None</b>.</returns> /// <remarks>This method disregards case of specified access level name.</remarks> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is an empty string.</exception> public static LiveJournalSecurityType AccessibilityByName(string name) { LiveJournalSecurityType accessLevel = LiveJournalSecurityType.None; Guard.ArgumentNotNullOrEmptyString(name, "name"); foreach (System.Reflection.FieldInfo fieldInfo in typeof(LiveJournalSecurityType).GetFields()) { if (fieldInfo.FieldType == typeof(LiveJournalSecurityType)) { LiveJournalSecurityType level = (LiveJournalSecurityType)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; if (String.Compare(name, enumerationMetadata.AlternateValue, StringComparison.OrdinalIgnoreCase) == 0) { accessLevel = level; break; } } } } return(accessLevel); }
/// <summary> /// Returns the period identifier for the supplied <see cref="SiteSummaryUpdatePeriod"/>. /// </summary> /// <param name="period">The <see cref="SiteSummaryUpdatePeriod"/> to get the period identifier for.</param> /// <returns>The period identifier for the supplied <paramref name="vocabulary"/>, otherwise returns an empty string.</returns> public static string PeriodAsString(SiteSummaryUpdatePeriod period) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ string name = String.Empty; //------------------------------------------------------------ // Return alternate value based on supplied protocol //------------------------------------------------------------ foreach (System.Reflection.FieldInfo fieldInfo in typeof(SiteSummaryUpdatePeriod).GetFields()) { if (fieldInfo.FieldType == typeof(SiteSummaryUpdatePeriod)) { SiteSummaryUpdatePeriod updatePeriod = (SiteSummaryUpdatePeriod)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); if (updatePeriod == period) { object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; name = enumerationMetadata.AlternateValue; break; } } } } return(name); }
/// <summary> /// Returns the cloud protocol identifier for the supplied <see cref="RssCloudProtocol"/>. /// </summary> /// <param name="protocol">The <see cref="RssCloudProtocol"/> to get the cloud protocol identifier for.</param> /// <returns>The cloud protocol identifier for the supplied <paramref name="protocol"/>, otherwise returns an empty string.</returns> /// <example> /// <code lang="cs" title="The following code example demonstrates the usage of the CloudProtocolAsString method."> /// <code /// source="..\..\Documentation\Microsoft .NET 3.5\CodeExamplesLibrary\Core\Rss\RssCloudExample.cs" /// region="CloudProtocolAsString(RssCloudProtocol protocol)" /// /> /// </code> /// </example> public static string CloudProtocolAsString(RssCloudProtocol protocol) { string name = String.Empty; foreach (System.Reflection.FieldInfo fieldInfo in typeof(RssCloudProtocol).GetFields()) { if (fieldInfo.FieldType == typeof(RssCloudProtocol)) { RssCloudProtocol cloudProtocol = (RssCloudProtocol)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); if (cloudProtocol == protocol) { object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; name = enumerationMetadata.AlternateValue; break; } } } } return(name); }
/// <summary> /// Returns the tombstone status identifier for the supplied <see cref="FeedSynchronizationTombstoneStatus"/>. /// </summary> /// <param name="status">The <see cref="FeedSynchronizationTombstoneStatus"/> to get the tombstone status identifier for.</param> /// <returns>The tombstone status identifier for the supplied <paramref name="vocabulary"/>, otherwise returns an empty string.</returns> public static string TombstoneStatusAsString(FeedSynchronizationTombstoneStatus status) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ string name = String.Empty; //------------------------------------------------------------ // Return alternate value based on supplied protocol //------------------------------------------------------------ foreach (System.Reflection.FieldInfo fieldInfo in typeof(FeedSynchronizationTombstoneStatus).GetFields()) { if (fieldInfo.FieldType == typeof(FeedSynchronizationTombstoneStatus)) { FeedSynchronizationTombstoneStatus tombstoneStatus = (FeedSynchronizationTombstoneStatus)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); if (tombstoneStatus == status) { object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; name = enumerationMetadata.AlternateValue; break; } } } } return(name); }
/// <summary> /// Returns the <see cref="XmlRpcScalarValueType"/> enumeration value that corresponds to the specified scalar type name. /// </summary> /// <param name="name">The name of the scalar type.</param> /// <returns>A <see cref="XmlRpcScalarValueType"/> enumeration value that corresponds to the specified string, otherwise returns <b>XmlRpcScalarValueType.None</b>.</returns> /// <remarks>This method disregards case of specified scalar type name.</remarks> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is an empty string.</exception> /// <example> /// <code /// lang="cs" /// title="The following code example demonstrates the usage of the ScalarTypeByName method." /// /> /// </example> public static XmlRpcScalarValueType ScalarTypeByName(string name) { XmlRpcScalarValueType valueType = XmlRpcScalarValueType.None; Guard.ArgumentNotNullOrEmptyString(name, "name"); foreach (System.Reflection.FieldInfo fieldInfo in typeof(XmlRpcScalarValueType).GetFields()) { if (fieldInfo.FieldType == typeof(XmlRpcScalarValueType)) { XmlRpcScalarValueType type = (XmlRpcScalarValueType)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; if (String.Compare(name, enumerationMetadata.AlternateValue, StringComparison.OrdinalIgnoreCase) == 0) { valueType = type; break; } } } } return(valueType); }
/// <summary> /// Returns the restriction type identifier for the supplied <see cref="YahooMediaRestrictionType"/>. /// </summary> /// <param name="type">The <see cref="YahooMediaRestrictionType"/> to get the restriction type identifier for.</param> /// <returns>The restriction type identifier for the supplied <paramref name="type"/>, otherwise returns an empty string.</returns> public static string RestrictionTypeAsString(YahooMediaRestrictionType type) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ string name = String.Empty; //------------------------------------------------------------ // Return alternate value based on supplied protocol //------------------------------------------------------------ foreach (System.Reflection.FieldInfo fieldInfo in typeof(YahooMediaRestrictionType).GetFields()) { if (fieldInfo.FieldType == typeof(YahooMediaRestrictionType)) { YahooMediaRestrictionType restrictionType = (YahooMediaRestrictionType)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); if (restrictionType == type) { object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; name = enumerationMetadata.AlternateValue; break; } } } } return(name); }
/// <summary> /// Returns the type vocabulary identifier for the supplied <see cref="DublinCoreTypeVocabularies"/>. /// </summary> /// <param name="vocabulary">The <see cref="DublinCoreTypeVocabularies"/> to get the type vocabulary identifier for.</param> /// <returns>The type vocabulary identifier for the supplied <paramref name="vocabulary"/>, otherwise returns an empty string.</returns> public static string TypeVocabularyAsString(DublinCoreTypeVocabularies vocabulary) { string name = String.Empty; foreach (System.Reflection.FieldInfo fieldInfo in typeof(DublinCoreTypeVocabularies).GetFields()) { if (fieldInfo.FieldType == typeof(DublinCoreTypeVocabularies)) { DublinCoreTypeVocabularies typeVocabulary = (DublinCoreTypeVocabularies)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); if (typeVocabulary == vocabulary) { object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; name = enumerationMetadata.AlternateValue; break; } } } } return(name); }
/// <summary> /// Returns the <see cref="YahooMediaHashAlgorithm"/> enumeration value that corresponds to the specified hash algorithm name. /// </summary> /// <param name="name">The name of the hash algorithm.</param> /// <returns>A <see cref="YahooMediaHashAlgorithm"/> enumeration value that corresponds to the specified string, otherwise returns <b>YahooMediaHashAlgorithm.None</b>.</returns> /// <remarks>This method disregards case of specified hash algorithm name.</remarks> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is an empty string.</exception> public static YahooMediaHashAlgorithm HashAlgorithmByName(string name) { YahooMediaHashAlgorithm hashAlgorithm = YahooMediaHashAlgorithm.None; Guard.ArgumentNotNullOrEmptyString(name, "name"); foreach (System.Reflection.FieldInfo fieldInfo in typeof(YahooMediaHashAlgorithm).GetFields()) { if (fieldInfo.FieldType == typeof(YahooMediaHashAlgorithm)) { YahooMediaHashAlgorithm algorithm = (YahooMediaHashAlgorithm)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; if (String.Compare(name, enumerationMetadata.AlternateValue, StringComparison.OrdinalIgnoreCase) == 0) { hashAlgorithm = algorithm; break; } } } } return(hashAlgorithm); }
/// <summary> /// Returns the <see cref="FeedSynchronizationTombstoneStatus"/> enumeration value that corresponds to the specified tombstone status name. /// </summary> /// <param name="name">The name of the tombstone status.</param> /// <returns>A <see cref="FeedSynchronizationTombstoneStatus"/> enumeration value that corresponds to the specified string, otherwise returns <b>FeedSynchronizationTombstoneStatus.None</b>.</returns> /// <remarks>This method disregards case of specified tombstone status name.</remarks> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is an empty string.</exception> public static FeedSynchronizationTombstoneStatus TombstoneStatusByName(string name) { FeedSynchronizationTombstoneStatus tombstoneStatus = FeedSynchronizationTombstoneStatus.None; Guard.ArgumentNotNullOrEmptyString(name, "name"); foreach (System.Reflection.FieldInfo fieldInfo in typeof(FeedSynchronizationTombstoneStatus).GetFields()) { if (fieldInfo.FieldType == typeof(FeedSynchronizationTombstoneStatus)) { FeedSynchronizationTombstoneStatus status = (FeedSynchronizationTombstoneStatus)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; if (String.Compare(name, enumerationMetadata.AlternateValue, StringComparison.OrdinalIgnoreCase) == 0) { tombstoneStatus = status; break; } } } } return(tombstoneStatus); }
/// <summary> /// Returns the <see cref="DublinCoreTypeVocabularies"/> enumeration value that corresponds to the specified type vocabulary name. /// </summary> /// <param name="name">The name of the type vocabulary.</param> /// <returns>A <see cref="DublinCoreTypeVocabularies"/> enumeration value that corresponds to the specified string, otherwise returns <b>DublinCoreTypeVocabularies.None</b>.</returns> /// <remarks>This method disregards case of specified type vocabulary name.</remarks> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is an empty string.</exception> public static DublinCoreTypeVocabularies TypeVocabularyByName(string name) { DublinCoreTypeVocabularies typeVocabulary = DublinCoreTypeVocabularies.None; Guard.ArgumentNotNullOrEmptyString(name, "name"); foreach (System.Reflection.FieldInfo fieldInfo in typeof(DublinCoreTypeVocabularies).GetFields()) { if (fieldInfo.FieldType == typeof(DublinCoreTypeVocabularies)) { DublinCoreTypeVocabularies vocabulary = (DublinCoreTypeVocabularies)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; if (String.Compare(name, enumerationMetadata.AlternateValue, StringComparison.OrdinalIgnoreCase) == 0) { typeVocabulary = vocabulary; break; } } } } return(typeVocabulary); }
/// <summary> /// Returns the <see cref="SiteSummaryUpdatePeriod"/> enumeration value that corresponds to the specified period name. /// </summary> /// <param name="name">The name of the period.</param> /// <returns>A <see cref="SiteSummaryUpdatePeriod"/> enumeration value that corresponds to the specified string, otherwise returns <b>SiteSummaryUpdatePeriod.None</b>.</returns> /// <remarks>This method disregards case of specified period name.</remarks> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is an empty string.</exception> public static SiteSummaryUpdatePeriod PeriodByName(string name) { SiteSummaryUpdatePeriod updatePeriod = SiteSummaryUpdatePeriod.None; Guard.ArgumentNotNullOrEmptyString(name, "name"); foreach (System.Reflection.FieldInfo fieldInfo in typeof(SiteSummaryUpdatePeriod).GetFields()) { if (fieldInfo.FieldType == typeof(SiteSummaryUpdatePeriod)) { SiteSummaryUpdatePeriod period = (SiteSummaryUpdatePeriod)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; if (String.Compare(name, enumerationMetadata.AlternateValue, StringComparison.OrdinalIgnoreCase) == 0) { updatePeriod = period; break; } } } } return(updatePeriod); }
/// <summary> /// Returns the <see cref="ITunesExplicitMaterial"/> enumeration value that corresponds to the specified explicit material name. /// </summary> /// <param name="name">The name of the explicit material.</param> /// <returns>A <see cref="ITunesExplicitMaterial"/> enumeration value that corresponds to the specified string, otherwise returns <b>ITunesExplicitMaterial.None</b>.</returns> /// <remarks>This method disregards case of specified explicit material name.</remarks> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is an empty string.</exception> public static ITunesExplicitMaterial ExplicitMaterialByName(string name) { ITunesExplicitMaterial explicitMaterial = ITunesExplicitMaterial.None; Guard.ArgumentNotNullOrEmptyString(name, "name"); foreach (System.Reflection.FieldInfo fieldInfo in typeof(ITunesExplicitMaterial).GetFields()) { if (fieldInfo.FieldType == typeof(ITunesExplicitMaterial)) { ITunesExplicitMaterial material = (ITunesExplicitMaterial)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; if (String.Compare(name, enumerationMetadata.AlternateValue, StringComparison.OrdinalIgnoreCase) == 0) { explicitMaterial = material; break; } } } } return(explicitMaterial); }
/// <summary> /// Returns the <see cref="RssCloudProtocol"/> enumeration value that corresponds to the specified protocol name. /// </summary> /// <param name="name">The name of the cloud protocol.</param> /// <returns>A <see cref="RssCloudProtocol"/> enumeration value that corresponds to the specified string, otherwise returns <b>RssCloudProtocol.None</b>.</returns> /// <remarks>This method disregards case of specified protocol name.</remarks> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is an empty string.</exception> /// <example> /// <code lang="cs" title="The following code example demonstrates the usage of the CloudProtocolByName method."> /// <code /// source="..\..\Documentation\Microsoft .NET 3.5\CodeExamplesLibrary\Core\Rss\RssCloudExample.cs" /// region="CloudProtocolByName(string name)" /// /> /// </code> /// </example> public static RssCloudProtocol CloudProtocolByName(string name) { RssCloudProtocol cloudProtocol = RssCloudProtocol.None; Guard.ArgumentNotNullOrEmptyString(name, "name"); foreach (System.Reflection.FieldInfo fieldInfo in typeof(RssCloudProtocol).GetFields()) { if (fieldInfo.FieldType == typeof(RssCloudProtocol)) { RssCloudProtocol protocol = (RssCloudProtocol)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; if (String.Compare(name, enumerationMetadata.AlternateValue, StringComparison.OrdinalIgnoreCase) == 0) { cloudProtocol = protocol; break; } } } } return(cloudProtocol); }
/// <summary> /// Returns the cloud protocol identifier for the supplied <see cref="ITunesExplicitMaterial"/>. /// </summary> /// <param name="material">The <see cref="ITunesExplicitMaterial"/> to get the explicit material identifier for.</param> /// <returns>The explicit material identifier for the supplied <paramref name="material"/>, otherwise returns an empty string.</returns> public static string ExplicitMaterialAsString(ITunesExplicitMaterial material) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ string name = String.Empty; //------------------------------------------------------------ // Return alternate value based on supplied protocol //------------------------------------------------------------ foreach (System.Reflection.FieldInfo fieldInfo in typeof(ITunesExplicitMaterial).GetFields()) { if (fieldInfo.FieldType == typeof(ITunesExplicitMaterial)) { ITunesExplicitMaterial explicitMaterial = (ITunesExplicitMaterial)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); if (explicitMaterial == material) { object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; name = enumerationMetadata.AlternateValue; break; } } } } return(name); }
/// <summary> /// Returns the approval status identifier for the supplied <see cref="BlogMLApprovalStatus"/>. /// </summary> /// <param name="status">The <see cref="BlogMLApprovalStatus"/> to get the text construct identifier for.</param> /// <returns>The approval status identifier for the supplied <paramref name="type"/>, otherwise returns an empty string.</returns> public static string ApprovalStatusAsString(BlogMLApprovalStatus status) { string name = String.Empty; foreach (System.Reflection.FieldInfo fieldInfo in typeof(BlogMLApprovalStatus).GetFields()) { if (fieldInfo.FieldType == typeof(BlogMLApprovalStatus)) { BlogMLApprovalStatus approvalStatus = (BlogMLApprovalStatus)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); if (approvalStatus == status) { object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; name = enumerationMetadata.AlternateValue; break; } } } } return(name); }
/// <summary> /// Returns the hash algorithm identifier for the supplied <see cref="YahooMediaHashAlgorithm"/>. /// </summary> /// <param name="algorithm">The <see cref="YahooMediaHashAlgorithm"/> to get the hash algorithm identifier for.</param> /// <returns>The hash algorithm identifier for the supplied <paramref name="algorithm"/>, otherwise returns an empty string.</returns> public static string HashAlgorithmAsString(YahooMediaHashAlgorithm algorithm) { string name = String.Empty; foreach (System.Reflection.FieldInfo fieldInfo in typeof(YahooMediaHashAlgorithm).GetFields()) { if (fieldInfo.FieldType == typeof(YahooMediaHashAlgorithm)) { YahooMediaHashAlgorithm hashAlgorithm = (YahooMediaHashAlgorithm)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); if (hashAlgorithm == algorithm) { object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; name = enumerationMetadata.AlternateValue; break; } } } } return(name); }
/// <summary> /// Returns the <see cref="BlogMLApprovalStatus"/> enumeration value that corresponds to the specified approval status value. /// </summary> /// <param name="value">The value of the approval status identifier.</param> /// <returns>A <see cref="BlogMLApprovalStatus"/> enumeration value that corresponds to the specified string, otherwise returns <b>BlogMLApprovalStatus.None</b>.</returns> /// <remarks>This method disregards case of specified approval status value.</remarks> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is an empty string.</exception> public static BlogMLApprovalStatus ApprovalStatusByValue(string value) { BlogMLApprovalStatus approvalStatus = BlogMLApprovalStatus.None; Guard.ArgumentNotNullOrEmptyString(value, "value"); foreach (System.Reflection.FieldInfo fieldInfo in typeof(BlogMLApprovalStatus).GetFields()) { if (fieldInfo.FieldType == typeof(BlogMLApprovalStatus)) { BlogMLApprovalStatus status = (BlogMLApprovalStatus)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; if (String.Compare(value, enumerationMetadata.AlternateValue, StringComparison.OrdinalIgnoreCase) == 0) { approvalStatus = status; break; } } } } return(approvalStatus); }
/// <summary> /// Returns the scalar type identifier for the supplied <see cref="XmlRpcScalarValueType"/>. /// </summary> /// <param name="type">The <see cref="XmlRpcScalarValueType"/> to get the scalar type identifier for.</param> /// <returns>The scalar type identifier for the supplied <paramref name="type"/>, otherwise returns an empty string.</returns> /// <example> /// <code /// lang="cs" /// title="The following code example demonstrates the usage of the ScalarTypeAsString method." /// /> /// </example> public static string ScalarTypeAsString(XmlRpcScalarValueType type) { string name = String.Empty; foreach (System.Reflection.FieldInfo fieldInfo in typeof(XmlRpcScalarValueType).GetFields()) { if (fieldInfo.FieldType == typeof(XmlRpcScalarValueType)) { XmlRpcScalarValueType valueType = (XmlRpcScalarValueType)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); if (valueType == type) { object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; name = enumerationMetadata.AlternateValue; break; } } } } return(name); }
/// <summary> /// Returns the relation type identifier for the supplied <see cref="FeedSynchronizationRelatedInformationType"/>. /// </summary> /// <param name="type">The <see cref="FeedSynchronizationRelatedInformationType"/> to get the relation type identifier for.</param> /// <returns>The relation type identifier for the supplied <paramref name="vocabulary"/>, otherwise returns an empty string.</returns> public static string RelationTypeAsString(FeedSynchronizationRelatedInformationType type) { string name = String.Empty; foreach (System.Reflection.FieldInfo fieldInfo in typeof(FeedSynchronizationRelatedInformationType).GetFields()) { if (fieldInfo.FieldType == typeof(FeedSynchronizationRelatedInformationType)) { FeedSynchronizationRelatedInformationType relationType = (FeedSynchronizationRelatedInformationType)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); if (relationType == type) { object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; name = enumerationMetadata.AlternateValue; break; } } } } return(name); }
//============================================================ // STATIC METHODS //============================================================ #region AccessibilityAsString(LiveJournalSecurityType level) /// <summary> /// Returns the access level identifier for the supplied <see cref="LiveJournalSecurityType"/>. /// </summary> /// <param name="level">The <see cref="LiveJournalSecurityType"/> to get the access level identifier for.</param> /// <returns>The access level identifier for the supplied <paramref name="level"/>, otherwise returns an empty string.</returns> public static string AccessibilityAsString(LiveJournalSecurityType level) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ string name = String.Empty; //------------------------------------------------------------ // Return alternate value based on supplied protocol //------------------------------------------------------------ foreach (System.Reflection.FieldInfo fieldInfo in typeof(LiveJournalSecurityType).GetFields()) { if (fieldInfo.FieldType == typeof(LiveJournalSecurityType)) { LiveJournalSecurityType accessLevel = (LiveJournalSecurityType)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); if (accessLevel == level) { object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; name = enumerationMetadata.AlternateValue; break; } } } } return(name); }
/// <summary> /// Returns the relationship identifier for the supplied <see cref="YahooMediaRestrictionRelationship"/>. /// </summary> /// <param name="relationship">The <see cref="YahooMediaRestrictionRelationship"/> to get the relationship identifier for.</param> /// <returns>The relationship identifier for the supplied <paramref name="relationship"/>, otherwise returns an empty string.</returns> public static string RelationshipAsString(YahooMediaRestrictionRelationship relationship) { string name = String.Empty; foreach (System.Reflection.FieldInfo fieldInfo in typeof(YahooMediaRestrictionRelationship).GetFields()) { if (fieldInfo.FieldType == typeof(YahooMediaRestrictionRelationship)) { YahooMediaRestrictionRelationship restrictionRelationship = (YahooMediaRestrictionRelationship)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); if (restrictionRelationship == relationship) { object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; name = enumerationMetadata.AlternateValue; break; } } } } return(name); }
/// <summary> /// Returns the <see cref="YahooMediaRestrictionType"/> enumeration value that corresponds to the specified restriction type name. /// </summary> /// <param name="name">The name of the restriction type.</param> /// <returns>A <see cref="YahooMediaRestrictionType"/> enumeration value that corresponds to the specified string, otherwise returns <b>YahooMediaRestrictionType.None</b>.</returns> /// <remarks>This method disregards case of specified restriction type name.</remarks> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is an empty string.</exception> public static YahooMediaRestrictionType RestrictionTypeByName(string name) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ YahooMediaRestrictionType restrictionType = YahooMediaRestrictionType.None; //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNullOrEmptyString(name, "name"); //------------------------------------------------------------ // Determine syndication content format based on supplied name //------------------------------------------------------------ foreach (System.Reflection.FieldInfo fieldInfo in typeof(YahooMediaRestrictionType).GetFields()) { if (fieldInfo.FieldType == typeof(YahooMediaRestrictionType)) { YahooMediaRestrictionType type = (YahooMediaRestrictionType)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; if (String.Compare(name, enumerationMetadata.AlternateValue, StringComparison.OrdinalIgnoreCase) == 0) { restrictionType = type; break; } } } } return(restrictionType); }
/// <summary> /// Returns the <see cref="FeedSynchronizationConflictPreservationDirective"/> enumeration value that corresponds to the specified conflict preservation name. /// </summary> /// <param name="name">The name of the conflict preservation.</param> /// <returns>A <see cref="FeedSynchronizationConflictPreservationDirective"/> enumeration value that corresponds to the specified string, otherwise returns <b>FeedSynchronizationConflictPreservationDirective.None</b>.</returns> /// <remarks>This method disregards case of specified conflict preservation name.</remarks> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="name"/> is an empty string.</exception> public static FeedSynchronizationConflictPreservationDirective ConflictPreservationByName(string name) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ FeedSynchronizationConflictPreservationDirective preservationDirective = FeedSynchronizationConflictPreservationDirective.None; //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNullOrEmptyString(name, "name"); //------------------------------------------------------------ // Determine syndication content format based on supplied name //------------------------------------------------------------ foreach (System.Reflection.FieldInfo fieldInfo in typeof(FeedSynchronizationConflictPreservationDirective).GetFields()) { if (fieldInfo.FieldType == typeof(FeedSynchronizationConflictPreservationDirective)) { FeedSynchronizationConflictPreservationDirective directive = (FeedSynchronizationConflictPreservationDirective)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name); object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute; if (String.Compare(name, enumerationMetadata.AlternateValue, StringComparison.OrdinalIgnoreCase) == 0) { preservationDirective = directive; break; } } } } return(preservationDirective); }