CreateChild() public method

public CreateChild ( string name ) : MutableConfiguration
name string
return MutableConfiguration
コード例 #1
0
 public void GlobalJobListeners_with_no_registration_throws()
 {
     var c = new WindsorContainer();
     var config = new MutableConfiguration("facility");
     config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq");
     config.CreateChild("globalJobListeners").CreateChild("item", "${jobli}");
     c.Kernel.ConfigurationStore.AddFacilityConfiguration("quartz", config);
     c.AddFacility("quartz", new QuartzFacility());
     c.Resolve<IScheduler>();
 }
コード例 #2
0
 public void GlobalJobListeners()
 {
     var c = new WindsorContainer();
     var config = new MutableConfiguration("facility");
     config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq");
     config.CreateChild("globalJobListeners").CreateChild("item", "${jobli}");
     c.Kernel.ConfigurationStore.AddFacilityConfiguration("quartz", config);
     c.Register(Component.For<IJobListener>().ImplementedBy<SomeJobListener>().Named("jobli"));
     c.AddFacility("quartz", new QuartzFacility());
     var scheduler = (QuartzNetScheduler)c.Resolve<IScheduler>();
     foreach (IJobListener l in scheduler.GlobalJobListeners)
         Console.WriteLine(l.Name);
     Assert.AreEqual(2, scheduler.GlobalJobListeners.Count);
 }
コード例 #3
0
        public void GlobalTriggerListeners()
        {
            var c = new WindsorContainer();
            var config = new MutableConfiguration("facility");
            config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq");
            config.CreateChild("globalTriggerListeners").CreateChild("item", "${jobli}");
            c.Kernel.ConfigurationStore.AddFacilityConfiguration("quartz", config);

            c.AddComponent("jobli", typeof (ITriggerListener), typeof (SomeTriggerListener));
            c.AddFacility("quartz", new QuartzFacility());

            var scheduler = c.Resolve<IScheduler>() as QuartzNetScheduler;
            foreach (ITriggerListener l in scheduler.GlobalTriggerListeners)
                Console.WriteLine(l.Name);
            Assert.AreEqual(1, scheduler.GlobalTriggerListeners.Count);
        }
コード例 #4
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);
 }
コード例 #5
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);
 }
コード例 #6
0
ファイル: IoC_142.cs プロジェクト: pmcg/Castle.Windsor
		public void ShouldBeAbleToSupplyValueForNullableParamViaCtor_FromConfig()
		{
			var container = new WindsorContainer();
			var configuration = new MutableConfiguration("parameters");
			configuration.CreateChild("foo", "5");
			container.Register(Component.For<ClassTakingNullableViaCtor>().Configuration(configuration));

			container.Resolve<ClassTakingNullableViaCtor>();
		}
コード例 #7
0
 private IConfiguration CreateModuleConfigurationNode()
 {
     var config = new MutableConfiguration("array");
     foreach (Type type in messageModules)
     {
         config.CreateChild("item", "${" + type.FullName + "}");
     }
     return config;
 }
コード例 #8
0
 public void Basic()
 {
     var c = new WindsorContainer();
     var config = new MutableConfiguration("facility");
     config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq");
     c.Kernel.ConfigurationStore.AddFacilityConfiguration("quartz", config);
     c.AddFacility("quartz", new QuartzFacility());
     c.Resolve<IJobScheduler>();
     c.Resolve<IScheduler>();
 }
コード例 #9
0
		public void ParseEndpoints_reflects_entries()
		{
			var config = new MutableConfiguration("entries");
			config.CreateChild("item").Attribute("assembly", "asm1").Attribute("endpoint", "end");

			var reg = new RemoteEndpointRegistry();
			reg.ParseEndpoints(config);

			Assert.AreEqual(1, reg.EntriesCount);
		}
コード例 #10
0
		public void ShouldBeAbleToSupplyValueForNullableParam_FromConfig()
		{
			var container = new WindsorContainer();
			var configuration = new MutableConfiguration("parameters");
			configuration.CreateChild("SomeVal", "5");
			container.Register(Component.For<ClassTakingNullable>().Configuration(configuration));

			var s = container.Resolve<ClassTakingNullable>();
			Assert.IsNotNull(s.SomeVal);
		}
コード例 #11
0
        public void JobListeners()
        {
            var c = new WindsorContainer();
            var config = new MutableConfiguration("facility");
            config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq");
            var listenerConfig = config.CreateChild("jobListeners");
            listenerConfig
                .CreateChild("job")
                .Attribute("name", "someJob")
                .CreateChild("listener", "${jobli}");
            c.Kernel.ConfigurationStore.AddFacilityConfiguration("quartz", config);

            c.AddComponent("jobli", typeof (IJobListener), typeof (SomeJobListener));
            c.AddFacility("quartz", new QuartzFacility());

            var scheduler = c.Resolve<IScheduler>() as QuartzNetScheduler;
            foreach (var l in scheduler.JobListenerNames)
                Console.WriteLine(l);
            var jobli = scheduler.GetJobListener(typeof(SomeJobListener).AssemblyQualifiedName);
            Assert.IsNotNull(jobli);
        }
コード例 #12
0
 public void FacilityRegistersReleasingJobListener()
 {
     using (var c = new WindsorContainer())
     {
         var config = new MutableConfiguration("facility");
         config.CreateChild("quartz");
         c.AddFacility<QuartzFacility>(f => f.Configure(config));
         var scheduler = c.Resolve<IScheduler>();
         //Assert.IsNotNull(scheduler.GlobalJobListeners);
         //Assert.AreEqual(2, scheduler.GlobalJobListeners.Count);
         Assert.IsAssignableFrom(typeof(ReleasingJobListener), scheduler.ListenerManager.GetJobListeners()[0]);
     }
 }
コード例 #13
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);
        }
コード例 #14
0
ファイル: ARATMTests.cs プロジェクト: ruanzx/mausch
        public void tt()
        {
            var container = new WindsorContainer();
            var facilityConfig = new MutableConfiguration("facility");
            var assemblies = facilityConfig.CreateChild("assemblies");
            assemblies.CreateChild("item", GetType().Assembly.FullName);
            var nhConfig = facilityConfig.CreateChild("config");
            AddConfig(nhConfig, Environment.ConnectionDriver, typeof(SQLite20Driver).FullName);
            AddConfig(nhConfig, Environment.Dialect, typeof(SQLiteDialect).FullName);
            AddConfig(nhConfig, Environment.ConnectionProvider, typeof(DriverConnectionProvider).FullName);
            AddConfig(nhConfig, Environment.ProxyFactoryFactoryClass, typeof(ProxyFactoryFactory).AssemblyQualifiedName);
            AddConfig(nhConfig, Environment.ConnectionString, "Data Source=test.db;Version=3;New=True;");
            container.Kernel.ConfigurationStore.AddFacilityConfiguration("ar", facilityConfig);
            var arFacility = new ActiveRecordFacility();
            container.AddFacility("ar", arFacility);
            container.AddFacility<TransactionFacility>();

            ActiveRecordStarter.CreateSchema();

            container.AddComponent<TransactionalService>();
            container.Resolve<TransactionalService>().DoSomething();

            Assert.IsFalse(ActiveRecordMediator<Person>.Exists());
        }
コード例 #15
0
        public void Basic()
        {
            using (var c = new WindsorContainer())
            {
                var config = new MutableConfiguration("facility");
                config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq");
                c.AddFacility<QuartzFacility>(f => f.Configure(config));
                var js = c.Resolve<IJobScheduler>();
                var sched = c.Resolve<IScheduler>();
                var factory = c.Resolve<IJobFactory>();

                Assert.IsTrue(js is QuartzNetSimpleScheduler);
                Assert.IsTrue(sched is QuartzNetScheduler);
                Assert.IsTrue(factory is WindsorJobFactory);
            }
        }
コード例 #16
0
 public void DisposableJobIsDisposed()
 {
     using (var c = new WindsorContainer())
     {
         c.Register(Component.For<DisposableJob>().LifeStyle.Transient);
         var config = new MutableConfiguration("facility");
         config.CreateChild("quartz");
         c.AddFacility<QuartzFacility>(f => f.Configure(config));
         var scheduler = c.Resolve<IScheduler>();
         var jobDetail = JobBuilder.Create<DisposableJob>().WithIdentity("somejob").Build();
         var trigger = TriggerBuilder.Create().WithIdentity("sometrigger").WithSimpleSchedule(s => s.WithIntervalInSeconds(1)).Build();
         scheduler.ScheduleJob(jobDetail, trigger);
         Assert.IsFalse(DisposableJob.Disposed);
         scheduler.Start();
         Thread.Sleep(1000);
         Assert.IsTrue(DisposableJob.Disposed);
     }
 }
コード例 #17
0
        public static void Configure(IWindsorContainer container, IList<string> assembliesToLoad)
        {
            var facility = new MutableConfiguration("facility");
            facility.Attributes.Add("id", "nhibernatefacility");
            facility.Attributes.Add("isWeb", "isWeb");
            facility.Attributes.Add("defaultFlushMode", "Commit");
            var factory = facility.CreateChild("factory");
            factory.Attributes.Add("id", "nhibernate.factory");
            var settings = factory.CreateChild("settings");

            CreateItem(settings, "connection.connection_string", Config.PortalConnectionString);
            CreateItem(settings, "connection.provider", "NHibernate.Connection.DriverConnectionProvider");
            CreateItem(settings, "connection.driver_class", "NHibernate.Driver.MySqlDataDriver");
            CreateItem(settings, "dialect", "NHibernate.Dialect.MySQL5Dialect");
            CreateItem(settings, "proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
            CreateItem(settings, "show_sql", Config.LogSqlQueries);
            var assemblies = factory.CreateChild("assemblies");
            foreach (var assebly in assembliesToLoad)
            {
                assemblies.CreateChild("assembly", assebly);
            }
            container.Kernel.ConfigurationStore.AddFacilityConfiguration("nHibernateFacility", facility);
            container.AddFacility<Castle.Facilities.NHibernateIntegration.NHibernateFacility>("nHibernateFacility");
        }
コード例 #18
0
		public void Wiring_WhenPublisherHasAProxy_ListenerShouldStillGetTheEvents()
		{
			MutableConfiguration config = new MutableConfiguration("component");
			config.
				CreateChild("subscribers").
					CreateChild("subscriber").
					Attribute("id", "listener").
					Attribute("event", "Event").
					Attribute("handler", "OnPublish");
			store.AddComponentConfiguration("publisher", config);

			container.AddFacility("event", new EventWiringFacility());

			// Registers interceptor as component
			container.Register(Component.For<MyInterceptor>().Named("my.interceptor"));
			
			container.Register(Component.For<SimpleListener>().Named("listener"));
			
			// Publisher has a reference to interceptor
			container.Register(
				Component.For<SimplePublisher>().
					Named("publisher").
					Interceptors(new InterceptorReference("my.interceptor")).First);

			// Triggers events
			SimplePublisher publisher = container.Resolve<SimplePublisher>();
			publisher.Trigger();

			MyInterceptor interceptor = container.Resolve<MyInterceptor>();
			Assert.AreEqual(1, interceptor.Intercepted);

			// Assert that event was caught
			SimpleListener listener = container.Resolve<SimpleListener>();
			Assert.IsTrue(listener.Listened);
			Assert.AreSame(publisher, listener.Sender);
		}
コード例 #19
0
 private void AddDefaultFactory(MutableConfiguration config)
 {
     config.CreateChild("factory").Attribute("id", "nhibernate-factory.default");
 }
コード例 #20
0
        public void GlobalTriggerListeners()
        {
            using (var c = new WindsorContainer())
            {
                var config = new MutableConfiguration("facility");
                config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq");
                config.CreateChild("globalTriggerListeners").CreateChild("item", "${jobli}");
                c.Register(Component.For<ITriggerListener>().ImplementedBy<SomeTriggerListener>().Named("jobli"));
                c.AddFacility<QuartzFacility>(f => f.Configure(config));

                var scheduler = (QuartzNetScheduler)c.Resolve<IScheduler>();
                foreach (ITriggerListener l in scheduler.ListenerManager.GetTriggerListeners())
                    Console.WriteLine(l.Name);
                Assert.AreEqual(1, scheduler.ListenerManager.GetTriggerListeners().Count);
            }
        }
コード例 #21
0
        public IConfiguration ToIConfiguration()
        {
            var config = new MutableConfiguration("rhino.esb");

            var busConfig = config.CreateChild("bus")
                .Attribute("endpoint", Endpoint)
                .Attribute("threadCount", ThreadCount.ToString())
                .Attribute("numberOfRetries", NumberOfRetries.ToString());

            if (string.IsNullOrEmpty(LoadBalancerEndpoint) == false)
                busConfig.Attribute("loadBalancerEndpoint", LoadBalancerEndpoint);

            if (string.IsNullOrEmpty(LogEndpoint) == false)
                busConfig.Attribute("logEndpoint", LogEndpoint);

            var messagesConfig = config.CreateChild("messages");

            foreach (var message in Messages)
            {
                messagesConfig.CreateChild("add")
                    .Attribute("name", message.Key)
                    .Attribute("endpoint", message.Value);
            }

            return config;
        }
コード例 #22
0
        public void GlobalJobListeners_with_no_registration_throws()
        {
            using (var c = new WindsorContainer())
            {
                var config = new MutableConfiguration("facility");
                config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq");
                config.CreateChild("globalJobListeners").CreateChild("item", "${jobli}");
                c.AddFacility<QuartzFacility>(f => f.Configure(config));

                c.Resolve<IScheduler>();
            }
        }
コード例 #23
0
        public void TriggerListeners()
        {
            using (var c = new WindsorContainer())
            {
                var config = new MutableConfiguration("facility");
                config.CreateChild("quartz").CreateChild("item", "qwe").Attribute("key", "qq");
                var listenerConfig = config.CreateChild("triggerListeners");
                listenerConfig
                    .CreateChild("job")
                    .Attribute("name", "someJob")
                    .CreateChild("listener", "${trigli}");

                c.Register(Component.For<ITriggerListener>().ImplementedBy<SomeTriggerListener>().Named("trigli"));
                c.AddFacility<QuartzFacility>(f => f.Configure(config));

                var scheduler = (QuartzNetScheduler)c.Resolve<IScheduler>();
                foreach (var l in scheduler.ListenerManager.GetTriggerListeners())
                    Console.WriteLine(l);
                var trigli = scheduler.ListenerManager.GetTriggerListener(typeof(SomeTriggerListener).AssemblyQualifiedName);
                Assert.IsNotNull(trigli);
            }
        }
コード例 #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
 private void AddFactory(MutableConfiguration config, String alias)
 {
     config.CreateChild("factory").Attribute("id", String.Format("nhibernate-factory.{0}", alias)).Attribute("alias", alias);
 }
コード例 #26
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");
 }
コード例 #27
0
		public void Can_satisfy_nullable_property_dependency()
		{
			var container = new WindsorContainer();
			var configuration = new MutableConfiguration("parameters");
			configuration.CreateChild("SomeVal", "5");
			container.Register(Component.For<HasNullableIntProperty>().Configuration(configuration));

			var s = container.Resolve<HasNullableIntProperty>();
			Assert.IsNotNull(s.SomeVal);
		}
コード例 #28
0
		public void Can_satisfy_nullable_ctor_dependency()
		{
			var container = new WindsorContainer();
			var configuration = new MutableConfiguration("parameters");
			configuration.CreateChild("foo", "5");
			container.Register(Component.For<HasNullableDoubleConstructor>().Configuration(configuration));

			container.Resolve<HasNullableDoubleConstructor>();
		}
		public void DictionaryWithDifferentValueTypes()
		{
			var config = new MutableConfiguration("dictionary");

			config.CreateChild("entry")
				.Attribute("key", "intentry")
				.Attribute("valueType", "System.Int32, mscorlib")
				.Value = "123";

			config.CreateChild("entry")
				.Attribute("key", "values")
				.Attribute("valueType", "System.Int32[], mscorlib")
				.CreateChild("array")
				.Attribute("type", "System.Int32, mscorlib")
				.CreateChild("item", "400");

			var dict =
				(IDictionary)converter.PerformConversion(config, typeof(IDictionary));

			Assert.IsNotNull(dict);

			Assert.AreEqual(123, dict["intentry"]);
			var values = (int[])dict["values"];
			Assert.IsNotNull(values);
			Assert.AreEqual(1, values.Length);
			Assert.AreEqual(400, values[0]);
		}
コード例 #30
0
 private static void CreateItem(MutableConfiguration parent, string key, string value)
 {
     var item = parent.CreateChild("item");
     item.Attributes.Add("key", key);
     item.Value = value;
 }