C
C#15mo ago
SWEETPONY

✅ 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
Pobiega15mo 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
SWEETPONY
SWEETPONYOP15mo ago
is it possible to do this without builder?
Pobiega
Pobiega15mo 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
SWEETPONY
SWEETPONYOP15mo 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
Pobiega15mo ago
oh its not your method?
SWEETPONY
SWEETPONYOP15mo ago
hmm I decided to just create another extension QueryQlWithChunks
Pobiega
Pobiega15mo ago
Thats also an option.
SWEETPONY
SWEETPONYOP15mo ago
thanks for helping
Pobiega
Pobiega15mo ago
yw
Want results from more Discord servers?
Add your server