@@ -538,6 +538,8 @@ public static DeserializationErrorDelegate OnDeserializationError
538538
539539 public static HashSet < Type > TreatValueAsRefTypes = new HashSet < Type > ( ) ;
540540
541+ public static HashSet < Type > TreatAsAbstractType = new HashSet < Type > ( ) ;
542+
541543 private static bool ? sPreferInterfaces ;
542544 /// <summary>
543545 /// If set to true, Interface types will be prefered over concrete types when serializing.
@@ -713,6 +715,7 @@ public static void Reset()
713715 HasSerializeFn = new HashSet < Type > ( ) ;
714716 HasIncludeDefaultValue = new HashSet < Type > ( ) ;
715717 TreatValueAsRefTypes = new HashSet < Type > { typeof ( KeyValuePair < , > ) } ;
718+ TreatAsAbstractType = new HashSet < Type > ( ) ;
716719 sPropertyConvention = null ;
717720 sExcludePropertyReferences = null ;
718721 sExcludeTypes = new HashSet < Type > { typeof ( Stream ) } ;
@@ -769,6 +772,23 @@ public class JsConfig<T>
769772 /// </summary>
770773 public static bool ? ExcludeTypeInfo = null ;
771774
775+ /// <summary>
776+ /// Treat non-abstract type like an abstract type
777+ /// </summary>
778+ public static bool TreatAsAbstractType
779+ {
780+ get { return JsConfig . TreatAsAbstractType . Contains ( typeof ( T ) ) ; }
781+ set
782+ {
783+ if ( value )
784+ JsConfig . TreatAsAbstractType . Add ( typeof ( T ) ) ;
785+ else
786+ JsConfig . TreatAsAbstractType . Remove ( typeof ( T ) ) ;
787+
788+ ClearFnCaches ( ) ;
789+ }
790+ }
791+
772792 /// <summary>
773793 /// <see langword="true"/> if the <see cref="ITypeSerializer"/> is configured
774794 /// to take advantage of <see cref="CLSCompliantAttribute"/> specification,
0 commit comments