Example #1
0
        public static object ParseEnumName(string enumText, bool isNullable, Type t)
        {
            if (enumText == string.Empty & isNullable)
            {
                return((object)null);
            }
            BidirectionalDictionary <string, string> map = EnumUtils.EnumMemberNamesPerType.Get(t);
            string str;

            if (enumText.IndexOf(',') != -1)
            {
                string[] strArray = enumText.Split(',');
                for (int index = 0; index < strArray.Length; ++index)
                {
                    string enumText1 = strArray[index].Trim();
                    strArray[index] = EnumUtils.ResolvedEnumName(map, enumText1);
                }
                str = string.Join(", ", strArray);
            }
            else
            {
                str = EnumUtils.ResolvedEnumName(map, enumText);
            }
            return(Enum.Parse(t, str, true));
        }
Example #2
0
        public static object ParseEnumName(string enumText, bool isNullable, Type t)
        {
            string str;

            if ((enumText == string.Empty) & isNullable)
            {
                return(null);
            }
            BidirectionalDictionary <string, string> bidirectionalDictionary = EnumUtils.EnumMemberNamesPerType.Get(t);

            if (enumText.IndexOf(',') == -1)
            {
                str = EnumUtils.ResolvedEnumName(bidirectionalDictionary, enumText);
            }
            else
            {
                string[] strArrays = enumText.Split(new char[] { ',' });
                for (int i = 0; i < (int)strArrays.Length; i++)
                {
                    string str1 = strArrays[i].Trim();
                    strArrays[i] = EnumUtils.ResolvedEnumName(bidirectionalDictionary, str1);
                }
                str = string.Join(", ", strArrays);
            }
            return(Enum.Parse(t, str, true));
        }