Exemple #1
0
        /// <summary>
        /// Converts the string representation of the name or numeric value of one or more enumerated
        /// constants to an equivalent enumerated object. A parameter specifies whether the operation
        /// is case-sensitive. The return value indicates whether the conversion succeeded.
        /// </summary>
        /// <param name="enumType">Type of the enum.</param>
        /// <param name="value">The string representation of the enumeration name or underlying value to convert.</param>
        /// <param name="ignoreCase">true to ignore case; false to consider case.</param>
        /// <param name="result">
        /// When this method returns, contains an object of the given type whose value is represented by value.
        /// This parameter is passed uninitialized.
        /// </param>
        /// <returns>true if the value parameter was converted successfully; otherwise, false.</returns>
        /// <remarks>
        /// It is recommended that you use <see cref="Enum.TryParse{TEnum}(string, bool, out TEnum)"/>
        /// instead of this method when possible.
        /// </remarks>
        public static bool TryParse(Type enumType, [NotNullWhen(true)] string?value, bool ignoreCase, out object result)
        {
            VerifyEnumType(enumType);
            InvokerDelegatePair pair = GetTryParsePair(enumType);

            return(pair.Item1(pair.Item2, value, ignoreCase, out result));
        }
Exemple #2
0
        public static bool TryParseDCSlow <TEnum> (string value, bool ignoreCase, out TEnum result)
        {
            object parsedValue;
            InvokerDelegatePair pair = GetTryParsePair(typeof(TEnum));
            bool success             = pair.Item1(pair.Item2, value, ignoreCase, out parsedValue);

            result = (TEnum)parsedValue;
            return(success);
        }
Exemple #3
0
        public static bool TryParseDC(Type enumType, string value, bool ignoreCase, out object result)
        {
            InvokerDelegatePair pair = GetTryParsePair(enumType);

            return(pair.Item1(pair.Item2, value, ignoreCase, out result));
        }