private static Type GetExceptionType(IQueryExceptionHandler <TRequest, TResponse> handler) { var interfaceType = ReflectionBridge .FindInterfaces( handler.GetType(), x => ReflectionBridge.CheckIsGeneric(x) && x.GetGenericTypeDefinition() == typeof(IQueryExceptionHandler <, ,>) ) .SingleOrDefault(); return(interfaceType is null ? typeof(Exception) : ReflectionBridge.GetGenericArguments(interfaceType)[2]); }
public ExceptionHandlerWrapper(IQueryExceptionHandler <TRequest, TResponse> handler) { Handler = handler; ExceptionType = GetExceptionType(Handler); }