/// <summary> /// 执行操作 /// </summary> /// <typeparam name="TResultObject">返回对象类型</typeparam> /// <param name="func">要执行的具体业务</param> /// <param name="throwException">是否抛出异常</param> /// <returns>返回结果对象</returns> public static TResultObject Execute <TResultObject>(Func <TResultObject> func, bool throwException = false) where TResultObject : IResultObject, new() { var opt = new SimpleServiceOption <DefaultRequest, TResultObject>(new DefaultRequest(), null, func); return(opt.DoExecute(throwException)); }
/// <summary> /// 执行操作 /// </summary> /// <typeparam name="TRequest">请求对象类型</typeparam> /// <typeparam name="TResultObject">返回对象类型</typeparam> /// <param name="request">请求</param> /// <param name="requestValidator">请求验证器</param> /// <param name="func">要执行的具体业务</param> /// <param name="throwException">是否抛出异常</param> /// <returns>返回结果对象</returns> public static TResultObject Execute <TRequest, TResultObject>(TRequest request, IValidator requestValidator, Func <TResultObject> func, bool throwException = false) where TRequest : IRequest where TResultObject : IResultObject, new() { var opt = new SimpleServiceOption <TRequest, TResultObject>(request, requestValidator, func); return(opt.DoExecute(throwException)); }