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); } }