@@ -12,20 +12,29 @@ internal abstract class ApiClientBase(HttpClient httpClient, ILogger<ICgScriptAp
12
12
{
13
13
public async Task < ScriptResult < TR > > Execute < TP , TR > ( string scriptName , TP parameter , JsonTypeInfo < TP > callJsonTypeInfo , JsonTypeInfo < TR > resultJsonTypeInfo , CancellationToken cancellationToken )
14
14
{
15
- using var activity = CgScriptTelemetry . Source . StartActivity ( scriptName ) ;
16
- return await ParseResponse ( await httpClient . PostAsync ( await GetPath ( scriptName ) , await GetJsonContent ( scriptName , parameter , callJsonTypeInfo ) , cancellationToken ) . ConfigureAwait ( false ) , resultJsonTypeInfo , cancellationToken ) ;
15
+ using var activity = CgScriptTelemetry . Source . StartActivity ( scriptName ) ;
16
+ var path = await GetPath ( scriptName ) ;
17
+ var jsonContent = await GetJsonContent ( scriptName , parameter , callJsonTypeInfo ) ;
18
+ var httpResponseMessage = await httpClient . PostAsync ( path , jsonContent , cancellationToken ) . ConfigureAwait ( false ) ;
19
+ return await ParseResponse ( httpResponseMessage , resultJsonTypeInfo , cancellationToken ) ;
17
20
}
18
21
19
22
public async Task < ScriptResult < TR > > ExecuteArray < TP , TR > ( string scriptName , TP parameter , JsonTypeInfo < TP > callJsonTypeInfo , JsonTypeInfo < TR > resultJsonTypeInfo , CancellationToken cancellationToken )
20
23
{
21
- using var activity = CgScriptTelemetry . Source . StartActivity ( scriptName ) ;
22
- return await ParseResponse ( await httpClient . PostAsync ( await GetPath ( scriptName , "?expandParameters=true" ) , await GetJsonContent ( scriptName , parameter , callJsonTypeInfo ) , cancellationToken ) . ConfigureAwait ( false ) , resultJsonTypeInfo , cancellationToken ) ;
24
+ using var activity = CgScriptTelemetry . Source . StartActivity ( scriptName ) ;
25
+ var path = await GetPath ( scriptName , "?expandParameters=true" ) ;
26
+ var jsonContent = await GetJsonContent ( scriptName , parameter , callJsonTypeInfo ) ;
27
+ var httpResponseMessage = await httpClient . PostAsync ( path , jsonContent , cancellationToken ) . ConfigureAwait ( false ) ;
28
+ return await ParseResponse ( httpResponseMessage , resultJsonTypeInfo , cancellationToken ) ;
23
29
}
24
30
25
31
public async Task < ScriptResult < TR > > Execute < TR > ( string scriptName , JsonTypeInfo < TR > resultJsonTypeInfo , CancellationToken cancellationToken = default )
26
32
{
27
- using var activity = CgScriptTelemetry . Source . StartActivity ( scriptName ) ;
28
- return await ParseResponse ( await httpClient . PostAsync ( await GetPath ( scriptName , "?expandParameters=true" ) , await GetJsonContent ( scriptName , null , ( JsonTypeInfo < object > ) null ! ) , cancellationToken ) . ConfigureAwait ( false ) , resultJsonTypeInfo , cancellationToken ) ;
33
+ using var activity = CgScriptTelemetry . Source . StartActivity ( scriptName ) ;
34
+ var path = await GetPath ( scriptName , "?expandParameters=true" ) ;
35
+ var jsonContent = await GetJsonContent ( scriptName , null , ( JsonTypeInfo < object > ) null ! ) ;
36
+ var httpResponseMessage = await httpClient . PostAsync ( path , jsonContent , cancellationToken ) . ConfigureAwait ( false ) ;
37
+ return await ParseResponse ( httpResponseMessage , resultJsonTypeInfo , cancellationToken ) ;
29
38
}
30
39
31
40
private async Task < ScriptResult < TR > > ParseResponse < TR > ( HttpResponseMessage call , JsonTypeInfo < TR > resultJsonTypeInfo , CancellationToken cancellationToken )
@@ -67,22 +76,31 @@ public async Task<ScriptResult<TR>> Execute<TP, TR>(string scriptName, TP parame
67
76
[ RequiresUnreferencedCode ( "JSON" ) ]
68
77
public async Task < ScriptResult < TR > > ExecuteArray < TP , TR > ( string scriptName , TP parameter , JsonSerializerOptions ? options , CancellationToken cancellationToken = default )
69
78
{
70
- using var activity = CgScriptTelemetry . Source . StartActivity ( scriptName ) ;
71
- return await ParseResponse < TR > ( await httpClient . PostAsync ( await GetPath ( scriptName , "?expandParameters=true" ) , await GetJsonContent ( scriptName , parameter , options ) , cancellationToken ) . ConfigureAwait ( false ) , options , cancellationToken ) ;
79
+ using var activity = CgScriptTelemetry . Source . StartActivity ( scriptName ) ;
80
+ var path = await GetPath ( scriptName , "?expandParameters=true" ) ;
81
+ var jsonContent = await GetJsonContent ( scriptName , parameter , options ) ;
82
+ var httpResponseMessage = await httpClient . PostAsync ( path , jsonContent , cancellationToken ) . ConfigureAwait ( false ) ;
83
+ return await ParseResponse < TR > ( httpResponseMessage , options , cancellationToken ) ;
72
84
}
73
85
74
86
[ RequiresUnreferencedCode ( "JSON" ) ]
75
87
public async Task < ScriptResult < TR > > Execute < TR > ( string scriptName , IReadOnlyCollection < object > parameters , JsonSerializerOptions ? options = null , CancellationToken cancellationToken = default )
76
88
{
77
- using var activity = CgScriptTelemetry . Source . StartActivity ( scriptName ) ;
78
- return await ParseResponse < TR > ( await httpClient . PostAsync ( await GetPath ( scriptName , "?expandParameters=true" ) , await GetJsonContent ( scriptName , parameters , options ) , cancellationToken ) . ConfigureAwait ( false ) , options , cancellationToken ) ;
89
+ using var activity = CgScriptTelemetry . Source . StartActivity ( scriptName ) ;
90
+ var path = await GetPath ( scriptName , "?expandParameters=true" ) ;
91
+ var jsonContent = await GetJsonContent ( scriptName , parameters , options ) ;
92
+ var httpResponseMessage = await httpClient . PostAsync ( path , jsonContent , cancellationToken ) . ConfigureAwait ( false ) ;
93
+ return await ParseResponse < TR > ( httpResponseMessage , options , cancellationToken ) ;
79
94
}
80
95
81
96
[ RequiresUnreferencedCode ( "JSON" ) ]
82
97
public async Task < ScriptResult < TR > > Execute < TR > ( string scriptName , JsonSerializerOptions ? options = null , CancellationToken cancellationToken = default )
83
98
{
84
- using var activity = CgScriptTelemetry . Source . StartActivity ( scriptName ) ;
85
- return await ParseResponse < TR > ( await httpClient . PostAsync ( await GetPath ( scriptName ) , await GetJsonContent ( scriptName , null , ( JsonTypeInfo < object > ) null ! ) , cancellationToken ) . ConfigureAwait ( false ) , options , cancellationToken ) ;
99
+ using var activity = CgScriptTelemetry . Source . StartActivity ( scriptName ) ;
100
+ var path = await GetPath ( scriptName ) ;
101
+ var jsonContent = await GetJsonContent ( scriptName , null , ( JsonTypeInfo < object > ) null ! ) ;
102
+ var httpResponseMessage = await httpClient . PostAsync ( path , jsonContent , cancellationToken ) . ConfigureAwait ( false ) ;
103
+ return await ParseResponse < TR > ( httpResponseMessage , options , cancellationToken ) ;
86
104
}
87
105
88
106
[ RequiresUnreferencedCode ( "JSON" ) ]
0 commit comments