/// <nodoc /> public static VoidResult <TError> ToResult <TError>(VoidResponseMessage <TError> response) where TError : ResponseError { return((response.error == null) ? VoidResult <TError> .Success() : VoidResult <TError> .Error(response.error)); }
private static RequestHandlerDelegate ForRequest2 <T, TResponseError>(Type targetType, MethodInfo method, HandlerProvider provider) where TResponseError : ResponseError, new() { Type deleType = typeof(Func <T, VoidResult <TResponseError> >); Func <T, VoidResult <TResponseError> > func = (Func <T, VoidResult <TResponseError> >)method.CreateDelegate(deleType); return((r, c, t) => { VoidRequestMessage request = (VoidRequestMessage)r; object target = provider.CreateTargetObject(targetType, c, t); VoidResult <TResponseError> result; try { result = func((T)target); } catch (Exception ex) { Console.Error.WriteLine(ex); result = VoidResult <TResponseError> .Error(Message.InternalError <TResponseError>()); } return new VoidResponseMessage <TResponseError> { Id = request.Id, Error = result.ErrorValue }; }); }