Код: Выделить всё
public async Task GetMyApp(Request Request, ODataQueryOptions? options = null)
{
MyResponse response = await ApiClient.GetData(Id, Name);
// some business logic
List expandOperators = new List();
expandOptions?
.ToList()
.ForEach(item =>
{
if (item.PathToNavigationProperty.FirstSegment.Identifier.Equals(AAEConstants.ODataConstants.ODataExpandDeployedTo, StringComparison.CurrentCultureIgnoreCase))
{
expandOperators.Add(FetchDeployInfo(response));
}
else if (item.PathToNavigationProperty.FirstSegment.Identifier.Equals(AAEConstants.ODataConstants.ODataExpandAvailableTo, StringComparison.CurrentCultureIgnoreCase))
{
expandOperators.Add(FetchAvailableInfo(response));
}
});
// make sure all the expand operations are done before returning
await Task.WhenAll(expandOperators);
}
Для полноты картины.
Код: Выделить всё
private async Task FetchDeployInfo(Response response)
{
Result deployedTores = await ApiClient.GetPolicyAsync(response.TitleId);
DeployedResponse deployedTo = deployedTores.ExtractDeployTo();
response.DeployedTo = deployedTo;
}
private async Task FetchAvailableInfo(Response response)
{
Result avlblTo = await ApiClient.GetPolicyAvlblAsync(response.TitleId);
AvlblResponse avlblTo = avlblTores .ExtractAVlblTo();
response.AvailableTo= avlblTo ;
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... on-c-sharp
Мобильная версия