Esempio n. 1
0
        static void Main()
        {
            var enumTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(assembly => assembly.GetTypes()).Where(type => type.IsEnum && !type.IsGenericType).ToList();

            //var methodInfo = typeof(Enums).GetMethod("GetUnderlyingType");
            using (new OperationTimer("All Available Enums Caching Performance"))
            {
                foreach (var enumType in enumTypes)
                {
                    //methodInfo.MakeGenericMethod(enumType).Invoke(null, null);
                    NonGenericEnums.GetUnderlyingType(enumType);
                }
            }
            Console.WriteLine(enumTypes.Count);

            Parse(enumTypes);

            var dayOfWeekArray = new DayOfWeek[14];

            for (var i = 0; i < dayOfWeekArray.Length; ++i)
            {
                dayOfWeekArray[i] = (DayOfWeek)i;
            }

            ToString(dayOfWeekArray);

            IsDefined(dayOfWeekArray);

            GetHashCode(dayOfWeekArray);

            var attributeTargetsArray = new AttributeTargets[15];

            attributeTargetsArray[0] = (AttributeTargets)0;
            attributeTargetsArray[1] = (AttributeTargets)1;
            for (var i = 2; i < attributeTargetsArray.Length; ++i)
            {
                attributeTargetsArray[i] = (AttributeTargets)(1 << (i - 1)) | (AttributeTargets)(1 << (i - 2));
            }
            var allAttributeTargets = (AttributeTargets[])Enum.GetValues(typeof(AttributeTargets));

            HasFlag(attributeTargetsArray, allAttributeTargets);

            Console.ReadLine();
        }
 public void NonGenericEnumsGetUnderlyingType()
 {
     Assert.AreEqual(typeof(short), NonGenericEnums.GetUnderlyingType(typeof(DateFilterOperator)));
     Assert.AreEqual(typeof(ulong), NonGenericEnums.GetUnderlyingType(typeof(ContiguousUInt64Enum)));
     Assert.AreEqual(typeof(long), NonGenericEnums.GetUnderlyingType(typeof(NonContiguousEnum)));
 }