@@ -12,20 +12,29 @@ internal abstract class ApiClientBase(HttpClient httpClient, ILogger<ICgScriptAp
1212{
1313 public async Task < ScriptResult < TR > > Execute < TP , TR > ( string scriptName , TP parameter , JsonTypeInfo < TP > callJsonTypeInfo , JsonTypeInfo < TR > resultJsonTypeInfo , CancellationToken cancellationToken )
1414 {
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 ) ;
1720 }
1821
1922 public async Task < ScriptResult < TR > > ExecuteArray < TP , TR > ( string scriptName , TP parameter , JsonTypeInfo < TP > callJsonTypeInfo , JsonTypeInfo < TR > resultJsonTypeInfo , CancellationToken cancellationToken )
2023 {
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 ) ;
2329 }
2430
2531 public async Task < ScriptResult < TR > > Execute < TR > ( string scriptName , JsonTypeInfo < TR > resultJsonTypeInfo , CancellationToken cancellationToken = default )
2632 {
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 ) ;
2938 }
3039
3140 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
6776 [ RequiresUnreferencedCode ( "JSON" ) ]
6877 public async Task < ScriptResult < TR > > ExecuteArray < TP , TR > ( string scriptName , TP parameter , JsonSerializerOptions ? options , CancellationToken cancellationToken = default )
6978 {
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 ) ;
7284 }
7385
7486 [ RequiresUnreferencedCode ( "JSON" ) ]
7587 public async Task < ScriptResult < TR > > Execute < TR > ( string scriptName , IReadOnlyCollection < object > parameters , JsonSerializerOptions ? options = null , CancellationToken cancellationToken = default )
7688 {
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 ) ;
7994 }
8095
8196 [ RequiresUnreferencedCode ( "JSON" ) ]
8297 public async Task < ScriptResult < TR > > Execute < TR > ( string scriptName , JsonSerializerOptions ? options = null , CancellationToken cancellationToken = default )
8398 {
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 ) ;
86104 }
87105
88106 [ RequiresUnreferencedCode ( "JSON" ) ]
0 commit comments