public FactoryResolutionPipeline(Foundation foundation, IServiceLocatorAdapter adapter, IServiceLocatorStore store) { var pipeline = new PostResolutionPipeline(foundation, adapter, store); Add(new ConditionalPipelineItem(foundation, adapter, store, pipeline)); Add(new DefaultPipelineItem(foundation, adapter, store, pipeline)); }
public override void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline) { var mappedFromType = registration.GetMappedFromType(); var mappedToType = registration.GetMappedToType(); if (mappedFromType != mappedToType) { adapter.RegisterFactoryMethod(mappedFromType, () => pipeline.Execute(mappedFromType)); RegisterLazy(adapter, mappedFromType, pipeline); adapter.Register(mappedToType, mappedToType); RegisterContextual(adapter, mappedToType); } else { var serviceLocator = adapter.GetInstance <IServiceLocator>(); adapter.RegisterFactoryMethod(mappedToType, () => { var instance = serviceLocator.GetInstance(mappedToType, "default." + mappedToType, new IResolutionArgument[0]); return(instance); }); serviceLocator.Register(new NamedRegistration(mappedToType, mappedToType, "default." + mappedToType)); } RegisterLazy(adapter, mappedToType, pipeline); RegisterTypeResolver(adapter, mappedFromType); RegisterContextual(adapter, mappedFromType); }
protected static List <object> MergeContextItems(IServiceLocatorStore context) { var contextItems = new List <object>(); var stores = context.All <IResolutionStore>().ToList(); var resolutionItems = new List <IResolutionArgument>(); stores.ForEach(x => resolutionItems.AddRange(x.Items)); for (int i = 0; i < resolutionItems.Count; i++) { var argument = resolutionItems[i]; if (argument is ContextArgument) { contextItems.Add(((ContextArgument)argument).ContextItem); } } foreach (IContextStore contextStore in context.All <IContextStore>()) { var items = contextStore.Items; for (int i = 0; i < items.Count; i++) { var item = items[i]; contextItems.Add(item); } } return(contextItems); }
protected static List<object> MergeContextItems(IServiceLocatorStore context) { var contextItems = new List<object>(); var stores = context.All<IResolutionStore>().ToList(); var resolutionItems = new List<IResolutionArgument>(); stores.ForEach(x => resolutionItems.AddRange(x.Items)); for (int i = 0; i < resolutionItems.Count; i++) { var argument = resolutionItems[i]; if (argument is ContextArgument) contextItems.Add(((ContextArgument) argument).ContextItem); } foreach (IContextStore contextStore in context.All<IContextStore>()) { var items = contextStore.Items; for (int i = 0; i < items.Count; i++) { var item = items[i]; contextItems.Add(item); } } return contextItems; }
public override void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline) { var mappedFromType = registration.GetMappedFromType(); var mappedToType = registration.GetMappedToType(); if (mappedFromType != mappedToType) { adapter.RegisterFactoryMethod(mappedFromType, () => pipeline.Execute(mappedFromType)); RegisterLazy(adapter, mappedFromType, pipeline); adapter.Register(mappedToType, mappedToType); RegisterContextual(adapter, mappedToType); } else { var serviceLocator = adapter.GetInstance<IServiceLocator>(); adapter.RegisterFactoryMethod(mappedToType, () => { var instance = serviceLocator.GetInstance(mappedToType, "default." + mappedToType, new IResolutionArgument[0]); return instance; }); serviceLocator.Register(new NamedRegistration(mappedToType, mappedToType, "default." + mappedToType)); } RegisterLazy(adapter, mappedToType, pipeline); RegisterTypeResolver(adapter, mappedFromType); RegisterContextual(adapter, mappedFromType); }
private ThreadedExecutionStore(IServiceLocatorStore store) { this.store = store; RequestedTypes = new List <Type>(); index = 0; store.SetStore <IResolutionStore>(new ThreadedResolutionStore()); }
protected ServiceLocator(IServiceLocatorAdapter serviceLocator, IServiceLocatorStore store) { this.serviceLocator = serviceLocator; this.store = store; foundation = new Foundation(); pipeline = new DefaultResolutionPipeline(foundation, serviceLocator, this.store); factoryPipeline = new FactoryResolutionPipeline(foundation, serviceLocator, this.store); postResolutionPipeline = new PostResolutionPipeline(foundation, serviceLocator, store); registrationTemplate = new DefaultMetaRegistrationTemplate(serviceLocator); serviceLocator.Register(typeof(Transient), typeof(Transient)); serviceLocator.Register(typeof(Singleton), typeof(Singleton)); serviceLocator.RegisterInstance(typeof(IServiceLocatorAdapter), serviceLocator); serviceLocator.RegisterInstance(typeof(IServiceLocator), this); serviceLocator.RegisterInstance(typeof(Microsoft.Practices.ServiceLocation.IServiceLocator), this); serviceLocator.RegisterInstance(typeof(Foundation), this.foundation); serviceLocator.RegisterInstance(typeof(IServiceLocatorStore), this.store); serviceLocator.RegisterInstance(typeof(IContextStore), this.store.Get <IContextStore>()); serviceLocator.RegisterInstance(typeof(IExecutionStore), this.store.Get <IExecutionStore>()); serviceLocator.RegisterInstance(typeof(IResolutionStore), this.store.Get <IResolutionStore>()); var binPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath ?? AppDomain.CurrentDomain.SetupInformation.ApplicationBase; Register(Load.FromAssembliesIn(binPath, binPath + @"\Plugins\", ".plugin")); }
private ThreadedExecutionStore(IServiceLocatorStore store) { this.store = store; RequestedTypes = new List<Type>(); index = 0; store.SetStore<IResolutionStore>(new ThreadedResolutionStore()); }
public DefaultResolutionPipeline(Foundation foundation, IServiceLocatorAdapter adapter, IServiceLocatorStore store) : base(foundation, adapter, store) { var pipeline = new PostResolutionPipeline(foundation, adapter, store); Add(new AdapterPipelineItem(foundation, adapter, store, pipeline)); }
public object Resolve(IInstanceResolver locator, IServiceLocatorStore context) { var stores = context.All <IResolutionStore>().ToList(); var items = new List <IResolutionArgument>(); stores.ForEach(x => items.AddRange(x.Items)); return(locator.GetInstance(type, name, items.OfType <IResolutionArgument, IResolutionArgument>())); }
public override void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline) { var namedRegistration = (INamedRegistration)registration; var mappedTo = registration.GetMappedTo(); adapter.RegisterInstanceWithName(registration.GetMappedToType(), mappedTo, namedRegistration.Key); adapter.RegisterInstanceWithName(registration.GetMappedFromType(), mappedTo, namedRegistration.Key); }
public override object ResolveWith(IInstanceResolver locator, IServiceLocatorStore context, PostResolutionPipeline pipeline) { if (!tempData.ContainsKey(registration.GetMappedToType().ToString())) { tempData[registration.GetMappedToType().ToString()] = registration.ResolveWith(locator, context, pipeline); } return tempData[registration.GetMappedToType().ToString()]; }
public override object ResolveWith(IInstanceResolver locator, IServiceLocatorStore context, PostResolutionPipeline pipeline) { if (!tempData.ContainsKey(registration.GetMappedToType().ToString())) { tempData[registration.GetMappedToType().ToString()] = registration.ResolveWith(locator, context, pipeline); } return(tempData[registration.GetMappedToType().ToString()]); }
public void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline) { if (registration is ConstructorRegistration) { var constructorRegistration = registration as ConstructorRegistration; store.Get<IInjectionOverrideStore>().Add(constructorRegistration.Arguments); } }
public void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline) { if (registration is ConstructorRegistration) { var constructorRegistration = registration as ConstructorRegistration; store.Get <IInjectionOverrideStore>().Add(constructorRegistration.Arguments); } }
public virtual bool IsValid(IActivationRule rule, IInstanceResolver resolver, IServiceLocatorStore context) { var items = MergeContextItems(context); for (int i = 0; i < items.Count; i++) { var contextItem = items[i]; if (rule.Evaluate(resolver, contextItem)) return true; } return false; }
public bool IsValid(IActivationRule rule, IInstanceResolver resolver, IServiceLocatorStore context) { var types = context.Get<IExecutionStore>().RequestedTypes; for(int i = 0; i < types.Count; i++) { var dependency = types[i]; if (rule.Evaluate(resolver, dependency)) return true; } return false; }
public override void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline) { var namedRegistration = (INamedRegistration)registration; var mappedToType = registration.GetMappedToType(); var mappedFromType = registration.GetMappedFromType(); adapter.RegisterWithName(mappedToType, mappedToType, namedRegistration.Key); adapter.RegisterWithName(mappedFromType, mappedToType, namedRegistration.Key); RegisterNamedLazy(adapter, mappedFromType, namedRegistration.Key); RegisterNamedLazy(adapter, mappedToType, namedRegistration.Key); }
public override void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline) { var mappedFromType = registration.GetMappedFromType(); var mappedToType = registration.GetMappedToType(); adapter.RegisterFactoryMethod(mappedFromType, () => pipeline.Execute(mappedFromType)); adapter.RegisterInstance(mappedToType, registration.GetMappedTo()); RegisterLazy(adapter, mappedFromType, pipeline); RegisterLazy(adapter, mappedToType, pipeline); RegisterContextual(adapter, mappedFromType); RegisterContextual(adapter, mappedToType); }
public override void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline) { var namedRegistration = (INamedRegistration) registration; var mappedToType = registration.GetMappedToType(); var mappedFromType = registration.GetMappedFromType(); adapter.RegisterWithName(mappedToType, mappedToType, namedRegistration.Key); adapter.RegisterWithName(mappedFromType, mappedToType, namedRegistration.Key); RegisterNamedLazy(adapter, mappedFromType, namedRegistration.Key); RegisterNamedLazy(adapter, mappedToType, namedRegistration.Key); }
public virtual object ResolveWith(IInstanceResolver locator, IServiceLocatorStore context, PostResolutionPipeline pipeline) { object instance = null; instance = GetActivationStrategy().Resolve(locator, context); if (pipeline != null) { var result = GetResult(instance); pipeline.Execute(result); } return(instance); }
public override object ResolveWith(IInstanceResolver resolver, IServiceLocatorStore context, PostResolutionPipeline pipeline) { if (instance == null) { lock (lockObject) { if(instance == null) { instance = registration.ResolveWith(resolver, context, pipeline); } } } return instance; }
public virtual object ResolveWith(IInstanceResolver locator, IServiceLocatorStore context, PostResolutionPipeline pipeline) { object instance = null; instance = GetActivationStrategy().Resolve(locator, context); if(pipeline != null) { var result = GetResult(instance); pipeline.Execute(result); } return instance; }
public bool IsValid(IActivationRule rule, IInstanceResolver resolver, IServiceLocatorStore context) { var types = context.Get <IExecutionStore>().RequestedTypes; for (int i = 0; i < types.Count; i++) { var dependency = types[i]; if (rule.Evaluate(resolver, dependency)) { return(true); } } return(false); }
public override object ResolveWith(IInstanceResolver resolver, IServiceLocatorStore context, PostResolutionPipeline pipeline) { if (instance == null) { lock (lockObject) { if (instance == null) { instance = registration.ResolveWith(resolver, context, pipeline); } } } return(instance); }
public override object ResolveWith(IInstanceResolver locator, IServiceLocatorStore context, PostResolutionPipeline pipeline) { var httpContext = locator.GetInstance<HttpContextBase>(); var instance = httpContext.Items[key]; if (instance == null) { lock (lockObject) { if (instance == null) { instance = registration.ResolveWith(locator, context, pipeline); httpContext.Items.Add(key, instance); return instance; } } } return httpContext.Items[key]; }
public override object ResolveWith(IInstanceResolver locator, IServiceLocatorStore context, PostResolutionPipeline pipeline) { var httpContext = locator.GetInstance <HttpContextBase>(); var instance = httpContext.Items[key]; if (instance == null) { lock (lockObject) { if (instance == null) { instance = registration.ResolveWith(locator, context, pipeline); httpContext.Items.Add(key, instance); return(instance); } } } return(httpContext.Items[key]); }
protected static List<object> MergeContextItems(IServiceLocatorStore context) { var contextItems = new List<object>(); var resolutionItems = context.Get<IResolutionStore>().Items; for (int i = 0; i < resolutionItems.Count; i++) { var argument = resolutionItems[i]; if (argument is ContextArgument) contextItems.Add(((ContextArgument) argument).ContextItem); } var items = context.Get<IContextStore>().Items; for (int i = 0; i < items.Count; i++) { var item = items[i]; contextItems.Add(item); } return contextItems; }
protected ServiceLocator(IServiceLocatorAdapter serviceLocator, IServiceLocatorStore store) { this.serviceLocator = serviceLocator; this.store = store; foundation = new Foundation(); pipeline = new DefaultResolutionPipeline(foundation, serviceLocator, this.store); factoryPipeline = new FactoryResolutionPipeline(foundation, serviceLocator, this.store); postResolutionPipeline = new PostResolutionPipeline(foundation, serviceLocator, store); registrationTemplate = new DefaultMetaRegistrationTemplate(serviceLocator); serviceLocator.Register(typeof(Transient), typeof(Transient)); serviceLocator.Register(typeof(Singleton), typeof(Singleton)); serviceLocator.RegisterInstance(typeof(IServiceLocatorAdapter), serviceLocator); serviceLocator.RegisterInstance(typeof(IServiceLocator), this); serviceLocator.RegisterInstance(typeof(Microsoft.Practices.ServiceLocation.IServiceLocator), this); serviceLocator.RegisterInstance(typeof(Foundation), this.foundation); serviceLocator.RegisterInstance(typeof(IServiceLocatorStore), this.store); serviceLocator.RegisterInstance(typeof(IContextStore), this.store.Get <IContextStore>()); serviceLocator.RegisterInstance(typeof(IExecutionStore), this.store.Get <IExecutionStore>()); serviceLocator.RegisterInstance(typeof(IResolutionStore), this.store.Get <IResolutionStore>()); }
protected static List <object> MergeContextItems(IServiceLocatorStore context) { var contextItems = new List <object>(); var resolutionItems = context.Get <IResolutionStore>().Items; for (int i = 0; i < resolutionItems.Count; i++) { var argument = resolutionItems[i]; if (argument is ContextArgument) { contextItems.Add(((ContextArgument)argument).ContextItem); } } var items = context.Get <IContextStore>().Items; for (int i = 0; i < items.Count; i++) { var item = items[i]; contextItems.Add(item); } return(contextItems); }
public object Resolve(IInstanceResolver locator, IServiceLocatorStore context) { return(factoryMethod(locator)); }
public virtual bool IsValid(IInstanceResolver locator, IServiceLocatorStore context) { return rule != null && rule.GetRuleEvaluationStrategy().IsValid(rule, locator, context); }
public PostResolutionPipeline(Foundation foundation, IServiceLocatorAdapter adapter, IServiceLocatorStore store) { Add(new ConditionalPostResolutionPipelineItem(foundation, adapter, store)); Add(new DefaultPostResolutionPipelineItem(foundation, adapter, store)); }
public void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline) { adapter.Register(registration.GetMappedFromType(), registration.GetMappedToType()); }
public void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline) { store.Get <IAwarenessStore>().Add(registration.GetMappedTo()); }
public AdapterPipelineItem(Foundation foundation, IServiceLocatorAdapter serviceLocator, IServiceLocatorStore store, PostResolutionPipeline pipeline) : base(foundation, serviceLocator, store) { this.pipeline = pipeline; }
protected WcfContextExecutionStore(IServiceLocatorStore store) { this.store = store; this.store.SetStore<IResolutionStore>(new WcfResolutionStore()); WcfOperationContext.Current.Items["WcfContextExecutionStore_ExecutionCount"] = 0; }
protected BasePipelineItem(Foundation foundation, IServiceLocatorAdapter serviceLocator, IServiceLocatorStore store) { this.foundation = foundation; this.serviceLocator = serviceLocator; this.store = store; }
public void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline) { }
public override object ResolveWith(IInstanceResolver resolver, IServiceLocatorStore context, PostResolutionPipeline pipeline) { return(action((TService)base.ResolveWith(resolver, context, pipeline))); }
protected HttpContextExecutionStore(IServiceLocatorStore store) { this.store = store; this.store.SetStore<IResolutionStore>(new HttpResolutionStore()); HttpContext.Current.Items["executionCount"] = 0; }
public abstract void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline);
public override object ResolveWith(IInstanceResolver resolver, IServiceLocatorStore context, PostResolutionPipeline pipeline) { return(registration.ResolveWith(resolver, context, pipeline)); }
protected HttpServiceLocator(IServiceLocatorAdapter serviceLocator, IServiceLocatorStore store) : base(serviceLocator, store) { serviceLocator.Register(typeof(PerHttpRequest), typeof(PerHttpRequest)); Register(Given<HttpContextBase>.ConstructWith(x => new HttpContextWrapper(HttpContext.Current))); }
public abstract object ResolveWith(IInstanceResolver locator, IServiceLocatorStore context, PostResolutionPipeline pipeline);
public void Register(IServiceLocatorAdapter adapter, IServiceLocatorStore store, IRegistration registration, ResolutionPipeline pipeline) { store.Get<IAwarenessStore>().Add(registration.GetMappedTo()); }
public DefaultPipelineItem(Foundation foundation, IServiceLocatorAdapter serviceLocator, IServiceLocatorStore store, PostResolutionPipeline pipeline) : base(foundation, serviceLocator, store) { this.pipeline = pipeline; this.store.Get <IExecutionStore>().WireEvent((ITypeRequester)this); this.store.Get <IExecutionStore>().WireEvent((ITypeResolver)this); this.registrationStore = foundation.StoreFor <DefaultRegistrationStore>(); }
public bool IsValid(IInstanceResolver locator, IServiceLocatorStore context) { return registration.IsValid(locator, context); }
public ConditionalPostResolutionPipelineItem(Foundation foundation, IServiceLocatorAdapter serviceLocator, IServiceLocatorStore store) : base(foundation, serviceLocator, store) { registrationStore = foundation.StoreFor <ConditionalPostResolutionStore>(); }
public object Resolve(IInstanceResolver locator, IServiceLocatorStore context) { return(implementation); }
public bool IsValid(IInstanceResolver locator, IServiceLocatorStore context) { return(registration.IsValid(locator, context)); }
public static IExecutionStore New(IServiceLocatorStore store) { return new ThreadedExecutionStore(store); }
public static IExecutionStore New(IServiceLocatorStore store) { return new WcfContextExecutionStore(store); }
public object ResolveWith(IInstanceResolver resolver, IServiceLocatorStore context, PostResolutionPipeline pipeline) { return registration.ResolveWith(resolver, context, pipeline); }