Exemple #1
0
        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"));
        }
Exemple #2
0
        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>());
        }
 public abstract object ResolveWith(IInstanceResolver locator, IServiceLocatorStore context, PostResolutionPipeline pipeline);
 public override object ResolveWith(IInstanceResolver resolver, IServiceLocatorStore context, PostResolutionPipeline pipeline)
 {
     return(action((TService)base.ResolveWith(resolver, context, pipeline)));
 }
Exemple #5
0
 public override object ResolveWith(IInstanceResolver resolver, IServiceLocatorStore context, PostResolutionPipeline pipeline)
 {
     return(registration.ResolveWith(resolver, context, pipeline));
 }
Exemple #6
0
        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);
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        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]);
        }
Exemple #9
0
        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()]);
        }