File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed
WebApiClientCore.Extensions.NewtonsoftJson/Attributes Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ namespace App.Clients
1515 [ LoggingFilter ]
1616 [ OAuthToken ]
1717 [ HttpHost ( "http://localhost:6000/" ) ]
18+ [ JsonNetReturn ]
1819 public interface IUserApi : IHttpApi
1920 {
2021 [ HttpGet ( "api/users/{account}" ) ]
Original file line number Diff line number Diff line change @@ -35,22 +35,19 @@ public JsonNetReturnAttribute(double acceptQuality)
3535 /// <returns></returns>
3636 public override async Task SetResultAsync ( ApiResponseContext context )
3737 {
38- var response = context . HttpContext . ResponseMessage ;
39- if ( response == null || response . Content == null )
38+ var content = context . HttpContext . ResponseMessage ? . Content ;
39+ if ( content == null )
4040 {
4141 return ;
4242 }
4343
44- if ( context . ApiAction . Return . DataType . IsRawType == false )
45- {
46- var json = await response . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
47- var resultType = context . ApiAction . Return . DataType . Type ;
44+ var json = await content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
45+ var resultType = context . ApiAction . Return . DataType . Type ;
4846
49- var name = context . HttpContext . OptionsName ;
50- var options = context . HttpContext . ServiceProvider . GetService < IOptionsMonitor < JsonNetSerializerOptions > > ( ) . Get ( name ) ;
47+ var name = context . HttpContext . OptionsName ;
48+ var options = context . HttpContext . ServiceProvider . GetService < IOptionsMonitor < JsonNetSerializerOptions > > ( ) . Get ( name ) ;
5149
52- context . Result = JsonConvert . DeserializeObject ( json , resultType , options . JsonDeserializeOptions ) ;
53- }
50+ context . Result = JsonConvert . DeserializeObject ( json , resultType , options . JsonDeserializeOptions ) ;
5451 }
5552 }
5653}
You can’t perform that action at this time.
0 commit comments