Пример #1
0
    // Reads all fields in 'Volume' class using reflection. And sends action for each field.
    public void DoVolumeReflection(Action <FieldInfo> action)
    {
        Type type = volumes.GetType();

        while (type != null)
        {
            FieldInfo[] myObjectFields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

            foreach (FieldInfo field in myObjectFields)
            {
                action(field);
            }


            type = type.BaseType;
        }
    }