本文整理汇总了C#中Castle.Core.Configuration.MutableConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# MutableConfiguration类的具体用法?C# MutableConfiguration怎么用?C# MutableConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MutableConfiguration类属于Castle.Core.Configuration命名空间,在下文中一共展示了MutableConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: UnsatisfiedConfigValues
public void UnsatisfiedConfigValues()
{
MutableConfiguration config = new MutableConfiguration("component");
MutableConfiguration parameters = new MutableConfiguration("parameters");
config.Children.Add(parameters);
parameters.Children.Add(new MutableConfiguration("name", "hammett"));
kernel.ConfigurationStore.AddComponentConfiguration("customer", config);
kernel.Register(Component.For(typeof(CustomerImpl2)).Named("key"));
var exception =
Assert.Throws(typeof(HandlerException), () =>
{
object instance = kernel["key"];
});
var expectedMessage =
string.Format(
"Can't create component 'key' as it has dependencies to be satisfied. {0}key is waiting for the following dependencies: {0}{0}" +
"Keys (components with specific keys){0}- name which was not registered. {0}- address which was not registered. {0}" +
"- age which was not registered. {0}",
Environment.NewLine);
Assert.AreEqual(expectedMessage, exception.Message);
}
开发者ID:gschuager,项目名称:Castle.Windsor,代码行数:26,代码来源:UnsatisfiedDependenciesTestCase.cs
示例2: SetUp
public void SetUp()
{
application = new Application();
uncaughtException = null;
container = new WindsorContainer();
container.AddFacility<SynchronizeFacility>()
.Register(Component.For<SynchronizationContext>(),
Component.For<AsynchronousContext>(),
Component.For<DummyWindow>().Named("Dummy").Activator<DummyFormActivator>(),
Component.For<IDummyWindow>().ImplementedBy<DummyWindow>(),
Component.For<ClassUsingWindowInWindowsContext>(),
Component.For<ClassUsingWindowInAmbientContext>(),
Component.For(typeof(IClassUsingDepedenecyContext<>)).ImplementedBy(typeof(ClassUsingDispatcherContext<>)),
Component.For<IWorker>().ImplementedBy<SimpleWorker>(),
Component.For<IWorkerWithOuts>().ImplementedBy<AsynchronousWorker>(),
Component.For<ManualWorker>()
);
var componentNode = new MutableConfiguration("component");
componentNode.Attributes[Constants.SynchronizedAttrib] = "true";
var synchronizeNode = new MutableConfiguration("synchronize");
synchronizeNode.Attributes["contextType"] = typeof(DispatcherSynchronizationContext).AssemblyQualifiedName;
var doWorkMethod = new MutableConfiguration("method");
doWorkMethod.Attributes["name"] = "DoWork";
doWorkMethod.Attributes["contextType"] = typeof(DispatcherSynchronizationContext).AssemblyQualifiedName;
synchronizeNode.Children.Add(doWorkMethod);
componentNode.Children.Add(synchronizeNode);
container.Kernel.ConfigurationStore.AddComponentConfiguration("class.needing.context", componentNode);
container.Register(Component.For<ClassUsingWindow>().Named("class.needing.context"));
}
开发者ID:castleproject,项目名称:Windsor,代码行数:33,代码来源:DispatcherObjectTestCase.cs
示例3: TestComponentWithNoInterface
public void TestComponentWithNoInterface()
{
IKernel kernel = new DefaultKernel();
kernel.ComponentCreated += new ComponentInstanceDelegate(OnNoInterfaceStartableComponentStarted);
MutableConfiguration compNode = new MutableConfiguration("component");
compNode.Attributes["id"] = "b";
compNode.Attributes["startable"] = "true";
compNode.Attributes["startMethod"] = "Start";
compNode.Attributes["stopMethod"] = "Stop";
kernel.ConfigurationStore.AddComponentConfiguration("b", compNode);
kernel.AddFacility("startable", new StartableFacility());
kernel.Register(Component.For(typeof(NoInterfaceStartableComponent)).Named("b"));
Assert.IsTrue(startableCreatedBeforeResolved, "Component was not properly started");
NoInterfaceStartableComponent component = kernel["b"] as NoInterfaceStartableComponent;
Assert.IsNotNull(component);
Assert.IsTrue(component.Started);
Assert.IsFalse(component.Stopped);
kernel.ReleaseComponent(component);
Assert.IsTrue(component.Stopped);
}
开发者ID:gschuager,项目名称:Castle.Windsor,代码行数:27,代码来源:StartableFacilityTestCase.cs
示例4: ResolvingPrimitivesThroughProperties
public void ResolvingPrimitivesThroughProperties()
{
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("address", "something"));
parameters.Children.Add(new MutableConfiguration("age", "25"));
kernel.ConfigurationStore.AddComponentConfiguration("customer", config);
kernel.AddComponent("customer", typeof (ICustomer), typeof (CustomerImpl));
expectedClient = kernel.GetHandler("customer").ComponentModel;
expectedModels = new List<DependencyModel>();
foreach (PropertySet prop in kernel.GetHandler("customer").ComponentModel.Properties)
{
expectedModels.Add(prop.Dependency);
}
ICustomer customer = (ICustomer) kernel["customer"];
Assert.IsNotNull(customer);
}
开发者ID:AGiorgetti,项目名称:Castle.InversionOfControl,代码行数:26,代码来源:EventTests.cs
示例5: SetUp
public void SetUp()
{
uncaughtException = null;
container = new WindsorContainer();
container.AddFacility("sync.facility", new SynchronizeFacility());
container.AddComponent("sync.context", typeof(SynchronizationContext));
container.AddComponent("dummy.form.class", typeof(DummyForm));
container.AddComponent("dummy.form.service", typeof(IDummyForm), typeof(DummyForm));
container.AddComponent("class.in.context", typeof(ClassUsingFormInContext));
container.AddComponent("sync.class.no.context", typeof(SyncClassWithoutContext));
container.AddComponent("sync.class.override.context", typeof(SyncClassOverrideContext));
MutableConfiguration componentNode = new MutableConfiguration("component");
componentNode.Attributes[Constants.SynchronizedAttrib] = "true";
MutableConfiguration synchronizeNode = new MutableConfiguration("synchronize");
synchronizeNode.Attributes["contextType"] = typeof(WindowsFormsSynchronizationContext).AssemblyQualifiedName;
MutableConfiguration doWorkMethod = new MutableConfiguration("method");
doWorkMethod.Attributes["name"] = "DoWork";
doWorkMethod.Attributes["contextType"] = typeof(WindowsFormsSynchronizationContext).AssemblyQualifiedName;
synchronizeNode.Children.Add(doWorkMethod);
componentNode.Children.Add(synchronizeNode);
container.AddComponent("generic.class.in.context", typeof(IClassUsingContext<>),
typeof(ClassUsingContext<>));
container.Kernel.ConfigurationStore.AddComponentConfiguration("class.needing.context", componentNode);
container.AddComponent("class.needing.context", typeof(ClassUsingForm));
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:29,代码来源:SynchronizeFacilityTest.cs
示例6: PopulateBusConfiguration
protected override void PopulateBusConfiguration(MutableConfiguration busConfig)
{
base.PopulateBusConfiguration(busConfig);
if (string.IsNullOrEmpty(Path) == false)
busConfig.Attribute("path", Path);
}
开发者ID:helge,项目名称:rhino-esb,代码行数:7,代码来源:RhinoQueuesHostConfiguration.cs
示例7: ComplexConfigurationParameter
public void ComplexConfigurationParameter()
{
var key = "key";
var value1 = "value1";
var value2 = "value2";
var confignode = new MutableConfiguration(key);
IConfiguration parameters = new MutableConfiguration("parameters");
confignode.Children.Add(parameters);
IConfiguration complexParam = new MutableConfiguration("complexparam");
parameters.Children.Add(complexParam);
IConfiguration complexNode = new MutableConfiguration("complexparametertype");
complexParam.Children.Add(complexNode);
complexNode.Children.Add(new MutableConfiguration("mandatoryvalue", value1));
complexNode.Children.Add(new MutableConfiguration("optionalvalue", value2));
kernel.ConfigurationStore.AddComponentConfiguration(key, confignode);
kernel.Register(Component.For(typeof(ClassWithComplexParameter)).Named(key));
var instance = kernel.Resolve<ClassWithComplexParameter>(key);
Assert.IsNotNull(instance);
Assert.IsNotNull(instance.ComplexParam);
Assert.AreEqual(value1, instance.ComplexParam.MandatoryValue);
Assert.AreEqual(value2, instance.ComplexParam.OptionalValue);
}
开发者ID:n2cms,项目名称:Castle.Windsor,代码行数:30,代码来源:ConfigurationTestCase.cs
示例8: BuildContainer
protected override WindsorContainer BuildContainer()
{
uncaughtException = null;
var container = new WindsorContainer();
container.AddFacility<SynchronizeFacility>()
.Register(Component.For<SynchronizationContext>(),
Component.For<AsynchronousContext>(),
Component.For<DummyForm>().Named("Dummy")
.Activator<DummyFormActivator>(),
Component.For<IDummyForm>().ImplementedBy<DummyForm>(),
Component.For<ClassUsingFormInWindowsContext>(),
Component.For<ClassUsingFormInAmbientContext>(),
Component.For<SyncClassWithoutContext>(),
Component.For<SyncClassOverrideContext>(),
Component.For(typeof(IClassUsingContext<>)).ImplementedBy(typeof(ClassUsingContext<>)),
Component.For<IWorker>().ImplementedBy<SimpleWorker>(),
Component.For<IWorkerWithOuts>().ImplementedBy<AsynchronousWorker>(),
Component.For<ManualWorker>()
);
var componentNode = new MutableConfiguration("component");
componentNode.Attributes[Constants.SynchronizedAttrib] = "true";
var synchronizeNode = new MutableConfiguration("synchronize");
synchronizeNode.Attributes["contextType"] = typeof(WindowsFormsSynchronizationContext).AssemblyQualifiedName;
var doWorkMethod = new MutableConfiguration("method");
doWorkMethod.Attributes["name"] = "DoWork";
doWorkMethod.Attributes["contextType"] = typeof(WindowsFormsSynchronizationContext).AssemblyQualifiedName;
synchronizeNode.Children.Add(doWorkMethod);
componentNode.Children.Add(synchronizeNode);
container.Kernel.ConfigurationStore.AddComponentConfiguration("class.needing.context", componentNode);
container.Register(Component.For<ClassUsingForm>().Named("class.needing.context"));
return container;
}
开发者ID:thefringeninja,项目名称:Castle.Windsor,代码行数:35,代码来源:SynchronizeFacilityTestFixture.cs
示例9: ConstructorWithArrayParameter
public void ConstructorWithArrayParameter()
{
var confignode = new MutableConfiguration("key");
IConfiguration parameters = new MutableConfiguration("parameters");
confignode.Children.Add(parameters);
IConfiguration hosts = new MutableConfiguration("hosts");
parameters.Children.Add(hosts);
IConfiguration array = new MutableConfiguration("array");
hosts.Children.Add(array);
array.Children.Add(new MutableConfiguration("item", "castle"));
array.Children.Add(new MutableConfiguration("item", "uol"));
array.Children.Add(new MutableConfiguration("item", "folha"));
kernel.ConfigurationStore.AddComponentConfiguration("key", confignode);
kernel.Register(Component.For(typeof(ClassWithConstructors)).Named("key"));
var instance = kernel.Resolve<ClassWithConstructors>("key");
Assert.IsNotNull(instance);
Assert.IsNull(instance.Host);
Assert.AreEqual("castle", instance.Hosts[0]);
Assert.AreEqual("uol", instance.Hosts[1]);
Assert.AreEqual("folha", instance.Hosts[2]);
}
开发者ID:n2cms,项目名称:Castle.Windsor,代码行数:26,代码来源:ConfigurationTestCase.cs
示例10: SimpleCase
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() );
}
开发者ID:ralescano,项目名称:castle,代码行数:31,代码来源:AspectSharpFacilityTestCase.cs
示例11: InvalidProtocol_throws
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);
}
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:8,代码来源:CastleFixture.cs
示例12: InvalidUrl_throws
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);
}
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:8,代码来源:CastleFixture.cs
示例13: AddComponent
private void AddComponent(string key, Type service, Type type, string factoryMethod)
{
var config = new MutableConfiguration(key);
config.Attributes["factoryId"] = "factory";
config.Attributes["factoryCreate"] = factoryMethod;
Container.Kernel.ConfigurationStore.AddComponentConfiguration(key, config);
Container.Kernel.Register(Component.For(service).ImplementedBy(type).Named(key));
}
开发者ID:dohansen,项目名称:Windsor,代码行数:8,代码来源:FactorySupportTestCase.cs
示例14: AddComponent
private void AddComponent(string key, Type service, Type type, string factoryMethod)
{
MutableConfiguration config = new MutableConfiguration(key);
config.Attributes["factoryId"] = "factory";
config.Attributes["factoryCreate"] = factoryMethod;
container.Kernel.ConfigurationStore.AddComponentConfiguration(key, config);
container.Kernel.AddComponent(key, service, type);
}
开发者ID:AGiorgetti,项目名称:Castle.InversionOfControl,代码行数:8,代码来源:FactorySupportTestCase.cs
示例15: AddComponent
private ComponentModel AddComponent(string key, Type type, string factoryMethod)
{
MutableConfiguration config = new MutableConfiguration(key);
config.Attributes["factoryId"] = "a";
config.Attributes["factoryCreate"] = factoryMethod;
kernel.ConfigurationStore.AddComponentConfiguration(key, config);
kernel.AddComponent(key, type);
return kernel.GetHandler(key).ComponentModel;
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:9,代码来源:FactorySupportTestCase.cs
示例16: AddParameter
protected void AddParameter(ComponentModel model, String name, IConfiguration value)
{
var parameters = EnsureParametersConfiguration(model);
var parameter = new MutableConfiguration(name);
parameter.Children.Add(value);
parameters.Children.Add(parameter);
}
开发者ID:castleproject,项目名称:Windsor,代码行数:9,代码来源:AbstractPropertyDescriptor.cs
示例17: CreateModuleConfigurationNode
private IConfiguration CreateModuleConfigurationNode()
{
var config = new MutableConfiguration("array");
foreach (Type type in messageModules)
{
config.CreateChild("item", "${" + type.FullName + "}");
}
return config;
}
开发者ID:BiYiTuan,项目名称:rhino-esb,代码行数:9,代码来源:RhinoServiceBusFacility.cs
示例18: ShouldBeAbleToSupplyValueForNullableParamViaCtor_FromConfig
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>();
}
开发者ID:pmcg,项目名称:Castle.Windsor,代码行数:9,代码来源:IoC_142.cs
示例19: EnsureParametersConfiguration
private IConfiguration EnsureParametersConfiguration(ComponentModel model)
{
var parameters = model.Configuration.Children["parameters"];
if (parameters == null)
{
parameters = new MutableConfiguration("parameters");
model.Configuration.Children.Add(parameters);
}
return parameters;
}
开发者ID:castleproject,项目名称:Windsor,代码行数:10,代码来源:AbstractPropertyDescriptor.cs
示例20: FACILITIES66
public void FACILITIES66()
{
container = new WindsorContainer();
IConfiguration confignode = new MutableConfiguration("facility");
confignode.Children.Add(new MutableConfiguration("arfacility"));
container.Kernel.ConfigurationStore.AddFacilityConfiguration("arfacility", confignode);
container.AddFacility("arfacility", new ActiveRecordFacility());
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:10,代码来源:BugTestCase.cs
注:本文中的Castle.Core.Configuration.MutableConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论