C
C#9mo ago
TOKYODRIFT!

✅ How to get arguments from one method and pass them to another extension?

I have following:
var subjects = await _subjectServiceClient
.QueryQl(filter,fieldSet)
.WithChunks();
var subjects = await _subjectServiceClient
.QueryQl(filter,fieldSet)
.WithChunks();
What I want: 1. if user don't use WithChunks extension than I just need to run all logic inside QueryQl 2. if user use WithChunks than I need to run logic inside WithChunks now it looks simple:
static public async Task<List<T>> WithChunks<T>(this Task<MqttResult<T>> task)
{
return null;
}
static public async Task<List<T>> WithChunks<T>(this Task<MqttResult<T>> task)
{
return null;
}
WithChunks is smth generic so I don't need to pass filter, fieldSet, I want to get it from task but how can I do it?
9 Replies
Pobiega
Pobiega9mo ago
Usually done with a builder so the first method you call creates a returns a builder that the following methods use to access/modify the result
TOKYODRIFT!
TOKYODRIFT!9mo ago
is it possible to do this without builder?
Pobiega
Pobiega9mo ago
and you have some method at the end to "end" the building, either a .Build() or .ToList() etc not afaik if you are fine with
await _subjectServiceClient
.QueryQl(filter,fieldSet)
.RunAsync();
await _subjectServiceClient
.QueryQl(filter,fieldSet)
.RunAsync();
then its this is easily done
TOKYODRIFT!
TOKYODRIFT!9mo ago
but QueryQl is a method from SubjectClient:
Task<MqttResult<SubjectsQueryQlResponse>> QueryQl(
SubjectFilter filter,
string fieldSet = default,
Pagination pagination = default,
Sort sort = default,
RequestParameters parameters = default );
Task<MqttResult<SubjectsQueryQlResponse>> QueryQl(
SubjectFilter filter,
string fieldSet = default,
Pagination pagination = default,
Sort sort = default,
RequestParameters parameters = default );
I can't use builder here
Pobiega
Pobiega9mo ago
oh its not your method?
TOKYODRIFT!
TOKYODRIFT!9mo ago
hmm I decided to just create another extension QueryQlWithChunks
Pobiega
Pobiega9mo ago
Thats also an option.
TOKYODRIFT!
TOKYODRIFT!9mo ago
thanks for helping
Pobiega
Pobiega9mo ago
yw