File tree Expand file tree Collapse file tree 5 files changed +21
-50
lines changed Expand file tree Collapse file tree 5 files changed +21
-50
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,6 @@ public static void AddJsonApiInternals(
129
129
services . AddScoped < IJsonApiWriter , JsonApiWriter > ( ) ;
130
130
services . AddScoped < IJsonApiDeSerializer , JsonApiDeSerializer > ( ) ;
131
131
services . AddScoped < IJsonApiReader , JsonApiReader > ( ) ;
132
- services . AddScoped < IJsonApiOperationsReader , JsonApiOperationsReader > ( ) ;
133
132
services . AddScoped < IGenericProcessorFactory , GenericProcessorFactory > ( ) ;
134
133
services . AddScoped ( typeof ( GenericProcessor < > ) ) ;
135
134
services . AddScoped ( typeof ( GenericProcessor < , > ) ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ public Task<InputFormatterResult> ReadAsync(InputFormatterContext context)
36
36
try
37
37
{
38
38
var body = GetRequestBody ( context . HttpContext . Request . Body ) ;
39
+
39
40
var model = _jsonApiContext . IsRelationshipPath ?
40
41
_deSerializer . DeserializeRelationship ( body ) :
41
42
_deSerializer . Deserialize ( body ) ;
@@ -67,4 +68,4 @@ private string GetRequestBody(Stream body)
67
68
}
68
69
}
69
70
}
70
- }
71
+ }
Original file line number Diff line number Diff line change 5
5
using JsonApiDotNetCore . Internal ;
6
6
using JsonApiDotNetCore . Internal . Generics ;
7
7
using JsonApiDotNetCore . Models ;
8
+ using JsonApiDotNetCore . Models . Operations ;
8
9
using JsonApiDotNetCore . Services ;
9
10
using Newtonsoft . Json ;
10
11
using Newtonsoft . Json . Linq ;
@@ -28,7 +29,20 @@ public object Deserialize(string requestBody)
28
29
{
29
30
try
30
31
{
31
- var document = JsonConvert . DeserializeObject < Document > ( requestBody ) ;
32
+ // TODO: determine whether or not the token should be re-used rather than performing full
33
+ // deserialization again from the string
34
+ var bodyJToken = JToken . Parse ( requestBody ) ;
35
+ if ( bodyJToken . SelectToken ( "operations" ) != null )
36
+ {
37
+ var operations = JsonConvert . DeserializeObject < OperationsDocument > ( requestBody ) ;
38
+ if ( operations == null )
39
+ throw new JsonApiException ( 400 , "Failed to deserialize operations request." ) ;
40
+
41
+ return operations ;
42
+ }
43
+
44
+ var document = bodyJToken . ToObject < Document > ( ) ;
45
+
32
46
_jsonApiContext . DocumentMeta = document . Meta ;
33
47
var entity = DocumentToObject ( document . Data ) ;
34
48
return entity ;
@@ -63,7 +77,7 @@ public List<TEntity> DeserializeList<TEntity>(string requestBody)
63
77
try
64
78
{
65
79
var documents = JsonConvert . DeserializeObject < Documents > ( requestBody ) ;
66
-
80
+
67
81
var deserializedList = new List < TEntity > ( ) ;
68
82
foreach ( var data in documents . Data )
69
83
{
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Threading . Tasks ;
4
+ using JsonApiDotNetCore . Data ;
4
5
using JsonApiDotNetCore . Internal ;
5
- using JsonApiDotNetCore . Models ;
6
6
using JsonApiDotNetCore . Models . Operations ;
7
7
using JsonApiDotNetCore . Models . Pointers ;
8
8
using Microsoft . EntityFrameworkCore ;
@@ -21,10 +21,10 @@ public class OperationsProcessor : IOperationsProcessor
21
21
22
22
public OperationsProcessor (
23
23
IOperationProcessorResolver processorResolver ,
24
- DbContext dbContext )
24
+ IDbContextResolver dbContextResolver )
25
25
{
26
26
_processorResolver = processorResolver ;
27
- _dbContext = dbContext ;
27
+ _dbContext = dbContextResolver . GetContext ( ) ;
28
28
}
29
29
30
30
public async Task < List < Operation > > ProcessAsync ( List < Operation > inputOps )
You can’t perform that action at this time.
0 commit comments