Inheritance: AbstractSubSystem, IConfigurationStore
コード例 #1
0
		public void ProperDeserialization()
		{
			DefaultConfigurationStore store = new DefaultConfigurationStore();
			XmlInterpreter interpreter = new XmlInterpreter(new ConfigResource());
			interpreter.ProcessResource(interpreter.Source, store);

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

			IConfiguration config = store.GetFacilityConfiguration("testidengine");
			IConfiguration childItem = config.Children["item"];
			Assert.IsNotNull(childItem);
			Assert.AreEqual("value", childItem.Value);

			config = store.GetFacilityConfiguration("testidengine2");
			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);
		}
コード例 #2
0
		public void ProperDeserialization()
		{
			var store = new DefaultConfigurationStore();
			var interpreter = new XmlInterpreter(new ConfigResource());
			IKernel kernel = new DefaultKernel();
			interpreter.ProcessResource(interpreter.Source, store, kernel);

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

			var config = store.GetFacilityConfiguration(typeof(NoopFacility).FullName);
			var childItem = config.Children["item"];
			Assert.IsNotNull(childItem);
			Assert.AreEqual("value", childItem.Value);

			config = store.GetFacilityConfiguration(typeof(Noop2Facility).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);
		}
コード例 #3
0
		public void MissingManifestResourceConfiguration()
		{
			var store = new DefaultConfigurationStore();
			var source = new AssemblyResource("assembly://Castle.Windsor.Tests/missing_config.xml");
			IKernel kernel = new DefaultKernel();
			new XmlInterpreter(source).ProcessResource(source, store, kernel);
		}
コード例 #4
0
		public void SimpleCase()
		{
			String contents = 
				"import Castle.Facilities.AspectSharp.Tests.Components in Castle.Facilities.AspectSharp.Tests " + 
				"import Castle.Facilities.AspectSharp.Tests.Interceptors in Castle.Facilities.AspectSharp.Tests " + 
				" " + 
				" aspect MyAspect for SimpleService " + 
				"   " + 
				"   pointcut method|property(*)" + 
				"     advice(LoggerInterceptor)" + 
				"   end" + 
				"   " + 
				" end ";

			MutableConfiguration config = new MutableConfiguration("facility", contents);

			DefaultConfigurationStore store = new DefaultConfigurationStore();
			store.AddFacilityConfiguration("aop", config);

			WindsorContainer container = new WindsorContainer(store);
			container.AddFacility( "aop", new AspectSharpFacility() );

			container.AddComponent("comp1", typeof(SimpleService));

			SimpleService service = container[ typeof(SimpleService) ] as SimpleService;
			service.DoSomething();
			service.DoSomethingElse();

			Assert.AreEqual( "Enter DoSomething\r\nEnter DoSomethingElse\r\n", 
				LoggerInterceptor.Messages.ToString() );
		}
		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"];
		}
コード例 #6
0
ファイル: BaseTest.cs プロジェクト: atczyc/castle
        public virtual void FixtureSetUp()
        {
            DefaultConfigurationStore store = new DefaultConfigurationStore();
            XmlInterpreter interpreter = new XmlInterpreter(new ConfigResource());
            interpreter.ProcessResource(interpreter.Source, store);

            container = new WindsorContainer(interpreter);
        }
コード例 #7
0
ファイル: CastleFixture.cs プロジェクト: Jo1nes/SolrNet
 public void InvalidProtocol_throws() {
     var configStore = new DefaultConfigurationStore();
     var configuration = new MutableConfiguration("facility");
     configuration.Attribute("type", typeof(SolrNetFacility).AssemblyQualifiedName);
     configuration.CreateChild("solrURL", "ftp://localhost");
     configStore.AddFacilityConfiguration(typeof(SolrNetFacility).FullName, configuration);
     new WindsorContainer(configStore);
 }
コード例 #8
0
ファイル: CastleFixture.cs プロジェクト: Jo1nes/SolrNet
 public void InvalidUrl_throws() {
     var configStore = new DefaultConfigurationStore();
     var configuration = new MutableConfiguration("facility");
     configuration.Attributes.Add("type", typeof(SolrNetFacility).FullName);
     configuration.CreateChild("solrURL", "123");
     configStore.AddFacilityConfiguration(typeof(SolrNetFacility).FullName, configuration);
     new WindsorContainer(configStore);
 }
コード例 #9
0
ファイル: Global.asax.cs プロジェクト: atczyc/castle
		protected void Application_Start(Object sender, EventArgs e)
		{
			DefaultConfigurationStore store = new DefaultConfigurationStore();
			XmlInterpreter interpreter = new XmlInterpreter(new ConfigResource());
			interpreter.ProcessResource(interpreter.Source, store);

            _container = new WindsorContainer(interpreter);
        }
コード例 #10
0
        public void CanLoadModuleImplicit()
        {
            var container = new WindsorContainer();

            var defaultConfigurationStore = new DefaultConfigurationStore();
            FromAssembly.Containing<RemoteEngineContextFactory>().Install(container, defaultConfigurationStore);

            AssertResolvable(container);
        }
コード例 #11
0
ファイル: Fixture.cs プロジェクト: ralescano/castle
		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);
			this.configuration = configurationStore.GetFacilityConfiguration("nhibernatefacility").Children["factory"];
			this.configurationBuilder = new PersistentConfigurationBuilder();
		}
コード例 #12
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"];
		}
コード例 #13
0
        public void CanLoadModuleExplicit()
        {
            var container = new WindsorContainer();

            var defaultConfigurationStore = new DefaultConfigurationStore();
            var ogDotNetModule = new OGDotNetModule();
            ogDotNetModule.Install(container, defaultConfigurationStore);

            AssertResolvable(container);
        }
コード例 #14
0
ファイル: FacilityTests.cs プロジェクト: ruanzx/mausch
 public void setup()
 {
     var store = new DefaultConfigurationStore();
     var solrSharpConfig = new MutableConfiguration("solrsharp");
     solrSharpConfig.Children.Add(new MutableConfiguration("solrUrl", "http://localhost:8983/solr/"));
     solrSharpConfig.Children.Add(new MutableConfiguration("searcherMode", "ReadWrite"));
     store.AddFacilityConfiguration("solrsharp", solrSharpConfig);
     container = new WindsorContainer(store);
     container.AddFacility("solrsharp", new SolrSharpFacility());
 }
コード例 #15
0
		public void CorrectConfigurationMapping()
		{
			DefaultConfigurationStore store = new DefaultConfigurationStore();
			XmlInterpreter interpreter = new XmlInterpreter(ConfigHelper.ResolveConfigPath("sample_config.xml"));
			interpreter.ProcessResource(interpreter.Source, store);

			WindsorContainer container = new WindsorContainer(store);

			container.AddFacility("testidengine", new DummyFacility());
		}
コード例 #16
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);
		}
コード例 #17
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);
		}
コード例 #18
0
        public void Ping_Query()
        {
            var configStore = new DefaultConfigurationStore();
            var configuration = new MutableConfiguration("facility");
            configuration.Attribute("type", typeof(SolrNetFacility).AssemblyQualifiedName);
            configuration.CreateChild("solrURL", "http://localhost:8983/solr");
            configStore.AddFacilityConfiguration(typeof(SolrNetFacility).FullName, configuration);
            var container = new WindsorContainer(configStore);

            var solr = container.Resolve<ISolrOperations<CastleFixture.Document>>();
            solr.Ping();
            Console.WriteLine(solr.Query(SolrQuery.All).Count);
        }
コード例 #19
0
ファイル: ControllerTest.cs プロジェクト: atczyc/castle
		public void SetUp() 
		{
			 _container = null;
			 _homeController = null;
			 _state = null;

			// Config by file
//			_container = new WindsorContainer( new XmlInterpreter( new AppDomainConfigSource("castle")),
//				new XmlInterpreter( "test.config" )
//				);

			DefaultConfigurationStore store = new DefaultConfigurationStore();
			XmlInterpreter interpreter = new XmlInterpreter(new ConfigResource());
			interpreter.ProcessResource(interpreter.Source, store);

			_container = new WindsorContainer( interpreter );

			//-- Config by Code for test
//			_container = new WindsorContainer(new DefaultConfigurationStore());
//
//			MutableConfiguration confignode = new MutableConfiguration("facility");
//
//			IConfiguration assembyView = confignode.Children.Add(new MutableConfiguration("assembyView"));
//
//			_container.Kernel.ConfigurationStore.AddFacilityConfiguration("MVCFacility", confignode);
//			_container.AddFacility("MVCFacility", new MVCFacility());
//
//			_container.AddComponent( "state", typeof(IState),typeof(MyApplicationState));
//			_container.AddComponent( "navigator", typeof(INavigator), typeof(DefaultNavigator));
//			_container.AddComponent( "viewManager", typeof(IViewManager), typeof(MockViewManager));
//			_container.AddComponent( "statePersister", typeof(IStatePersister), typeof(MemoryStatePersister));
//
//			// controllers
//			_container.AddComponent( "HomeController", typeof(HomeController) );
//			_container.AddComponent( "AccountController", typeof(AccountController) );
//
//			// components
//			_container.AddComponent( "ServiceA", typeof(IServiceA), typeof(ServiceA));


			_homeController = _container["HomeController"] as HomeController;
			_state = _homeController.State as MyApplicationState;
		}
コード例 #20
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);
		}
コード例 #21
0
		public void ProperDeserialization()
		{
			DefaultConfigurationStore store = new DefaultConfigurationStore();

			XmlInterpreter interpreter = new XmlInterpreter(ConfigHelper.ResolveConfigPath("sample_config.xml"));
			interpreter.ProcessResource(interpreter.Source, store);

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

			IConfiguration config = store.GetFacilityConfiguration("testidengine");
			IConfiguration childItem = config.Children["item"];
			Assert.IsNotNull(childItem);
			Assert.AreEqual("value", childItem.Value);

			config = store.GetFacilityConfiguration("testidengine2");
			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);
		}
コード例 #22
0
		public void AopInterceptorAndCastleInterceptor()
		{
			String contents = 
				"import Castle.Facilities.AspectSharp.Tests.Components in Castle.Facilities.AspectSharp.Tests " + 
				"import Castle.Facilities.AspectSharp.Tests.Interceptors in Castle.Facilities.AspectSharp.Tests " + 
				" " + 
				" aspect MyAspect for AnotherService " + 
				"   " + 
				"   pointcut method|property(*)" + 
				"     advice(LoggerInterceptor)" + 
				"   end" + 
				"   " + 
				" end ";

			MutableConfiguration config = new MutableConfiguration("facility", contents);

			DefaultConfigurationStore store = new DefaultConfigurationStore();
			store.AddFacilityConfiguration("aop", config);

			WindsorContainer container = new WindsorContainer(store);
			container.AddFacility( "aop", new AspectSharpFacility() );

			container.AddComponent( "interceptor1", typeof(CastleSimpleInterceptor) );
			container.AddComponent("comp1", typeof(SimpleService));
			container.AddComponent("comp2", typeof(IAnotherService), typeof(AnotherService));

			IAnotherService service = container[ typeof(IAnotherService) ] as IAnotherService;
			service.Name = "hammett";
			service.StartWork();

			Assert.AreEqual( "Enter set_Name\r\nEnter StartWork\r\n", 
				LoggerInterceptor.Messages.ToString() );

			CastleSimpleInterceptor interceptor = 
				container[ typeof(CastleSimpleInterceptor) ] as CastleSimpleInterceptor;

			Assert.AreEqual(2, interceptor.Executions);
		}
コード例 #23
0
		public void ComponentIdGetsLoadedFromTheParsedConfiguration() {
			
			DefaultConfigurationStore store = new DefaultConfigurationStore();
			XmlInterpreter interpreter = new XmlInterpreter(ConfigHelper.ResolveConfigPath("sample_config_with_spaces.xml"));
			interpreter.ProcessResource(interpreter.Source, store);

			WindsorContainer container = new WindsorContainer(store);

			IHandler handler = container.Kernel.GetHandler(typeof(ICalcService));
			Assert.AreEqual(Core.LifestyleType.Transient, handler.ComponentModel.LifestyleType);
		}
コード例 #24
0
ファイル: Tests.cs プロジェクト: AlmostTooCool/SolrNet
        public void Ping_Query()
        {
            var configStore = new DefaultConfigurationStore();
            var configuration = new MutableConfiguration("facility");
            configuration.CreateChild("solrURL", "http://localhost:8983/solr");
            configStore.AddFacilityConfiguration("solr", configuration);
            var container = new WindsorContainer(configStore);
            container.AddFacility<SolrNetFacility>("solr");

            var solr = container.Resolve<ISolrOperations<Document>>();
            solr.Ping();
            Console.WriteLine(solr.Query(SolrQuery.All).Count);
        }
コード例 #25
0
ファイル: Tests.cs プロジェクト: AlmostTooCool/SolrNet
 public void InvalidUrl_throws()
 {
     var configStore = new DefaultConfigurationStore();
     var configuration = new MutableConfiguration("facility");
     configuration.CreateChild("solrURL", "123");
     configStore.AddFacilityConfiguration("solr", configuration);
     var container = new WindsorContainer(configStore);
     container.AddFacility<SolrNetFacility>("solr");
 }
コード例 #26
0
		public void ParametersAndServicesBestCase()
		{
			var store = new DefaultConfigurationStore();

			var config = new MutableConfiguration("component");
			var parameters = new MutableConfiguration("parameters");
			config.Children.Add(parameters);
			parameters.Children.Add(new MutableConfiguration("name", "hammett"));
			parameters.Children.Add(new MutableConfiguration("port", "120"));

			store.AddComponentConfiguration("service", config);

			Kernel.ConfigurationStore = store;

			Container.Register(Component.For<A>().Named("a"),
			                   Component.For<ServiceUser2>().Named("service"));

			var service = Container.Resolve<ServiceUser2>("service");

			Assert.IsNotNull(service);
			Assert.IsNotNull(service.AComponent);
			Assert.IsNull(service.BComponent);
			Assert.IsNull(service.CComponent);
			Assert.AreEqual("hammett", service.Name);
			Assert.AreEqual(120, service.Port);
		}
コード例 #27
0
		public void ParametersAndServicesBestCase2()
		{
			DefaultConfigurationStore store = new DefaultConfigurationStore();

			MutableConfiguration config = new MutableConfiguration("component");
			MutableConfiguration parameters = new MutableConfiguration("parameters");
			config.Children.Add(parameters);
			parameters.Children.Add(new MutableConfiguration("name", "hammett"));
			parameters.Children.Add(new MutableConfiguration("port", "120"));
			parameters.Children.Add(new MutableConfiguration("Scheduleinterval", "22"));

			store.AddComponentConfiguration("service", config);

			kernel.ConfigurationStore = store;

			kernel.AddComponent("a", typeof(A));
			kernel.AddComponent("service", typeof(ServiceUser2));

			ServiceUser2 service = (ServiceUser2) kernel["service"];

			Assert.IsNotNull(service);
			Assert.IsNotNull(service.AComponent);
			Assert.IsNull(service.BComponent);
			Assert.IsNull(service.CComponent);
			Assert.AreEqual("hammett", service.Name);
			Assert.AreEqual(120, service.Port);
			Assert.AreEqual(22, service.ScheduleInterval);
		}