@@ -15,7 +15,7 @@ public class LegacyDatatablesMediaTypeFormatter : JsonMediaTypeFormatter
1515 public static readonly string ApplicationDatatablesMediaType = "application/datatables" ;
1616 public static readonly string TextDatatablesMediaType = "text/datatables" ;
1717
18- public LegacyDatatablesMediaTypeFormatter ( )
18+ public LegacyDatatablesMediaTypeFormatter ( )
1919 : base ( )
2020 {
2121 this . SupportedMediaTypes . Clear ( ) ;
@@ -25,10 +25,10 @@ public LegacyDatatablesMediaTypeFormatter()
2525 this . MediaTypeMappings . Clear ( ) ;
2626 this . AddRequestHeaderMapping ( "x-requested-with" , "XMLHttpRequest" , StringComparison . OrdinalIgnoreCase , true , ApplicationDatatablesMediaType ) ;
2727
28- this . SerializerSettings . Converters . Add ( new LegacyFilterRequestConverter ( ) ) ;
29- this . SerializerSettings . Converters . Add ( new LegacyPageResponseConverter ( ) ) ;
28+ this . SerializerSettings . Converters . Add ( new LegacyFilterRequestConverter ( ) ) ;
29+ this . SerializerSettings . Converters . Add ( new LegacyPageResponseConverter ( ) ) ;
3030
31- this . SerializerSettings . Formatting = Formatting . Indented ;
31+ this . SerializerSettings . Formatting = Formatting . Indented ;
3232 }
3333
3434 public new static MediaTypeHeaderValue DefaultMediaType
@@ -46,12 +46,20 @@ public override void SetDefaultContentHeaders(Type type, HttpContentHeaders head
4646
4747 public override bool CanReadType ( Type type )
4848 {
49- return true ;
49+ foreach ( var converter in this . SerializerSettings . Converters )
50+ if ( converter . CanConvert ( type ) )
51+ return true ;
52+
53+ return false ;
5054 }
5155
5256 public override bool CanWriteType ( Type type )
5357 {
54- return true ;
58+ foreach ( var converter in this . SerializerSettings . Converters )
59+ if ( converter . CanConvert ( type ) )
60+ return true ;
61+
62+ return false ;
5563 }
5664
5765 public override Task < object > ReadFromStreamAsync ( Type type , Stream readStream , HttpContent content , IFormatterLogger formatterLogger )
0 commit comments