// Background: The function GetRuntimeFields gets constant fields only for the specified type, // not for its base types. So we have to walk recursively through base classes. // The docmentation says full trust for the immediate caller is required for property BaseClass. // TODO: Rewrite this stuff for medium trust. void CollectKeyDescriptors(Type type) { // Get fields of the specified type only. var fields = type.GetTypeInfo().DeclaredFields; foreach (FieldInfo field in fields) { var attributes = field.GetCustomAttributes(typeof(KeyInfoAttribute), false); foreach (var attribute in attributes) { KeyDescriptor descriptor = new KeyDescriptor((KeyInfoAttribute)attribute); descriptor.KeyValue = (string)field.GetValue(null); _keyDescriptors[descriptor.KeyValue] = descriptor; } } type = type.GetTypeInfo().BaseType; if (type != typeof(object) && type != typeof(PdfObject)) { CollectKeyDescriptors(type); } }