private AddComponentConfiguration ( String key, IConfiguration config ) : void | ||
key | String | |
config | IConfiguration | |
return | void |
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); }
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); }