我的控制器库有以下处理程序:
protected ActionResult HandleRequest<TRequest, TResponse, TViewModel>(Func<TRequest, TResponse> function, TRequest request)
where TRequest : BaseRequest
where TResponse : BaseResponse<TViewModel>
where TViewModel : BaseViewModel
{
var viewData = function(request);
return View(viewData);
}
目前称之为
return HandleRequest<HomeIndexGetRequest, HomeIndexGetResponse, HomeIndexGetViewModel>(GetData, request);
在我的控制器中。 GetData方法看起来像
private static HomeIndexGetResponse GetData(HomeIndexGetRequest request)
{
return new HomeIndexGetResponse
{
ViewModel = new HomeIndexGetViewModel()
};
}
HomeIndexGetResponse
签名是
public class HomeIndexGetResponse : BaseResponse<HomeIndexGetViewModel>
BaseResponse
设置为
public abstract class BaseResponse<TViewModel> where TViewModel : BaseViewModel
问题:我是否有可能在没有明确指定类型参数的情况下调用HandleRequest?
return HandleRequest(GetData, request);