Ejemplo n.º 1
0
        // Token: 0x0600172A RID: 5930 RVA: 0x0006D9BC File Offset: 0x0006BBBC
        public static object ParseEnumName(string enumText, bool isNullable, Type t)
        {
            if (enumText == string.Empty && isNullable)
            {
                return(null);
            }
            Class_495 <string, string> map = Class_505.EnumMemberNamesPerType.Get(t);
            string value;

            if (enumText.IndexOf(',') != -1)
            {
                string[] array = enumText.Split(new char[]
                {
                    ','
                });
                for (int i = 0; i < array.Length; i++)
                {
                    string enumText2 = array[i].Trim();
                    array[i] = Class_505.ResolvedEnumName(map, enumText2);
                }
                value = string.Join(", ", array);
            }
            else
            {
                value = Class_505.ResolvedEnumName(map, enumText);
            }
            return(Enum.Parse(t, value, true));
        }
Ejemplo n.º 2
0
        // Token: 0x0600172C RID: 5932 RVA: 0x0006DAF0 File Offset: 0x0006BCF0
        private static string ResolvedEnumName(Class_495 <string, string> map, string enumText)
        {
            string text;

            map.TryGetBySecond(enumText, ref text);
            text = (text ?? enumText);
            return(text);
        }
Ejemplo n.º 3
0
        // Token: 0x06001724 RID: 5924 RVA: 0x0006D548 File Offset: 0x0006B748
        private static Class_495 <string, string> InitializeEnumType(Type type)
        {
            Class_495 <string, string> class_ = new Class_495 <string, string>(StringComparer.OrdinalIgnoreCase, StringComparer.OrdinalIgnoreCase);

            foreach (FieldInfo fieldInfo in type.GetFields())
            {
                string name = fieldInfo.Name;
                string text = (from EnumMemberAttribute a in fieldInfo.GetCustomAttributes(typeof(EnumMemberAttribute), true)
                               select a.Value).SingleOrDefault <string>() ?? fieldInfo.Name;
                string text2;
                if (class_.TryGetBySecond(text, ref text2))
                {
                    throw new InvalidOperationException("Enum name '{0}' already exists on enum '{1}'.".FormatWith(CultureInfo.InvariantCulture, text, type.Name));
                }
                class_.Set(name, text);
            }
            return(class_);
        }
Ejemplo n.º 4
0
        // Token: 0x0600172B RID: 5931 RVA: 0x0006DA64 File Offset: 0x0006BC64
        public static string ToEnumName(Type enumType, string enumText, bool camelCaseText)
        {
            Class_495 <string, string> class_ = Class_505.EnumMemberNamesPerType.Get(enumType);

            string[] array = enumText.Split(new char[]
            {
                ','
            });
            for (int i = 0; i < array.Length; i++)
            {
                string text = array[i].Trim();
                string text2;
                class_.TryGetByFirst(text, ref text2);
                text2 = (text2 ?? text);
                if (camelCaseText)
                {
                    text2 = Class_515.ToCamelCase(text2);
                }
                array[i] = text2;
            }
            return(string.Join(", ", array));
        }