コード例 #1
0
        public RouteAction Handle(ICall call)
        {
            if (_callResults.TryGetResult(call, out var configuredResult))
            {
                return(RouteAction.Return(configuredResult));
            }

            return(RouteAction.Continue());
        }
コード例 #2
0
        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)));
        }
コード例 #3
0
        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());
        }