@@ -632,8 +632,19 @@ public static PropertyInfo[] GetPublicProperties(this Type type)
632632 }
633633
634634 public const string DataMember = "DataMemberAttribute" ;
635- public const string IgnoreDataMember = "IgnoreDataMemberAttribute" ;
636- public const string JsonIgnoreMembar = "JsonIgnoreAttribute" ;
635+
636+ internal static string [ ] IgnoreAttributesNamed = new [ ] {
637+ "IgnoreDataMemberAttribute" ,
638+ "JsonIgnoreAttribute"
639+ } ;
640+
641+ internal static void Reset ( )
642+ {
643+ IgnoreAttributesNamed = new [ ] {
644+ "IgnoreDataMemberAttribute" ,
645+ "JsonIgnoreAttribute"
646+ } ;
647+ }
637648
638649 public static PropertyInfo [ ] GetSerializableProperties ( this Type type )
639650 {
@@ -648,12 +659,11 @@ public static PropertyInfo[] GetSerializableProperties(this Type type)
648659
649660 // else return those properties that are not decorated with IgnoreDataMember
650661 return publicReadableProperties
651- . Where ( prop => prop . AllAttributes ( ) . All ( attr =>
652- {
662+ . Where ( prop => prop . AllAttributes ( ) . All ( attr => {
653663 var name = attr . GetType ( ) . Name ;
654- return name != IgnoreDataMember && name != JsonIgnoreMembar ;
655- } ) )
656- . Where ( prop => ! JsConfig . ExcludeTypes . Contains ( prop . PropertyType ) )
664+ return ! IgnoreAttributesNamed . Contains ( name ) ;
665+ } ) )
666+ . Where ( prop => ! JsConfig . ExcludeTypes . Contains ( prop . PropertyType ) )
657667 . ToArray ( ) ;
658668 }
659669
@@ -672,7 +682,8 @@ public static FieldInfo[] GetSerializableFields(this Type type)
672682
673683 // else return those properties that are not decorated with IgnoreDataMember
674684 return publicFields
675- . Where ( prop => prop . AllAttributes ( ) . All ( attr => attr . GetType ( ) . Name != IgnoreDataMember ) )
685+ . Where ( prop => prop . AllAttributes ( )
686+ . All ( attr => ! IgnoreAttributesNamed . Contains ( attr . GetType ( ) . Name ) ) )
676687 . Where ( prop => ! JsConfig . ExcludeTypes . Contains ( prop . FieldType ) )
677688 . ToArray ( ) ;
678689 }
@@ -1299,7 +1310,7 @@ public static TAttribute FirstAttribute<TAttribute>(this MemberInfo memberInfo)
12991310 {
13001311 return memberInfo . AllAttributes < TAttribute > ( ) . FirstOrDefault ( ) ;
13011312 }
1302-
1313+
13031314 public static TAttribute FirstAttribute < TAttribute > ( this ParameterInfo paramInfo )
13041315 {
13051316 return paramInfo . AllAttributes < TAttribute > ( ) . FirstOrDefault ( ) ;
0 commit comments