private void AddOrUpdateRegistration(ref AvlTreeKeyValue <Type, ArrayStoreKeyed <object, IServiceRegistration> > repository, IServiceRegistration registration, bool remap, bool replace) { var newRepository = new ArrayStoreKeyed <object, IServiceRegistration>(registration.RegistrationId, registration); if (remap) { Swap.SwapValue(ref repository, repo => repo.AddOrUpdate(registration.ServiceType, newRepository, (oldValue, newValue) => newValue)); } else { Swap.SwapValue(ref repository, repo => repo.AddOrUpdate(registration.ServiceType, newRepository, (oldValue, newValue) => oldValue.AddOrUpdate(registration.RegistrationId, registration, replace))); } }
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; }
public static bool ContainsRegistration(this AvlTreeKeyValue <Type, ArrayStoreKeyed <object, IServiceRegistration> > repository, Type type, object name) { var registrations = repository.GetOrDefault(type); if (name != null && registrations != null) { return(registrations.GetOrDefault(name) != null); } if (registrations != null || !type.IsClosedGenericType()) { return(registrations != null); } registrations = repository.GetOrDefault(type.GetGenericTypeDefinition()); return(registrations?.Any(reg => reg.ValidateGenericConstraints(type)) ?? false); }
private void AddOrUpdateRegistration(ref AvlTreeKeyValue <Type, ArrayStoreKeyed <object, IServiceRegistration> > repository, IServiceRegistration registration, Type serviceType, bool remap, bool replace) { var newRepository = new ArrayStoreKeyed <object, IServiceRegistration>(registration.RegistrationId, registration); if (remap) { Swap.SwapValue(ref repository, (t1, t2, t3, t4, repo) => repo.AddOrUpdate(t1, t2, true), serviceType, newRepository, Constants.DelegatePlaceholder, Constants.DelegatePlaceholder); } else { Swap.SwapValue(ref repository, (t1, t2, t3, t4, repo) => repo.AddOrUpdate(t2, t3, (oldValue, newValue) => oldValue.AddOrUpdate(t1.RegistrationId, t1, t4)), registration, serviceType, newRepository, replace); } }
private ResolutionContext(IResolutionScope scope, AvlTreeKeyValue <int, bool> circularDependencyBarrier, AvlTree <Expression> expressionOverrides, AvlTree <Type> currentlyDecoratingTypes, ArrayStore <ArrayStoreKeyed <bool, ParameterExpression> > parameterExpressions, ISet <object> scopeNames, IContainerContext childContext, bool nullResultAllowed, ParameterExpression currentScope, ArrayStoreKeyed <object, ParameterExpression> knownVariables) { this.DefinedVariables = ArrayStoreKeyed <object, ParameterExpression> .Empty; this.SingleInstructions = ArrayStore <Expression> .Empty; this.expressionOverrides = expressionOverrides; this.currentlyDecoratingTypes = currentlyDecoratingTypes; this.NullResultAllowed = nullResultAllowed; this.ResolutionScope = scope; this.RootScope = scope.RootScope; this.CurrentScopeParameter = currentScope; this.ParameterExpressions = parameterExpressions; this.ChildContext = childContext; this.ScopeNames = scopeNames; this.knownVariables = knownVariables; this.circularDependencyBarrier = circularDependencyBarrier; }
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; }
public RegistrationRepository() { this.serviceRepository = AvlTreeKeyValue <Type, ArrayStoreKeyed <object, IServiceRegistration> > .Empty; this.namedScopeRepository = AvlTreeKeyValue <Type, ArrayStoreKeyed <object, IServiceRegistration> > .Empty; }
/// <summary> /// Constructs a <see cref="DecoratorRepository"/>. /// </summary> public DecoratorRepository() { this.repository = AvlTreeKeyValue <Type, ArrayStoreKeyed <Type, IServiceRegistration> > .Empty; }
internal void SetExpressionOverride(Type type, Expression expression) => this.expressionOverrides = this.expressionOverrides.AddOrUpdate(type, expression, true);
internal void ClearCurrentlyDecoratingType(Type type) => this.currentlyDecoratingTypes = this.currentlyDecoratingTypes.AddOrUpdate(type, null, true);
internal void AddCurrentlyDecoratingType(Type type) => this.currentlyDecoratingTypes = this.currentlyDecoratingTypes.AddOrUpdate(type, type);