Esempio n. 1
0
        /// <summary>
        /// Create new request from this request
        /// </summary>
        /// <param name="activationType">request type</param>
        /// <param name="requestingStrategy">requesting strategy</param>
        /// <param name="injectedType">type being injected into</param>
        /// <param name="requestType">request type</param>
        /// <param name="info">info for request</param>
        /// <param name="maintainPaths">maintain wrapper and decorator path</param>
        /// <param name="carryData"></param>
        /// <returns>new request</returns>
        public IActivationExpressionRequest NewRequest(Type activationType, IActivationStrategy requestingStrategy, Type injectedType, RequestType requestType, object info, bool maintainPaths = false, bool carryData = false)
        {
            if (ObjectGraphDepth + 1 > Services.Compiler.MaxObjectGraphDepth)
            {
                throw new RecursiveLocateException(GetStaticInjectionContext());
            }

            var data = carryData ? PerDelegateData : new PerDelegateData();

            var returnValue = new ActivationExpressionRequest(activationType, requestType, Services, Constants, ObjectGraphDepth + 1, RequestingScope, data)
            {
                Parent             = this,
                InjectedType       = injectedType,
                RequestingStrategy = requestingStrategy,
                Info = info,
                DisposalScopeExpression   = DisposalScopeExpression,
                ScopeParameter            = ScopeParameter,
                InjectionContextParameter = InjectionContextParameter,
                KnownValueExpressions     = KnownValueExpressions
            };

            if (Filter != null && RequestingStrategy != null &&
                RequestingStrategy.StrategyType == ActivationStrategyType.WrapperStrategy)
            {
                returnValue.Filter = Filter;
            }

            if (maintainPaths)
            {
                returnValue._wrapperNodes   = _wrapperNodes;
                returnValue._decoratorNodes = _decoratorNodes;
            }

            return(returnValue);
        }
        /// <summary>
        /// Creates new rooted request (for lifestyles)
        /// </summary>
        /// <param name="activationType"></param>
        /// <param name="requestingScope"></param>
        /// <param name="maintainPaths"></param>
        /// <returns></returns>
        public IActivationExpressionRequest NewRootedRequest(Type activationType, IInjectionScope requestingScope,
                                                             bool maintainPaths = false)
        {
            if (ObjectGraphDepth + 1 > Services.Compiler.MaxObjectGraphDepth)
            {
                throw new RecursiveLocateException(GetStaticInjectionContext());
            }

            var returnValue = new ActivationExpressionRequest(activationType,
                                                              RequestType.Root,
                                                              Services,
                                                              Constants,
                                                              ObjectGraphDepth + 1,
                                                              requestingScope);

            if (maintainPaths)
            {
                returnValue._wrapperNodes   = _wrapperNodes;
                returnValue._decoratorNodes = _decoratorNodes;
            }

            return(returnValue);
        }