コード例 #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"));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: ServiceLocator.cs プロジェクト: legendz3/Siege
        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>());
        }