public void CanEnumerateFontfaceOptions() { var fontfaces = ValueEnum.Enumerate <FontfaceOptions>(); foreach (var fontface in fontfaces) { } }
/// <summary> /// Attempts to convert the string identifier of the <see cref="ValueEnum{TValue}"/> /// to the instance of the member declaration. The return value indicates whether /// the conversion succeeded. /// </summary> /// <param name="valueEnumType"> /// The Type of the <see cref="ValueEnum{TValue}"/> declaration. /// </param> /// <param name="name"> /// The <see cref="ValueEnum{TValue}"/> member declaration member identifier to parse.</param> /// <param name="valueEnumInstance"> /// The returned instance of the member with the provided identifier name. /// </param> /// <returns> /// A boolean value indicating whether the conversion succeeded. /// </returns> public static bool TryParse( Type valueEnumType, string name, out ValueEnum valueEnumInstance) { return(TryParse( valueEnumType, name, false, out valueEnumInstance)); }
/// <summary> /// Attempts to convert the string identifier of the <see cref="ValueEnum{TValue}"/> /// to the instance of the member declaration. The return value indicates whether /// the conversion succeeded. /// </summary> /// <param name="valueEnumType"> /// The Type of the <see cref="ValueEnum{TValue}"/> declaration. /// </param> /// <param name="name"> /// The <see cref="ValueEnum{TValue}"/> member declaration member identifier to parse.</param> /// <param name="ignoreCase"> /// A boolean parameter that if set to true will use a case-insensitive <see cref="StringComparison"/> /// as a comparator against the ValueEnum member identifiers. This is not an optional property. /// </param> /// <param name="valueEnumInstance"> /// The returned instance of the member with the provided identifier name. /// </param> /// <returns> /// A boolean value indicating whether the conversion succeeded. /// </returns> public static bool TryParse( Type valueEnumType, string name, bool ignoreCase, out ValueEnum valueEnumInstance) { try { valueEnumInstance = Parse(valueEnumType, name, ignoreCase); return(true); } catch (Exception ex) when( ex is ArgumentNullException || ex is ArgumentException) { valueEnumInstance = default(ValueEnum); return(false); } }