Example #1
0
 public static InvokeWrapper[] FindFieldsAndProperties(object obj,
                                                       Type type,
                                                       BindingFlags fieldBindFlags    = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static,
                                                       BindingFlags propertyBindFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)
 {
     FieldWrapper[]    fields     = FieldWrapper.FindFields(obj, type, fieldBindFlags);
     PropertyWrapper[] properties = PropertyWrapper.FindProperties(obj, type, propertyBindFlags);
     return(fields.Concat <InvokeWrapper>(properties).ToArray());
 }
Example #2
0
        /// <summary>
        /// Collects fields and properties of a given type.
        /// </summary>
        /// <param name="type">Type.</param>
        /// <param name="fieldBindingFlags">Field binding flags.</param>
        /// <param name="propertyBindingFlags">Properties binding flags.</param>
        /// <returns>Array of field/property wrappers.</returns>
        public static InvokeWrapper[] FindFieldsAndProperties(Type type,
                                                              BindingFlags fieldBindingFlags    = DefaultBindingFlags,
                                                              BindingFlags propertyBindingFlags = DefaultBindingFlags)
        {
            FieldWrapper[]    fields     = FieldWrapper.FindFields(type, fieldBindingFlags);
            PropertyWrapper[] properties = PropertyWrapper.FindProperties(type, propertyBindingFlags);

            return(fields.Concat <InvokeWrapper>(properties).OrderByDescending(wrapper => wrapper.Priority).ToArray());
        }
Example #3
0
        /// <summary>
        /// Collects fields and properties of a given type.
        /// </summary>
        /// <param name="type">Type.</param>
        /// <param name="fieldBindingFlags">Field binding flags.</param>
        /// <param name="propertyBindingFlags">Properties binding flags.</param>
        /// <returns>Array of field/property wrappers.</returns>
        public static InvokeWrapper[] FindFieldsAndProperties(Type type,
                                                              BindingFlags fieldBindingFlags    = DefaultBindingFlags,
                                                              BindingFlags propertyBindingFlags = DefaultBindingFlags)
        {
            var isDefaultBindings = fieldBindingFlags == DefaultBindingFlags &&
                                    propertyBindingFlags == DefaultBindingFlags;

            if (isDefaultBindings &&
                s_defaultBindingFlagsFieldsPropertiesCache.TryGetValue(type, out var fieldsAndPropertiesCache))
            {
                return(fieldsAndPropertiesCache);
            }

            var fields              = FieldWrapper.FindFields(type, fieldBindingFlags);
            var properties          = PropertyWrapper.FindProperties(type, propertyBindingFlags);
            var fieldsAndProperties = fields.Concat <InvokeWrapper>(properties).OrderByDescending(wrapper => wrapper.Priority).ToArray();

            if (isDefaultBindings)
            {
                s_defaultBindingFlagsFieldsPropertiesCache.Add(type, fieldsAndProperties);
            }
            return(fieldsAndProperties);
        }