Beispiel #1
0
        static LevelObjectInformation()
        {
            var type = typeof(ObjectProperty);
            var baseAttributeType = typeof(ObjectPropertyTypeAttribute);
            var attributeTypes    = baseAttributeType.Assembly.GetTypes().Where(t => t.BaseType == baseAttributeType);

            foreach (var field in type.GetFields())
            {
                ObjectPropertyTypeAttribute a = null;
                for (int i = 0; i < attributeTypes.Count() && a == null; i++)
                {
                    a = field.GetCustomAttributes(baseAttributeType, false).FirstOrDefault() as ObjectPropertyTypeAttribute;
                }
                int value = (int)field.GetRawConstantValue();
                if (value > 0)
                {
                    objectPropertyAttributes[value - 1]     = a;
                    objectPropertyAttributeTypes[value - 1] = a?.GetType();
                }
            }
        }
        static LevelObjectInformation()
        {
            var type = typeof(ObjectProperty);
            var baseAttributeType = typeof(ObjectPropertyTypeAttribute);
            var attributeTypes    = baseAttributeType.Assembly.GetTypes().Where(t => t.BaseType == baseAttributeType);

            foreach (var n in Enum.GetNames(type))
            {
                var m = type.GetMember(n).FirstOrDefault();
                ObjectPropertyTypeAttribute a = null;
                for (int i = 0; i < attributeTypes.Count() && a == null; i++)
                {
                    a = m.GetCustomAttributes(baseAttributeType, false).FirstOrDefault() as ObjectPropertyTypeAttribute;
                }
                int value = (int)Enum.Parse(type, n);
                if (value > 0)
                {
                    objectPropertyAttributes[value - 1]     = a;
                    objectPropertyAttributeTypes[value - 1] = a?.GetType();
                }
            }
        }