Example #1
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "CreationContext" /> class.
        /// </summary>
        /// <param name = "requestedType">The type to extract generic arguments.</param>
        /// <param name = "parentContext">The parent context.</param>
        /// <param name = "propagateInlineDependencies">When set to <c>true</c> will clone <paramref name = "parentContext" /> <see
        ///    cref = "AdditionalArguments" />.</param>
        public CreationContext(Type requestedType, CreationContext parentContext, bool propagateInlineDependencies)
            : this(parentContext.Handler, parentContext.ReleasePolicy, requestedType, null, null, parentContext)
        {
            if (parentContext == null)
            {
                throw new ArgumentNullException("parentContext");
            }

            if (parentContext.extendedProperties != null)
            {
                extendedProperties = new Arguments(parentContext.extendedProperties);
            }

            if (propagateInlineDependencies && parentContext.HasAdditionalArguments)
            {
                additionalArguments = new Arguments(parentContext.additionalArguments);
            }
        }
Example #2
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "CreationContext" /> class.
        /// </summary>
        /// <param name = "handler">The handler.</param>
        /// <param name = "releasePolicy">The release policy.</param>
        /// <param name = "requestedType">The type to extract generic arguments.</param>
        /// <param name = "additionalArguments">The additional arguments.</param>
        /// <param name = "converter">The conversion manager.</param>
        /// <param name = "parent">Parent context</param>
        public CreationContext(IHandler handler, IReleasePolicy releasePolicy, Type requestedType,
                               IDictionary additionalArguments, ITypeConverter converter,
                               CreationContext parent)
        {
            this.requestedType = requestedType;
            this.handler = handler;
            this.releasePolicy = releasePolicy;
            this.additionalArguments = EnsureAdditionalArgumentsWriteable(additionalArguments);
            this.converter = converter;

            if (parent != null)
            {
                resolutionStack = parent.resolutionStack;
                handlerStack = parent.handlerStack;
                return;
            }
            handlerStack = new Stack<IHandler>(4);
            resolutionStack = new Stack<ResolutionContext>(4);
        }
Example #3
0
 public virtual object Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver,
                               ComponentModel model,
                               DependencyModel dependency)
 {
     Debug.Assert(CanResolve(context, contextHandlerResolver, model, dependency),
                  "CanResolve(context, contextHandlerResolver, model, dependency)");
     object result = null;
     if (dependency.DependencyKey != null)
     {
         result = Resolve(dependency, additionalArguments[dependency.DependencyKey]);
     }
     return result ?? Resolve(dependency, additionalArguments[dependency.TargetType]);
 }
Example #4
0
 public ResolutionContext(CreationContext context, IHandler handler, bool requiresDecommission, bool trackContext)
 {
     this.context = context;
     this.requiresDecommission = requiresDecommission;
     this.trackContext = trackContext;
     this.handler = handler;
 }
Example #5
0
 public virtual bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver,
                                ComponentModel model,
                                DependencyModel dependency)
 {
     return HasAdditionalArguments && (CanResolveByKey(dependency) || CanResolveByType(dependency));
 }