private async Task <T> ProcessApiCallAsync <T>(Uri fullUrl, HttpMethod httpMethod, QueryParameters queryParameters, BodyParameters bodyParameters, CancellationToken ct) where T : class { var parametersAsDTOs = ConvertToDtoBodyParameters(bodyParameters); Type dtoType = _dtoResolver.GetDataTransferObjectRecursive(typeof(T)); var sendMethod = CreateGenericSendAsyncMethodInfo(dtoType); var apiCallResponseType = typeof(ApiCallResponse <>).MakeGenericType(dtoType); var apiResponse = Convert.ChangeType( await sendMethod.InvokeAsync(this, new object[] { fullUrl, httpMethod, ct, queryParameters, parametersAsDTOs }), apiCallResponseType); EnsureSuccessfullApiResponse((ApiCallResponse)apiResponse); //map to object because of Automapper 10.0 .NET Framework //https://docs.automapper.org/en/latest/10.0-Upgrade-Guide.html#mapping-from-dynamic-in-net-4-6-1 return(_mapper.Map <T>(((dynamic)apiResponse).Content as object)); }
public void CanFindRecursiveDtoObject() { var dtoType = _resolver.GetDataTransferObjectRecursive(typeof(ClassD <ClassB>)); dtoType.Should().Be(typeof(ClassC <ClassA>)); }