static JsonDynamicIdConverter()
        {
            var names  = Enum.GetNames(typeof(TEnum));
            var values = (TEnum[])Enum.GetValues(typeof(TEnum));

            for (var i = 0; i < values.Length; ++i)
            {
                IntToName.Add(Convert.ToInt32(values[i]), names[i]);
                NameToInt.Add(names[i].ToLower(), Convert.ToInt32(values[i]));
            }
        }
Exemple #2
0
        static JsonDynamicIdConverter()
        {
            var names1  = Enum.GetNames(typeof(TEnum1));
            var values1 = (TEnum1[])Enum.GetValues(typeof(TEnum1));

            for (var i = 0; i < values1.Length; ++i)
            {
                IntToName.Add(Convert.ToInt32(values1[i]), names1[i]);
                NameToInt.Add(names1[i].ToLower(), Convert.ToInt32(values1[i]));
            }

            var names2  = Enum.GetNames(typeof(TEnum2));
            var values2 = (TEnum2[])Enum.GetValues(typeof(TEnum2));

            for (var i = 0; i < values2.Length; ++i)
            {
                if (string.Equals(names2[i], "Undefined"))
                {
                    continue;
                }
                IntToName.Add(Convert.ToInt32(values2[i]), names2[i]);
                NameToInt.Add(names2[i].ToLower(), Convert.ToInt32(values2[i]));
            }
        }