/// <summary>Initializes a new instance of the <see cref="PropertyValueEnumerator" /> class.</summary> /// <param name="instance">Instance to iterate.</param> /// <param name="bindingFlags">Property binding flags.</param> /// <param name="recursive">Recursive property search.</param> /// <param name="filter">Allows to filter properties.</param> public PropertyValueEnumerator(object instance, BindingFlags bindingFlags, bool recursive = false, PropertyDataFilter filter = null) { Filter = filter; Root = instance; BindingFlags = bindingFlags; Recursive = recursive; Reset(); }
/// <summary>Initializes a new instance of the <see cref="PropertyEnumerator" /> class.</summary> /// <param name="type">Type to iterate.</param> /// <param name="bindingFlags">Property binding flags.</param> /// <param name="recursive">Recursive property search.</param> /// <param name="filter">Allows to filter properties.</param> public PropertyEnumerator(Type type, BindingFlags bindingFlags, bool recursive = false, PropertyDataFilter filter = null) { Filter = filter; Root = type; BindingFlags = bindingFlags; Recursive = recursive; Reset(); }
/// <summary>Get a list of available properties.</summary> /// <param name="instance">Object instance to read.</param> /// <param name="bindingFlags">A bitwise combination of the enumeration values that specify how the search is conducted.</param> /// <param name="withValue">List only sub-properties with values.</param> /// <param name="noRecursion">Disable recursion.</param> /// <param name="filter">Allows to filter properties.</param> /// <returns>Returns an <see cref="IEnumerable{T}" /> with all properties of the specified instance.</returns> public static IEnumerable <PropertyData> GetProperties(this object instance, BindingFlags bindingFlags = 0, bool withValue = false, bool noRecursion = false, PropertyDataFilter filter = null) { if (instance == null) { throw new ArgumentNullException(nameof(instance)); } if (bindingFlags == 0) { bindingFlags = BindingFlags.Instance | BindingFlags.Public; } return(withValue ? new PropertyValueEnumerator(instance, bindingFlags, !noRecursion, filter) : new PropertyEnumerator(instance.GetType(), bindingFlags, !noRecursion, filter)); }