コード例 #1
0
        private static IDictionary <FieldType, MappedType> MapFieldTypes()
        {
            var map = new Dictionary <FieldType, MappedType>();

            foreach (FieldInfo field in typeof(FieldType).GetFields(BindingFlags.Static | BindingFlags.Public))
            {
                FieldType             fieldType = (FieldType)field.GetValue(null);
                FieldMappingAttribute mapping   = (FieldMappingAttribute)field.GetCustomAttributes(typeof(FieldMappingAttribute), false)[0];
                map[fieldType] = mapping.MappedType;
            }
            return(Dictionaries.AsReadOnly(map));
        }
コード例 #2
0
        private static IDictionary <FieldType, FieldMappingAttribute> MapFieldTypes()
        {
            Dictionary <FieldType, FieldMappingAttribute> dictionary = new Dictionary <FieldType, FieldMappingAttribute>();

            FieldInfo[] fields = typeof(FieldType).GetFields((BindingFlags)24);
            for (int i = 0; i < fields.Length; i++)
            {
                FieldInfo             fieldInfo             = fields[i];
                FieldType             fieldType             = (FieldType)fieldInfo.GetValue(null);
                FieldMappingAttribute fieldMappingAttribute = (FieldMappingAttribute)fieldInfo.GetCustomAttributes(typeof(FieldMappingAttribute), false).GetEnumerator().Current;
                dictionary[fieldType] = fieldMappingAttribute;
            }
            return(Dictionaries.AsReadOnly <FieldType, FieldMappingAttribute>(dictionary));
        }