public void SetUp()
		{
			var configurationStore = new DefaultConfigurationStore();
			var resource = new AssemblyResource("Castle.Facilities.NHibernateIntegration.Tests/Issues/Facilities117/facility.xml");
			var xmlInterpreter = new XmlInterpreter(resource);
			xmlInterpreter.ProcessResource(resource, configurationStore);
			facilityCfg = configurationStore.GetFacilityConfiguration("nhibernatefacility").Children["factory"];
		}
コード例 #2
0
ファイル: Fixture.cs プロジェクト: janv8000/Windsor
		public override void OnSetUp()
		{
			var configurationStore = new DefaultConfigurationStore();
			var resource = new AssemblyResource("Castle.Facilities.NHibernateIntegration.Tests/Issues/Facilities116/facility.xml");
			var xmlInterpreter = new XmlInterpreter(resource);
			xmlInterpreter.ProcessResource(resource, configurationStore);
			configuration = configurationStore.GetFacilityConfiguration("nhibernatefacility").Children["factory"];
			configurationBuilder = new PersistentConfigurationBuilder();
		}
コード例 #3
0
        public void CorrectConfigurationMapping()
        {
            DefaultConfigurationStore store       = new DefaultConfigurationStore();
            XmlInterpreter            interpreter = new XmlInterpreter("sample_config.xml");

            interpreter.ProcessResource(interpreter.Source, store);

            WindsorContainer container = new WindsorContainer(store);

            container.AddFacility("testidengine", new DummyFacility());
        }
コード例 #4
0
        public void Init()
        {
            DefaultConfigurationStore store       = new DefaultConfigurationStore();
            XmlInterpreter            interpreter = new XmlInterpreter(new ConfigResource());

            interpreter.ProcessResource(interpreter.Source, store);
            _container = new PestControlContainer(interpreter);

            _model  = (PestControlModel)_container["pestcontrolModel"];
            _engine = (PrevalenceEngine)_container["prevalenceengine"];
        }
コード例 #5
0
        public void Test_Embedded3()
        {
            var resource          = Xml.Embedded("hasResourceIncludes.xml");
            var interpreter       = new XmlInterpreter(resource);
            var kernel            = new DefaultKernel();
            var resourceSubSystem = kernel.GetSubSystem(SubSystemConstants.ResourceKey) as IResourceSubSystem;
            var processor         = new XmlProcessor(null, resourceSubSystem);
            var assemRes          = resource as AssemblyResource;

            Assert.IsNotNull(assemRes);
            var stream = assemRes.CreateStream();
        }
コード例 #6
0
        public void Test_Embedded()
        {
            var resource = Xml.Embedded("hasResourceIncludes.xml");

            Assert.IsNotNull(resource);
            Assert.AreEqual(resource.FileBasePath, AppDomain.CurrentDomain.BaseDirectory);
            var interpreter = new XmlInterpreter(resource);

            Assert.AreEqual(interpreter.EnvironmentName, null);
            var kernel = new DefaultKernel();

            interpreter.ProcessResource(resource, kernel.ConfigurationStore, kernel);
        }
コード例 #7
0
ファイル: Container.cs プロジェクト: Zoulily97/CQIE.OVS
 private Container()
 {
     try
     {
         interpreter = new Castle.Windsor.Configuration.Interpreters.XmlInterpreter("Config/ServiceConfig.xml");
         windsor     = new WindsorContainer(interpreter);
         Kernel      = windsor.Kernel;
     }
     catch (Exception E)
     {
         throw E;
     }
 }
コード例 #8
0
        public void CorrectConfigurationMapping()
        {
            var     store       = new DefaultConfigurationStore();
            var     interpreter = new XmlInterpreter(Xml.Embedded("sample_config.xml"));
            IKernel kernel      = new DefaultKernel();

            interpreter.ProcessResource(interpreter.Source, store, kernel);

            var container = new WindsorContainer(store);
            var facility  = container.Kernel.GetFacilities().OfType <HiperFacility>().Single();

            Assert.IsTrue(facility.Initialized);
        }
コード例 #9
0
ファイル: Container.cs プロジェクト: yiyungent/LMS
 /// <summary>
 /// 私有化构造方法,实现单例模式
 /// </summary>
 private Container()
 {
     try
     {
         interpreter = new XmlInterpreter("Config/Service.xml");
         windsor     = new WindsorContainer(interpreter);
         kernel      = windsor.Kernel;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #10
0
        public override IEnumerable <T> ReadEntities(string filePath)
        {
            XmlDocument xmlContent = new XmlDocument();

            xmlContent.Load(filePath);

            XmlNodeList elemList = xmlContent.GetElementsByTagName("ROW");

            foreach (XmlNode item in elemList)
            {
                yield return(XmlInterpreter.DeserializeObject <T>(item.OuterXml));
            }
        }
コード例 #11
0
        public void ComponentIdGetsLoadedFromTheParsedConfiguration()
        {
            var     store       = new DefaultConfigurationStore();
            var     interpreter = new XmlInterpreter(Xml.Embedded("sample_config_with_spaces.xml"));
            IKernel kernel      = new DefaultKernel();

            interpreter.ProcessResource(interpreter.Source, store, kernel);

            var container = new WindsorContainer(store);

            var handler = container.Kernel.GetHandler(typeof(ICalcService));

            Assert.AreEqual(Core.LifestyleType.Transient, handler.ComponentModel.LifestyleType);
        }
コード例 #12
0
        public With_accepting_work_queue()
        {
            if (MessageQueue.Exists(acceptingWorkQueuePath) == false)
            {
                MessageQueue.Create(acceptingWorkQueuePath);
            }
            var acceptingWork = new MessageQueue(acceptingWorkQueuePath);

            acceptingWork.Purge();

            var interpreter = new XmlInterpreter(@"LoadBalancer\BusWithAcceptingWorkLoadBalancer.config");

            container = new WindsorContainer(interpreter);
            container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());

            container.Register(Component.For <MyHandler>());

            container.Register(
                Component.For <MsmqLoadBalancer>()
                .DependsOn(new
            {
                threadCount           = 1,
                endpoint              = new Uri(loadBalancerQueue),
                transactional         = TransactionalOptions.FigureItOut,
                secondaryLoadBalancer = TestQueueUri2.Uri
            })
                );

            container.Register(
                Component.For <MsmqReadyForWorkListener>()
                .DependsOn(new
            {
                threadCount   = 1,
                endpoint      = new Uri(acceptingWorkQueue),
                transactional = TransactionalOptions.FigureItOut
            })
                );

            container.Register(
                Component.For <MsmqSecondaryLoadBalancer>()
                .DependsOn(new
            {
                threadCount         = 1,
                endpoint            = TestQueueUri2.Uri,
                primaryLoadBalancer = new Uri(loadBalancerQueue),
                transactional       = TransactionalOptions.FigureItOut
            })
                );
        }
コード例 #13
0
ファイル: Global.asax.cs プロジェクト: tonykit/CPY
        private void WireUpDependencyResolvers()
        {
            Castle.Core.Resource.ConfigResource source = new Castle.Core.Resource.ConfigResource();
            XmlInterpreter interpreter = new XmlInterpreter(source);

            IocContext.WindsorContainer = new WindsorContainer(interpreter);
            IocContext.WindsorContainer.Register(Classes.FromThisAssembly().BasedOn <ApiController>().LifestylePerWebRequest());
            IocContext.WindsorContainer.Register(Classes.FromThisAssembly().BasedOn <Controller>().LifestylePerWebRequest());
            //IocContext.WindsorContainer.Register(
            //    Component.For<IUnitOfWork>().ImplementedBy<DemoUnitOfWorkContext>().LifestylePerThread());
            IocContext.WindsorContainer.Register(
                Component.For <IUow>().ImplementedBy <Uow>().LifestylePerThread());
            IocContext.WindsorContainer.Register(
                Component.For <IUDbContext>().ImplementedBy <UDbcontext>().LifestylePerThread());
            GlobalConfiguration.Configuration.DependencyResolver = new WindsorDependencyResolver(IocContext.WindsorContainer);
            //ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(IocContext.WindsorContainer));
        }
コード例 #14
0
        public With_fail_over()
        {
            var interpreter = new XmlInterpreter(@"LoadBalancer\BusWithLoadBalancer.config");

            container = new WindsorContainer(interpreter);
            container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());

            container.Register(
                Component.For <MsmqLoadBalancer>()
                .DependsOn(new
            {
                threadCount           = 1,
                endpoint              = new Uri(loadBalancerQueue),
                secondaryLoadBalancer = TestQueueUri2.Uri,
                transactional         = TransactionalOptions.FigureItOut
            })
                );
        }
コード例 #15
0
        public void InvalidAssemblyName()
        {
            String xml =
                "<configuration>" +
                "	<facilities>"+
                "		<facility id=\"batchregistration\">"+
                "			<assemblyBatch name=\"MyCastle.Facilities.BatchRegistration.Tests\" useAttributes=\"false\" >"+
                "				<include key=\"other\" component=\"Castle.Facilities.BatchRegistration.Tests.Components.OtherComponent\" />"+
                "			</assemblyBatch>"+
                "		</facility>"+
                "	</facilities>"+
                "</configuration>";

            XmlInterpreter interpreter = new XmlInterpreter(new StaticContentResource(xml));

            interpreter.ProcessResource(interpreter.Source, _kernel.ConfigurationStore);

            _kernel.AddFacility("batchregistration", new BatchRegistrationFacility());
        }
コード例 #16
0
        public void ProperDeserialization()
        {
            var store = new DefaultConfigurationStore();

            var     interpreter = new XmlInterpreter(Xml.Embedded("sample_config_complex.xml"));
            IKernel kernel      = new DefaultKernel();

            interpreter.ProcessResource(interpreter.Source, store, kernel);

            Assert.AreEqual(2, store.GetFacilities().Length);
            Assert.AreEqual(2, store.GetComponents().Length);
            Assert.AreEqual(2, store.GetConfigurationForChildContainers().Length);

            var config    = store.GetFacilityConfiguration(typeof(DummyFacility).FullName);
            var childItem = config.Children["item"];

            Assert.IsNotNull(childItem);
            Assert.AreEqual("value", childItem.Value);

            config = store.GetFacilityConfiguration(typeof(HiperFacility).FullName);
            Assert.IsNotNull(config);
            Assert.AreEqual("value within CDATA section", config.Value);

            config    = store.GetComponentConfiguration("testidcomponent1");
            childItem = config.Children["item"];
            Assert.IsNotNull(childItem);
            Assert.AreEqual("value1", childItem.Value);

            config    = store.GetComponentConfiguration("testidcomponent2");
            childItem = config.Children["item"];
            Assert.IsNotNull(childItem);
            Assert.AreEqual("value2", childItem.Value);

            config = store.GetChildContainerConfiguration("child1");
            Assert.IsNotNull(config);
            Assert.AreEqual(config.Attributes["name"], "child1");
            Assert.AreEqual("<configuration />", config.Value);

            config = store.GetChildContainerConfiguration("child2");
            Assert.IsNotNull(config);
            Assert.AreEqual(config.Attributes["name"], "child2");
            Assert.AreEqual("<configuration />", config.Value);
        }
コード例 #17
0
        public void AddFacilities()
        {
            String xml =
                "<configuration>" +
                "	<facilities>"+
                "		<facility id=\"batchregistration\">"+
                "			<addFacility id=\"facility1\" type=\"Castle.Facilities.BatchRegistration.Tests.Facilities.Facility1, Castle.Facilities.BatchRegistration.Tests\" />"+
                "			<addFacility id=\"facility2\" type=\"Castle.Facilities.BatchRegistration.Tests.Facilities.Facility2, Castle.Facilities.BatchRegistration.Tests\" />"+
                "		</facility>"+
                "	</facilities>"+
                "</configuration>";

            XmlInterpreter interpreter = new XmlInterpreter(new StaticContentResource(xml));

            interpreter.ProcessResource(interpreter.Source, _kernel.ConfigurationStore);

            _kernel.AddFacility("batchregistration", new BatchRegistrationFacility());

            IFacility[] facilities = _kernel.GetFacilities();
            Assert.AreEqual(3, facilities.Length);
        }
コード例 #18
0
        public void UsingAttributes()
        {
            String xml =
                "<configuration>" +
                "	<facilities>"+
                "		<facility id=\"batchregistration\">"+
                "			<assemblyBatch name=\"Castle.Facilities.BatchRegistration.Tests\" useAttributes=\"true\" />"+
                "		</facility>"+
                "	</facilities>"+
                "</configuration>";

            XmlInterpreter interpreter = new XmlInterpreter(new StaticContentResource(xml));

            interpreter.ProcessResource(interpreter.Source, _kernel.ConfigurationStore);

            _kernel.AddFacility("batchregistration", new BatchRegistrationFacility());

            Assert.IsTrue(_kernel.HasComponent("comp1"));
            Assert.IsTrue(_kernel.HasComponent("comp2"));
            Assert.IsTrue(_kernel.HasComponent(typeof(Component1)));
            Assert.IsTrue(_kernel.HasComponent(typeof(Component2)));
        }
コード例 #19
0
        protected void ProcessFolder(Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store,
                                     Castle.MicroKernel.IKernel kernel,
                                     string path)
        {
            foreach (var extraConfig in Directory.GetFiles(path, "*.castle.config"))
            {
                try
                {
                    var interpreter = new XmlInterpreter(extraConfig);
                    interpreter.ProcessResource(interpreter.Source, store, kernel);
                }
                catch (ConfigurationErrorsException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("Failed to load configuration: " + extraConfig, ex);
                }
            }

            Directory.GetDirectories(path).ToList().ForEach(folder => ProcessFolder(store, kernel, folder));
        }
コード例 #20
0
        public void Test_Embedded4()
        {
            var resource          = Xml.Embedded("hasResourceIncludes.xml");
            var interpreter       = new XmlInterpreter(resource);
            var kernel            = new DefaultKernel();
            var resourceSubSystem = kernel.GetSubSystem(SubSystemConstants.ResourceKey) as IResourceSubSystem;
            var processor         = new XmlProcessor(null, resourceSubSystem);
            var assemRes          = resource as AssemblyResource;

            Assert.IsNotNull(assemRes);
            var doc = new XmlDocument();

            using (var stream = resource.GetStreamReader())
            {
                doc.Load(stream);
            }
            var engine = new DefaultXmlProcessorEngine(null, resourceSubSystem);

            engine.PushResource(resource);
            Assert.AreEqual(doc.DocumentElement.InnerText, "");
            var element = processor.Process(doc.DocumentElement);

            engine.PopResource();
        }
コード例 #21
0
        public ActorRuntimeWithCastle(string file)
        {
            XmlInterpreter inter = new XmlInterpreter(file);

            container = new WindsorContainer(inter);
        }
コード例 #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultContainer"/> class.
        /// </summary>
        public DefaultContainer()
            : base()
        {
            // 初始化日志系统的相关组件
            try {
                if (loggerFactory == null)
                {
                    throw new Exception("日志对象没有被初始化");
                }
                IConfigurationInterpreter interpreter = new XmlInterpreter();
                interpreter.ProcessResource(interpreter.Source, Kernel.ConfigurationStore);
                this.Kernel.AddComponentInstance("logger", typeof(ILoggerFactory), loggerFactory);
                logger = loggerFactory.CreateLogger <DefaultContainer>("Framework");
            }
            catch (Exception ex) {
                System.Diagnostics.EventLog.WriteEntry("Framework", "日志启动错误:" + ex.Message, System.Diagnostics.EventLogEntryType.Error);
                throw;
            }

            // 加载服务器端的服务
            try {
                string filename = FileUtility.ConvertToFullPath(@"Uniframework.config");
                logger.Info("开始加载注册表服务");
                this.Kernel.AddComponentInstance("configService", typeof(IConfigurationService), new XMLConfigurationService(filename));

                logger.Info("开始加载嵌入式对象数据库服务");
                AddComponent("ObjectDatabaseService", typeof(IDb4oDatabaseService), typeof(Db4oDatabaseService));

                logger.Info("开始加载事件分发服务");
                AddFacility("eventautowiring", new EventAutoWiringFacility());

                logger.Info("开始加载会话管理服务");
                AddComponent("SessionService", typeof(ISessionService), typeof(SessionService));

                logger.Info("开始加载系统管理服务");
                AddFacility("System.Facility", new SystemFacility());

                logger.Info("开始加载客户端初始化服务");
                AddComponent("InitializeService", typeof(IInitializeService), typeof(InitializeService));

                logger.Info("开始加载远程调用服务");
                AddComponent("DefaultServiceCaller", typeof(IServiceCaller), typeof(DefaultServiceCaller));

                CheckBuiltInService(); // 对远程服务及远程方法进行注入处理

                AbstractExtend[] loadedExtends = LoadFrameworkExtends();

                string[] customServices = LoadFrameworkComponents();

                object[] components = ActivatingComponents();

                WiringEvent();

                foreach (AbstractExtend extend in loadedExtends)
                {
                    extend.LoadFinished(components);
                }

                logger.Info("开始加载应用服务器网关");
                AddComponent("ServiceGateway", typeof(ServiceGateway));

                systemReady = true;
                logger.Info("应用服务器启动完成");
            }
            catch (Exception ex) {
                logger.Fatal("注册组件时发生错误", ex);
            }
        }
コード例 #23
0
 public MindDumpContainer(XmlInterpreter interpreter) : base(interpreter)
 {
     Init();
 }
コード例 #24
0
 public NetBpmWebContainer(XmlInterpreter interpreter)
     : base(interpreter)
 {
     Init();
 }