@@ -552,11 +552,11 @@ public static PropertyInfo[] GetSerializableProperties(this Type type)
552
552
? publicReadableProperties . Where ( attr =>
553
553
attr . IsDefined ( typeof ( DataMemberAttribute ) , false ) ) . ToArray ( )
554
554
: publicReadableProperties . Where ( attr =>
555
- attr . AllAttributes ( false ) . Any ( x => x . GetType ( ) . Name == DataMember ) ) . ToArray ( ) ;
555
+ attr . AllAttributes ( ) . Any ( x => x . GetType ( ) . Name == DataMember ) ) . ToArray ( ) ;
556
556
}
557
557
558
558
// else return those properties that are not decorated with IgnoreDataMember
559
- return publicReadableProperties . Where ( prop => prop . AllAttributes ( false ) . All ( attr => attr . GetType ( ) . Name != IgnoreDataMember ) ) . ToArray ( ) ;
559
+ return publicReadableProperties . Where ( prop => prop . AllAttributes ( ) . All ( attr => attr . GetType ( ) . Name != IgnoreDataMember ) ) . ToArray ( ) ;
560
560
}
561
561
562
562
public static FieldInfo [ ] GetSerializableFields ( this Type type )
@@ -568,7 +568,7 @@ public static FieldInfo[] GetSerializableFields(this Type type)
568
568
var publicFields = type . GetPublicFields ( ) ;
569
569
570
570
// else return those properties that are not decorated with IgnoreDataMember
571
- return publicFields . Where ( prop => prop . AllAttributes ( false ) . All ( attr => attr . GetType ( ) . Name != IgnoreDataMember ) ) . ToArray ( ) ;
571
+ return publicFields . Where ( prop => prop . AllAttributes ( ) . All ( attr => attr . GetType ( ) . Name != IgnoreDataMember ) ) . ToArray ( ) ;
572
572
}
573
573
574
574
#if ! SILVERLIGHT && ! MONOTOUCH
@@ -589,7 +589,7 @@ public static DataContractAttribute GetDataContract(this Type type)
589
589
590
590
public static DataMemberAttribute GetDataMember ( this PropertyInfo pi )
591
591
{
592
- var dataMember = pi . AllAttributes ( typeof ( DataMemberAttribute ) , false )
592
+ var dataMember = pi . AllAttributes ( typeof ( DataMemberAttribute ) )
593
593
. FirstOrDefault ( ) as DataMemberAttribute ;
594
594
595
595
#if ! SILVERLIGHT && ! MONOTOUCH && ! XBOX
@@ -601,7 +601,7 @@ public static DataMemberAttribute GetDataMember(this PropertyInfo pi)
601
601
602
602
public static DataMemberAttribute GetDataMember ( this FieldInfo pi )
603
603
{
604
- var dataMember = pi . AllAttributes ( typeof ( DataMemberAttribute ) , false )
604
+ var dataMember = pi . AllAttributes ( typeof ( DataMemberAttribute ) )
605
605
. FirstOrDefault ( ) as DataMemberAttribute ;
606
606
607
607
#if ! SILVERLIGHT && ! MONOTOUCH && ! XBOX
@@ -858,33 +858,33 @@ public static MemberInfo[] GetAllPublicMembers(this Type type)
858
858
#endif
859
859
}
860
860
861
- public static bool HasAttribute < T > ( this Type type , bool inherit = true )
861
+ public static bool HasAttribute < T > ( this Type type )
862
862
{
863
- return type . AllAttributes ( inherit ) . Any ( x => x . GetType ( ) == typeof ( T ) ) ;
863
+ return type . AllAttributes ( ) . Any ( x => x . GetType ( ) == typeof ( T ) ) ;
864
864
}
865
865
866
- public static bool HasAttributeNamed ( this Type type , string name , bool inherit = true )
866
+ public static bool HasAttributeNamed ( this Type type , string name )
867
867
{
868
868
var normalizedAttr = name . Replace ( "Attribute" , "" ) . ToLower ( ) ;
869
- return type . AllAttributes ( inherit ) . Any ( x => x . GetType ( ) . Name . Replace ( "Attribute" , "" ) . ToLower ( ) == normalizedAttr ) ;
869
+ return type . AllAttributes ( ) . Any ( x => x . GetType ( ) . Name . Replace ( "Attribute" , "" ) . ToLower ( ) == normalizedAttr ) ;
870
870
}
871
871
872
- public static bool HasAttributeNamed ( this PropertyInfo pi , string name , bool inherit = true )
872
+ public static bool HasAttributeNamed ( this PropertyInfo pi , string name )
873
873
{
874
874
var normalizedAttr = name . Replace ( "Attribute" , "" ) . ToLower ( ) ;
875
- return pi . AllAttributes ( inherit ) . Any ( x => x . GetType ( ) . Name . Replace ( "Attribute" , "" ) . ToLower ( ) == normalizedAttr ) ;
875
+ return pi . AllAttributes ( ) . Any ( x => x . GetType ( ) . Name . Replace ( "Attribute" , "" ) . ToLower ( ) == normalizedAttr ) ;
876
876
}
877
877
878
- public static bool HasAttributeNamed ( this FieldInfo fi , string name , bool inherit = true )
878
+ public static bool HasAttributeNamed ( this FieldInfo fi , string name )
879
879
{
880
880
var normalizedAttr = name . Replace ( "Attribute" , "" ) . ToLower ( ) ;
881
- return fi . AllAttributes ( inherit ) . Any ( x => x . GetType ( ) . Name . Replace ( "Attribute" , "" ) . ToLower ( ) == normalizedAttr ) ;
881
+ return fi . AllAttributes ( ) . Any ( x => x . GetType ( ) . Name . Replace ( "Attribute" , "" ) . ToLower ( ) == normalizedAttr ) ;
882
882
}
883
883
884
- public static bool HasAttributeNamed ( this MemberInfo mi , string name , bool inherit = true )
884
+ public static bool HasAttributeNamed ( this MemberInfo mi , string name )
885
885
{
886
886
var normalizedAttr = name . Replace ( "Attribute" , "" ) . ToLower ( ) ;
887
- return mi . AllAttributes ( inherit ) . Any ( x => x . GetType ( ) . Name . Replace ( "Attribute" , "" ) . ToLower ( ) == normalizedAttr ) ;
887
+ return mi . AllAttributes ( ) . Any ( x => x . GetType ( ) . Name . Replace ( "Attribute" , "" ) . ToLower ( ) == normalizedAttr ) ;
888
888
}
889
889
890
890
const string DataContract = "DataContractAttribute" ;
@@ -929,75 +929,77 @@ public static PropertyInfo[] AllProperties(this Type type)
929
929
#endif
930
930
}
931
931
932
- public static object [ ] AllAttributes ( this PropertyInfo propertyInfo , bool inherit = true )
932
+ public static object [ ] AllAttributes ( this PropertyInfo propertyInfo )
933
933
{
934
934
#if NETFX_CORE
935
- return propertyInfo . GetCustomAttributes ( inherit ) . ToArray ( ) ;
935
+ return propertyInfo . GetCustomAttributes ( true ) . ToArray ( ) ;
936
936
#else
937
- return propertyInfo . GetCustomAttributes ( inherit ) ;
937
+ return propertyInfo . GetCustomAttributes ( true ) ;
938
938
#endif
939
939
}
940
940
941
- public static object [ ] AllAttributes ( this PropertyInfo propertyInfo , Type attrType , bool inherit = true )
941
+ public static object [ ] AllAttributes ( this PropertyInfo propertyInfo , Type attrType )
942
942
{
943
943
#if NETFX_CORE
944
- return propertyInfo . GetCustomAttributes ( inherit ) . Where ( x => x . GetType ( ) == attrType ) . ToArray ( ) ;
944
+ return propertyInfo . GetCustomAttributes ( true ) . Where ( x => x . GetType ( ) == attrType ) . ToArray ( ) ;
945
945
#else
946
- return propertyInfo . GetCustomAttributes ( attrType , inherit ) ;
946
+ return propertyInfo . GetCustomAttributes ( attrType , true ) ;
947
947
#endif
948
948
}
949
949
950
- public static object [ ] AllAttributes ( this FieldInfo fieldInfo , bool inherit = true )
950
+ public static object [ ] AllAttributes ( this FieldInfo fieldInfo )
951
951
{
952
952
#if NETFX_CORE
953
- return fieldInfo . GetCustomAttributes ( inherit ) . ToArray ( ) ;
953
+ return fieldInfo . GetCustomAttributes ( true ) . ToArray ( ) ;
954
954
#else
955
- return fieldInfo . GetCustomAttributes ( inherit ) ;
955
+ return fieldInfo . GetCustomAttributes ( true ) ;
956
956
#endif
957
957
}
958
958
959
- public static object [ ] AllAttributes ( this MemberInfo memberInfo , bool inherit = true )
959
+ public static object [ ] AllAttributes ( this MemberInfo memberInfo )
960
960
{
961
961
#if NETFX_CORE
962
- return memberInfo . GetCustomAttributes ( inherit ) . ToArray ( ) ;
962
+ return memberInfo . GetCustomAttributes ( true ) . ToArray ( ) ;
963
963
#else
964
- return memberInfo . GetCustomAttributes ( inherit ) ;
964
+ return memberInfo . GetCustomAttributes ( true ) ;
965
965
#endif
966
966
}
967
967
968
- public static object [ ] AllAttributes ( this MemberInfo meberInfo , Type attrType , bool inherit = true )
968
+ public static object [ ] AllAttributes ( this MemberInfo meberInfo , Type attrType )
969
969
{
970
970
#if NETFX_CORE
971
- return meberInfo . GetCustomAttributes ( inherit ) . Where ( x => x . GetType ( ) == attrType ) . ToArray ( ) ;
971
+ return meberInfo . GetCustomAttributes ( true ) . Where ( x => x . GetType ( ) == attrType ) . ToArray ( ) ;
972
972
#else
973
- return meberInfo . GetCustomAttributes ( attrType , inherit ) ;
973
+ return meberInfo . GetCustomAttributes ( attrType , true ) ;
974
974
#endif
975
975
}
976
976
977
- public static object [ ] AllAttributes ( this FieldInfo fieldInfo , Type attrType , bool inherit = true )
977
+ public static object [ ] AllAttributes ( this FieldInfo fieldInfo , Type attrType )
978
978
{
979
979
#if NETFX_CORE
980
- return fieldInfo . GetCustomAttributes ( inherit ) . Where ( x => x . GetType ( ) == attrType ) . ToArray ( ) ;
980
+ return fieldInfo . GetCustomAttributes ( true ) . Where ( x => x . GetType ( ) == attrType ) . ToArray ( ) ;
981
981
#else
982
- return fieldInfo . GetCustomAttributes ( attrType , inherit ) ;
982
+ return fieldInfo . GetCustomAttributes ( attrType , true ) ;
983
983
#endif
984
984
}
985
985
986
- public static object [ ] AllAttributes ( this Type type , bool inherit = true )
986
+ public static object [ ] AllAttributes ( this Type type )
987
987
{
988
988
#if NETFX_CORE
989
- return type . GetTypeInfo ( ) . GetCustomAttributes ( inherit ) . ToArray ( ) ;
989
+ return type . GetTypeInfo ( ) . GetCustomAttributes ( true ) . ToArray ( ) ;
990
+ #elif SILVERLIGHT
991
+ return type . GetCustomAttributes ( true ) ;
990
992
#else
991
- return type . GetCustomAttributes ( inherit ) ;
993
+ return TypeDescriptor . GetAttributes ( type ) . Cast < object > ( ) . ToArray ( ) ;
992
994
#endif
993
995
}
994
996
995
- public static object [ ] AllAttributes ( this Type type , Type attrType , bool inherit = true )
997
+ public static object [ ] AllAttributes ( this Type type , Type attrType )
996
998
{
997
999
#if NETFX_CORE
998
- return type . GetTypeInfo ( ) . GetCustomAttributes ( inherit ) . Where ( x => x . GetType ( ) == attrType ) . ToArray ( ) ;
1000
+ return type . GetTypeInfo ( ) . GetCustomAttributes ( true ) . Where ( x => x . GetType ( ) == attrType ) . ToArray ( ) ;
999
1001
#elif SILVERLIGHT
1000
- return type . GetCustomAttributes ( attrType , inherit ) ;
1002
+ return type . GetCustomAttributes ( attrType , true ) ;
1001
1003
#else
1002
1004
return TypeDescriptor . GetAttributes ( type ) . OfType < Attribute > ( ) . ToArray ( ) ;
1003
1005
#endif
0 commit comments