コード例 #1
0
ファイル: AttributeMap.cs プロジェクト: GeorchW/protobuf-net
        public static AttributeMap[] Create(TypeModel model, MemberInfo member, bool inherit)
        {
#if FEAT_IKVM
            System.Collections.Generic.IList<CustomAttributeData> all = member.__GetCustomAttributes(model.MapType(typeof(Attribute)), inherit);
            AttributeMap[] result = new AttributeMap[all.Count];
            int index = 0;
            foreach (CustomAttributeData attrib in all)
            {
                result[index++] = new AttributeDataMap(attrib);
            }
            return result;
#else
#if WINRT || COREFX
            Attribute[] all = System.Linq.Enumerable.ToArray(member.GetCustomAttributes(inherit));
#else
            object[] all = member.GetCustomAttributes(inherit);
#endif
            AttributeMap[] result = new AttributeMap[all.Length];
            for(int i = 0 ; i < all.Length ; i++)
            {
                result[i] = new ReflectionAttributeMap((Attribute)all[i]);
            }
            return result;
#endif
        }
コード例 #2
0
ファイル: AttributeMap.cs プロジェクト: 289997171/vicking
 public static AttributeMap[] Create(TypeModel model, Type type, bool inherit)
 {
     #if FEAT_IKVM
     Type attribType = model.MapType(typeof(System.Attribute));
     System.Collections.Generic.IList<CustomAttributeData> all = type.__GetCustomAttributes(attribType, inherit);
     AttributeMap[] result = new AttributeMap[all.Count];
     int index = 0;
     foreach (CustomAttributeData attrib in all)
     {
         result[index++] = new AttributeDataMap(attrib);
     }
     return result;
     #else
     #if WINRT
     Attribute[] all = System.Linq.Enumerable.ToArray(type.GetTypeInfo().GetCustomAttributes(inherit));
     #else
     var all = type.GetCustomAttributes(inherit);
     #endif
     var result = new AttributeMap[all.Length];
     for (var i = 0; i < all.Length; i++)
     {
         result[i] = new ReflectionAttributeMap((Attribute) all[i]);
     }
     return result;
     #endif
 }
コード例 #3
0
        public static AttributeMap[] Create(TypeModel model, MemberInfo member, bool inherit)
        {
#if FEAT_IKVM
            System.Collections.Generic.IList <CustomAttributeData> all = member.__GetCustomAttributes(model.MapType(typeof(Attribute)), inherit);
            AttributeMap[] result = new AttributeMap[all.Count];
            int            index  = 0;
            foreach (CustomAttributeData attrib in all)
            {
                result[index++] = new AttributeDataMap(attrib);
            }
            return(result);
#else
#if WINRT
            Attribute[] all = System.Linq.Enumerable.ToArray(member.GetCustomAttributes(inherit));
#else
            object[] all = member.GetCustomAttributes(inherit);
#endif
            AttributeMap[] result = new AttributeMap[all.Length];
            for (int i = 0; i < all.Length; i++)
            {
                result[i] = new ReflectionAttributeMap((Attribute)all[i]);
            }
            return(result);
#endif
        }
コード例 #4
0
        public static AttributeMap[] Create(TypeModel model, Type type, bool inherit)
        {
#if FEAT_IKVM
            Type attribType = model.MapType(typeof(System.Attribute));
            System.Collections.Generic.IList <CustomAttributeData> all = type.__GetCustomAttributes(attribType, inherit);
            AttributeMap[] result = new AttributeMap[all.Count];
            int            index  = 0;
            foreach (CustomAttributeData attrib in all)
            {
                result[index++] = new AttributeDataMap(attrib);
            }
            return(result);
#else
            //#if WINRT || COREFX
            //      Attribute[] all = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.OfType<Attribute>(type.GetTypeInfo().GetCustomAttributes(inherit)));
            //#else
            Attribute[] all = type.GetAllAttributes(null, inherit).ToArray();
//#endif
            AttributeMap[] result = new AttributeMap[all.Length];
            for (int i = 0; i < all.Length; i++)
            {
                result[i] = new ReflectionAttributeMap(all[i]);
            }
            return(result);
#endif
        }
コード例 #5
0
        public static AttributeMap[] Create(ITypeMapper model, Type type, bool inherit)
        {
#if FEAT_IKVM
            Type attribType = model.MapType(typeof(System.Attribute), true);
            System.Collections.Generic.IList <CustomAttributeData> all = type.__GetCustomAttributes(attribType, inherit);
            AttributeMap[] result = new AttributeMap[all.Count];
            int            index  = 0;
            foreach (CustomAttributeData attrib in all)
            {
                result[index++] = new AttributeDataMap(attrib);
            }
            return(result);
#else
#if WINRT
            Attribute[] all = System.Linq.Enumerable.ToArray(type.GetTypeInfo().GetCustomAttributes(inherit));
#else
            object[] all = type.GetCustomAttributes(inherit);
#endif
            AttributeMap[] result = new AttributeMap[all.Length];
            for (int i = 0; i < all.Length; i++)
            {
                result[i] = new ReflectionAttributeMap((Attribute)all[i]);
            }
            return(result);
#endif
        }
コード例 #6
0
ファイル: AttributeMap.cs プロジェクト: zwinter/ET
        public static AttributeMap[] Create(TypeModel model, Assembly assembly)
        {
#if FEAT_IKVM
            const bool inherit = false;
            System.Collections.Generic.IList <CustomAttributeData> all = assembly.__GetCustomAttributes(model.MapType(typeof(Attribute)), inherit);
            AttributeMap[] result = new AttributeMap[all.Count];
            int            index  = 0;
            foreach (CustomAttributeData attrib in all)
            {
                result[index++] = new AttributeDataMap(attrib);
            }
            return(result);
#else
#if WINRT || COREFX
            Attribute[] all = System.Linq.Enumerable.ToArray(assembly.GetCustomAttributes());
#else
            const bool inherit = false;
            //object[] all = assembly.GetCustomAttributes(inherit);
            // 过滤掉null的Attribute
            object[] all = assembly.GetCustomAttributes(inherit).Where((x) => x != null).ToArray();
#endif
            AttributeMap[] result = new AttributeMap[all.Length];
            for (int i = 0; i < all.Length; i++)
            {
                result[i] = new ReflectionAttributeMap((Attribute)all[i]);
            }
            return(result);
#endif
        }
コード例 #7
0
 public static AttributeMap[] Create(TypeModel model, Assembly assembly)
 {
     object[]       customAttributes = assembly.GetCustomAttributes(false);
     AttributeMap[] array            = new AttributeMap[customAttributes.Length];
     for (int i = 0; i < customAttributes.Length; i++)
     {
         array[i] = new ReflectionAttributeMap((Attribute)customAttributes[i]);
     }
     return(array);
 }
コード例 #8
0
 public static AttributeMap[] Create(TypeModel model, MemberInfo member, bool inherit)
 {
     object[]       customAttributes = member.GetCustomAttributes(inherit);
     AttributeMap[] array            = new AttributeMap[customAttributes.Length];
     for (int i = 0; i < customAttributes.Length; i++)
     {
         array[i] = new ReflectionAttributeMap((Attribute)customAttributes[i]);
     }
     return(array);
 }
コード例 #9
0
 public static AttributeMap[] Create(TypeModel model, Type type, bool inherit)
 {
     object[]       customAttributes = type.GetCustomAttributes(inherit);
     AttributeMap[] mapArray         = new AttributeMap[customAttributes.Length];
     for (int i = 0; i < customAttributes.Length; i++)
     {
         mapArray[i] = new ReflectionAttributeMap((Attribute)customAttributes[i]);
     }
     return(mapArray);
 }
コード例 #10
0
 public static AttributeMap[] Create(TypeModel model, MemberInfo member, bool inherit)
 {
     object[]       all    = member.GetCustomAttributes(inherit);
     AttributeMap[] result = new AttributeMap[all.Length];
     for (int i = 0; i < all.Length; i++)
     {
         result[i] = new ReflectionAttributeMap((Attribute)all[i]);
     }
     return(result);
 }
コード例 #11
0
        public static AttributeMap[] Create(TypeModel model, Assembly assembly)
        {
            object[] all = assembly.GetCustomAttributes(inherit: false);

            AttributeMap[] result = new AttributeMap[all.Length];
            for (int i = 0; i < all.Length; i++)
            {
                result[i] = new ReflectionAttributeMap((Attribute)all[i]);
            }
            return(result);
        }
コード例 #12
0
        public static AttributeMap[] Create(TypeModel model, MemberInfo member, bool inherit)
        {
#if COREFX || PROFILE259
            Attribute[] all = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.OfType <Attribute>(member.GetCustomAttributes(inherit)));
#else
            object[] all = member.GetCustomAttributes(inherit);
#endif
            AttributeMap[] result = new AttributeMap[all.Length];
            for (int i = 0; i < all.Length; i++)
            {
                result[i] = new ReflectionAttributeMap((Attribute)all[i]);
            }
            return(result);
        }
コード例 #13
0
        public static AttributeMap[] Create(TypeModel model, Assembly assembly)
        {
#if COREFX || PROFILE259
            Attribute[] all = System.Linq.Enumerable.ToArray(assembly.GetCustomAttributes());
#else
            const bool inherit = false;
            object[]   all     = assembly.GetCustomAttributes(inherit);
#endif
            AttributeMap[] result = new AttributeMap[all.Length];
            for (int i = 0; i < all.Length; i++)
            {
                result[i] = new ReflectionAttributeMap((Attribute)all[i]);
            }
            return(result);
        }
コード例 #14
0
ファイル: AttributeMap.cs プロジェクト: 289997171/vicking
 public static AttributeMap[] Create(TypeModel model, Assembly assembly)
 {
     #if FEAT_IKVM
     const bool inherit = false;
     System.Collections.Generic.IList<CustomAttributeData> all = assembly.__GetCustomAttributes(model.MapType(typeof(Attribute)), inherit);
     AttributeMap[] result = new AttributeMap[all.Count];
     int index = 0;
     foreach (CustomAttributeData attrib in all)
     {
         result[index++] = new AttributeDataMap(attrib);
     }
     return result;
     #else
     #if WINRT
     Attribute[] all = System.Linq.Enumerable.ToArray(assembly.GetCustomAttributes());
     #else
     const bool inherit = false;
     var all = assembly.GetCustomAttributes(inherit);
     #endif
     var result = new AttributeMap[all.Length];
     for (var i = 0; i < all.Length; i++)
     {
         result[i] = new ReflectionAttributeMap((Attribute) all[i]);
     }
     return result;
     #endif
 }