ReflectionExtensions.GetFields C# (CSharp) Method

GetFields() public static method

public static GetFields ( this type ) : IEnumerable
type this
return IEnumerable
    public static IEnumerable<FieldInfo> GetFields(this Type type)
    {
        return  GetFields(type, (BindingFlags)0x0);
    }

Same methods

ReflectionExtensions::GetFields ( this type, BindingFlags, flags ) : IEnumerable

Usage Example

Ejemplo n.º 1
0
        static DependencyProperty GetForegroundProperty(FrameworkElement element)
        {
            if (element is Control)
            {
                return(Control.ForegroundProperty);
            }
            if (element is TextBlock)
            {
                return(TextBlock.ForegroundProperty);
            }

            Type type = element.GetType();

            DependencyProperty foregroundProperty;

            if (!ForegroundProperties.Value.TryGetValue(type, out foregroundProperty))
            {
                FieldInfo field = ReflectionExtensions.GetFields(type).FirstOrDefault(f => f.Name == "ForegroundProperty");
                if (field == null)
                {
                    throw new ArgumentException("type is not a Foregroundable type");
                }

                var property = (DependencyProperty)field.GetValue(null);
                ForegroundProperties.Value.TryAdd(type, property);

                return(property);
            }

            return(foregroundProperty);
        }
All Usage Examples Of ReflectionExtensions::GetFields