Ejemplo n.º 1
0
        /// <summary>
        /// Call delegate for each public static PropertyDefinition field in type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="propFieldDelegate">The property field delegate.</param>
        internal static void ForeachPublicStaticPropertyFieldInType(Type type, PropertyFieldInfoDelegate propFieldDelegate)
        {
            FieldInfo[] fieldInfos = type.GetRuntimeFields().ToArray();

            foreach (FieldInfo fieldInfo in fieldInfos)
            {
                if (fieldInfo.FieldType == typeof(PropertyDefinition) || fieldInfo.FieldType.GetTypeInfo().IsSubclassOf(typeof(PropertyDefinition)))
                {
                    PropertyDefinition propertyDefinition = (PropertyDefinition)fieldInfo.GetValue(null);
                    propFieldDelegate(propertyDefinition, fieldInfo);
                }
            }
        }
        /// <summary>
        /// Call delegate for each public static PropertyDefinition field in type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="propFieldDelegate">The property field delegate.</param>
        internal static void ForeachPublicStaticPropertyFieldInType(Type type, PropertyFieldInfoDelegate propFieldDelegate)
        {
            FieldInfo[] fieldInfos = type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly);

            foreach (FieldInfo fieldInfo in fieldInfos)
            {
                if (fieldInfo.FieldType == typeof(PropertyDefinition) || fieldInfo.FieldType.IsAssignableFrom(typeof(PropertyDefinition)))
                {
                    PropertyDefinition propertyDefinition = (PropertyDefinition)fieldInfo.GetValue(null);
                    propFieldDelegate(propertyDefinition, fieldInfo);
                }
            }
        }