public void RemoveChild(MsLifetimeScope lifetimeScope) { lock (_children) { _children.Remove(lifetimeScope); } }
public void AddChild(MsLifetimeScope lifetimeScope) { lock (_children) { _children.Add(lifetimeScope); } }
public static IDisposable Using(MsLifetimeScope newLifetimeScope) { var previous = Current; Current = newLifetimeScope; return(new DisposeAction(() => { Current = previous; })); }
public override object Resolve(CreationContext context, IReleasePolicy releasePolicy) { if (MsLifetimeScope.Current == null) { return(base.Resolve(context, releasePolicy)); } using (MsLifetimeScope.Using(_globalMsLifetimeScopeProvider.LifetimeScope)) { return(base.Resolve(context, releasePolicy)); } }
public WindsorServiceScope(IWindsorContainer container, MsLifetimeScope currentMsLifetimeScope) { _parentLifetimeScope = currentMsLifetimeScope; LifetimeScope = new MsLifetimeScope(); _parentLifetimeScope?.AddChild(LifetimeScope); using (MsLifetimeScope.Using(LifetimeScope)) { ServiceProvider = container.Resolve <IServiceProvider>(); } }
private object GetServiceInternal(Type serviceType, bool isOptional) { using (MsLifetimeScope.Using(_ownMsLifetimeScope)) { if (serviceType.IsGenericType && serviceType.GetGenericTypeDefinition() == typeof(IEnumerable <>)) { var allObjects = _container.ResolveAll(serviceType.GenericTypeArguments[0]); Array.Reverse(allObjects); return(allObjects); } if (!isOptional) { return(_container.Resolve(serviceType)); } if (_container.Kernel.HasComponent(serviceType)) { return(_container.Resolve(serviceType)); } return(null); } }
public ScopedWindsorServiceProvider(IWindsorContainer container, MsLifetimeScopeProvider msLifetimeScopeProvider) { _container = container; _ownMsLifetimeScope = msLifetimeScopeProvider.LifetimeScope; }
public GlobalMsLifetimeScopeProvider() { LifetimeScope = new MsLifetimeScope(); }
public MsLifetimeScopeProvider(GlobalMsLifetimeScopeProvider globalMsLifetimeScopeProvider) { LifetimeScope = MsLifetimeScope.Current ?? globalMsLifetimeScopeProvider.LifetimeScope; }
public WindsorServiceScopeFactory(IWindsorContainer container, MsLifetimeScopeProvider msLifetimeScopeProvider) { _container = container; _msLifetimeScope = msLifetimeScopeProvider.LifetimeScope; }