コード例 #1
0
        public static IList <T> smethod_0 <T>(T gparam_0) where T : struct
        {
            Type type = typeof(T);

            if (!type.IsDefined(typeof(FlagsAttribute), false))
            {
                throw new ArgumentException("Enum type {0} is not a set of flags.".smethod_0(CultureInfo.InvariantCulture, type));
            }
            Type             underlyingType = Enum.GetUnderlyingType(gparam_0.GetType());
            ulong            num            = Convert.ToUInt64(gparam_0, CultureInfo.InvariantCulture);
            Class188 <ulong> source         = smethod_1 <T>();
            IList <T>        list           = new List <T>();

            foreach (Class187 <ulong> class3 in source)
            {
                if (((num & class3.Prop_0) == class3.Prop_0) && (class3.Prop_0 != 0L))
                {
                    list.Add((T)Convert.ChangeType(class3.Prop_0, underlyingType, CultureInfo.CurrentCulture));
                }
            }
            if ((list.Count == 0) && (source.SingleOrDefault <Class187 <ulong> >(new Func <Class187 <ulong>, bool>(Class186.smethod_5 <T>)) != null))
            {
                list.Add(default(T));
            }
            return(list);
        }
コード例 #2
0
        public static Class188 <T> smethod_2 <T>(Type type_0) where T : struct
        {
            if (type_0 == null)
            {
                throw new ArgumentNullException("enumType");
            }
            Class203.smethod_1(type_0, "enumType");
            IList <object> list   = smethod_3(type_0);
            IList <string> list2  = smethod_4(type_0);
            Class188 <T>   class2 = new Class188 <T>();

            for (int i = 0; i < list.Count; i++)
            {
                try
                {
                    class2.Add(new Class187 <T>(list2[i], (T)Convert.ChangeType(list[i], typeof(T), CultureInfo.CurrentCulture)));
                }
                catch (OverflowException exception)
                {
                    throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Value from enum with the underlying type of {0} cannot be added to dictionary with a value type of {1}. Value was too large: {2}", new object[] { Enum.GetUnderlyingType(type_0), typeof(T), Convert.ToUInt64(list[i], CultureInfo.InvariantCulture) }), exception);
                }
            }
            return(class2);
        }