Exemplo n.º 1
0
 /// <summary>
 /// Constructs a <see cref="ResolutionScopeBase"/>.
 /// </summary>
 public ResolutionScopeBase()
 {
     this.disposed            = new AtomicBool();
     this.rootItem            = DisposableItem.Empty;
     this.rootFinalizableItem = FinalizableItem.Empty;
     this.scopedItems         = new ConcurrentTree <object, object>();
     this.scopedInstances     = new ConcurrentTree <Type, object>();
 }
Exemplo n.º 2
0
 private ResolutionScope(IResolverSelector resolverSelector,
                         IExpressionBuilder expressionBuilder, IContainerContext containerContext,
                         DelegateCache delegateCache, object name)
 {
     this.rootItem            = DisposableItem.Empty;
     this.rootFinalizableItem = FinalizableItem.Empty;
     this.scopedItems         = AvlTree <object> .Empty;
     this.scopedInstances     = AvlTreeKeyValue <Type, object> .Empty;
     this.resolverSelector    = resolverSelector;
     this.expressionBuilder   = expressionBuilder;
     this.containerContext    = containerContext;
     this.Name          = name;
     this.delegateCache = delegateCache;
 }
Exemplo n.º 3
0
        /// <inheritdoc />
        public TService AddWithFinalizer <TService>(TService finalizable, Action <TService> finalizer)
        {
            var item = new FinalizableItem {
                Item = finalizable, Finalizer = f => finalizer((TService)f), Next = this.rootFinalizableItem
            };
            var current = this.rootFinalizableItem;

            Swap.SwapValue(ref this.rootFinalizableItem, current, item, root =>
                           new FinalizableItem {
                Item = finalizable, Finalizer = f => finalizer((TService)f), Next = root
            });

            return(finalizable);
        }
Exemplo n.º 4
0
 private ResolutionScope(IResolverSelector resolverSelector, IServiceRegistrator serviceRegistrator,
                         IExpressionBuilder expressionBuilder, IContainerContext containerContext,
                         AvlTreeKeyValue <object, Func <IResolutionScope, object> >[] serviceDelegateCache,
                         AvlTreeKeyValue <object, Func <IResolutionScope, Delegate> >[] factoryDelegates, object name)
 {
     this.disposed            = new AtomicBool();
     this.rootItem            = DisposableItem.Empty;
     this.rootFinalizableItem = FinalizableItem.Empty;
     this.scopedItems         = AvlTreeKeyValue <object, object> .Empty;
     this.scopedInstances     = AvlTreeKeyValue <Type, object> .Empty;
     this.resolverSelector    = resolverSelector;
     this.serviceRegistrator  = serviceRegistrator;
     this.expressionBuilder   = expressionBuilder;
     this.containerContext    = containerContext;
     this.Name             = name;
     this.serviceDelegates = serviceDelegateCache;
     this.factoryDelegates = factoryDelegates;
     this.indexBound       = this.serviceDelegates.Length - 1;
 }