/// <summary> /// Initializes a new instance of KeyDescriptor from the specified attribute during a KeysMeta /// initializes itself using reflection. /// </summary> public KeyDescriptor(KeyInfoAttribute attribute) { Version = attribute.Version; KeyType = attribute.KeyType; FixedValue = attribute.FixedValue; ObjectType = attribute.ObjectType; if (Version == "") { Version = "1.0"; } }
public DictionaryMeta(Type type) { //#if (NETFX_CORE && DEBUG) || CORE // if (type == typeof(PDFPages.Keys)) // { // var x = typeof(PDFPages).GetRuntimeFields(); // var y = typeof(PDFPages).GetTypeInfo().DeclaredFields; // x.GetType(); // y.GetType(); // Debug-Break.Break(); // Test.It(); // } //#endif #if !NETFX_CORE && !UWP FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); foreach (FieldInfo field in fields) { object[] attributes = field.GetCustomAttributes(typeof(KeyInfoAttribute), false); if (attributes.Length == 1) { KeyInfoAttribute attribute = (KeyInfoAttribute)attributes[0]; KeyDescriptor descriptor = new KeyDescriptor(attribute) { KeyValue = (string)field.GetValue(null) }; _keyDescriptors[descriptor.KeyValue] = descriptor; } } #else // Rewritten for WinRT. CollectKeyDescriptors(type); //var fields = type.GetRuntimeFields(); // does not work //fields2.GetType(); //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; // } //} #endif }