public RouteAction Handle(ICall call) { if (_callResults.TryGetResult(call, out var configuredResult)) { return(RouteAction.Return(configuredResult)); } return(RouteAction.Continue()); }
public RouteAction Handle(ICall call) { if (_callResults.TryGetResult(call, out var cachedResult)) { return(RouteAction.Return(cachedResult)); } var type = call.GetReturnType(); var compatibleProviders = _autoValueProviders.Where(x => x.CanProvideValueFor(type)).FirstOrNothing(); return(compatibleProviders.Fold( RouteAction.Continue, ReturnValueUsingProvider(call, type))); }
public RouteAction Handle(ICall call) { if (_callResults.TryGetResult(call, out var cachedResult)) { return(RouteAction.Return(cachedResult)); } var type = call.GetReturnType(); // This is a hot method which is invoked frequently and has major impact on performance. // Therefore, the LINQ cycle was unwinded to loop. foreach (var autoValueProvider in _autoValueProviders) { if (autoValueProvider.CanProvideValueFor(type)) { return(RouteAction.Return(GetResultValueUsingProvider(call, type, autoValueProvider))); } } return(RouteAction.Continue()); }