本文整理汇总了C#中Castle.MicroKernel.DefaultKernel类的典型用法代码示例。如果您正苦于以下问题:C# DefaultKernel类的具体用法?C# DefaultKernel怎么用?C# DefaultKernel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultKernel类属于Castle.MicroKernel命名空间,在下文中一共展示了DefaultKernel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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
示例2: SimulateRegistration
public static ICollection<IHandler> SimulateRegistration(this IRegistration reg)
{
using (var kernel = new DefaultKernel()) {
kernel.Register(reg);
return kernel.GetAssignableHandlers(typeof (object));
}
}
开发者ID:ruanzx,项目名称:mausch,代码行数:7,代码来源:IRegistrationExtensions.cs
示例3: MissingManifestResourceConfiguration
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);
}
开发者ID:castleproject,项目名称:Windsor,代码行数:7,代码来源:ConfigXmlInterpreterTestCase.cs
示例4: ProperDeserialization
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);
}
开发者ID:RookieX,项目名称:Windsor,代码行数:29,代码来源:AppDomainConfigurationStoreTestCase.cs
示例5: Starts_component_without_start_method
public void Starts_component_without_start_method()
{
ClassWithInstanceCount.InstancesCount = 0;
IKernel kernel = new DefaultKernel();
kernel.AddFacility<StartableFacility>(f => f.DeferredTryStart());
kernel.Register(Component.For<ClassWithInstanceCount>().Start());
Assert.AreEqual(1, ClassWithInstanceCount.InstancesCount);
}
开发者ID:HEskandari,项目名称:Castle.InversionOfControl,代码行数:8,代码来源:StartableFacilityTestCase.cs
示例6: current_property_exposes_the_correct_resolver
public void current_property_exposes_the_correct_resolver()
{
var kernel = new DefaultKernel();
var resolver = new CastleDependencyResolver(kernel);
GlobalHost.DependencyResolver = resolver;
Assert.That(CastleDependencyResolver.Current, Is.EqualTo(GlobalHost.DependencyResolver));
}
开发者ID:stormid,项目名称:signalR.Castle,代码行数:9,代码来源:CastleDependencyResolverTests.cs
示例7: tt
public void tt()
{
var kernel = new DefaultKernel();
kernel.Register(AllTypes.Pick()
.FromAssembly(Assembly.GetExecutingAssembly())
.WithService.FirstInterface());
kernel.Resolve<ISomeInterface>();
}
开发者ID:ruanzx,项目名称:mausch,代码行数:9,代码来源:RegTests.cs
示例8: get_service_returns_null_for_unregistered_service
public void get_service_returns_null_for_unregistered_service()
{
var kernel = new DefaultKernel();
var resolver = new CastleDependencyResolver(kernel);
var service = resolver.GetService(typeof(object));
Assert.That(service, Is.Null);
}
开发者ID:stormid,项目名称:signalR.Castle,代码行数:9,代码来源:CastleDependencyResolverTests.cs
示例9: get_services_returns_empty_enumerable_for_unregistered_service
public void get_services_returns_empty_enumerable_for_unregistered_service()
{
var kernel = new DefaultKernel();
var resolver = new CastleDependencyResolver(kernel);
var services = resolver.GetServices(typeof(object));
Assert.That(services.Count(), Is.EqualTo(0));
}
开发者ID:stormid,项目名称:signalR.Castle,代码行数:9,代码来源:CastleDependencyResolverTests.cs
示例10: Application_Start
protected void Application_Start(object sender, EventArgs e) {
var kernel = new DefaultKernel();
kernel.Register(Component.For<HttpContextBase>()
.LifeStyle.Transient
.UsingFactoryMethod(() => new HttpContextWrapper(HttpContext.Current)));
kernel.Register(Component.For<SomeService>()
.LifeStyle.HybridPerWebRequestTransient());
kernel.Resolve<SomeService>();
}
开发者ID:kujotx,项目名称:Castle.Windsor.Lifestyles,代码行数:9,代码来源:Global.asax.cs
示例11: Main
public static void Main(string[] args)
{
IKernel kernel = new DefaultKernel();
kernel.AddFacility("non.opt.props", new NonOptionalPropertiesFacility());
kernel.AddComponent("sql.connmng", typeof(SqlConnectionManager));
SqlConnectionManager connManager = (SqlConnectionManager) kernel["sql.connmng"];
}
开发者ID:ralescano,项目名称:castle,代码行数:10,代码来源:App.cs
示例12: AddChildKernelToTwoParentsThrowsException
public void AddChildKernelToTwoParentsThrowsException()
{
IKernel kernel2 = new DefaultKernel();
IKernel subkernel = new DefaultKernel();
Kernel.AddChildKernel(subkernel);
Assert.AreEqual(Kernel, subkernel.Parent);
kernel2.AddChildKernel(subkernel);
}
开发者ID:castleproject,项目名称:Windsor,代码行数:11,代码来源:SubContainersTestCase.cs
示例13: Kernel_should_select_ctor_with_available_dependencies
public void Kernel_should_select_ctor_with_available_dependencies()
{
var kernel = new DefaultKernel();
kernel.AddComponent<Service>();
kernel.AddComponent<ComponentX>();
kernel.AddComponent<ComponentY>();
var service = kernel.Resolve<Service>();
Assert.IsNull(service.A);
Assert.IsNotNull(service.X);
Assert.IsNotNull(service.Y);
}
开发者ID:ruanzx,项目名称:mausch,代码行数:11,代码来源:MultipleConstructorsAgain.cs
示例14: Should_Dispose_From_Containers
public virtual void Should_Dispose_From_Containers()
{
DefaultKernel disposableKernel = new DefaultKernel();
using (var disposableLocater = new SiegeContainer(new WindsorAdapter.WindsorAdapter(disposableKernel)))
{
disposableLocater.Register(Given<ITestInterface>.Then<TestCase1>());
Assert.IsTrue(disposableLocater.GetInstance<ITestInterface>() is TestCase1);
}
Assert.IsFalse(disposableKernel.HasComponent(typeof(ITestInterface)));
}
开发者ID:dtdimi,项目名称:Siege,代码行数:11,代码来源:WindsorAdapterTests.cs
示例15: get_services_returns_registered_service
public void get_services_returns_registered_service()
{
var kernel = new DefaultKernel();
kernel.Register(Component.For<object>().Instance(new object()));
var resolver = new CastleDependencyResolver(kernel);
var services = resolver.GetServices(typeof(object));
Assert.That(services.Count(), Is.EqualTo(1));
}
开发者ID:stormid,项目名称:signalR.Castle,代码行数:11,代码来源:CastleDependencyResolverTests.cs
示例16: CorrectConfigurationMapping
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);
}
开发者ID:castleproject,项目名称:Windsor,代码行数:11,代码来源:ConfigXmlInterpreterTestCase.cs
示例17: ComponentIdGetsLoadedFromTheParsedConfiguration
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);
}
开发者ID:castleproject,项目名称:Windsor,代码行数:12,代码来源:ConfigXmlInterpreterTestCase.cs
示例18: FacilityConfig_is_not_null
public void FacilityConfig_is_not_null()
{
using (var c = new DefaultKernel())
{
const string facilityKey = "hiper";
var config = new MutableConfiguration("facility");
c.ConfigurationStore.AddFacilityConfiguration(facilityKey, config);
var facility = new HiperFacility();
c.AddFacility(facilityKey, facility);
Assert.IsTrue(facility.Initialized);
}
}
开发者ID:RookieX,项目名称:Windsor,代码行数:12,代码来源:IoC-334.cs
示例19: DoesNotResolveArraysByDefault
public void DoesNotResolveArraysByDefault()
{
var kernel = new DefaultKernel();
kernel.Register(
Component.For<Thing>(),
Component.For<ISubThing>().ImplementedBy<First>(),
Component.For<ISubThing>().ImplementedBy<Second>(),
Component.For<ISubThing>().ImplementedBy<Third>()
);
var thing = kernel.Resolve<Thing>();
}
开发者ID:somlea-george,项目名称:sutekishop,代码行数:13,代码来源:ArrayResolverTests.cs
示例20: LoadWindsorAssembly
public void LoadWindsorAssembly()
{
IKernel kernel = new DefaultKernel();
kernel.AddComponent( "A", typeof(AssemblyResolverComponent) );
AssemblyResolverComponent comp = (AssemblyResolverComponent) kernel["A"];
comp.Start();
Type windsor = Type.GetType(
"Castle.Windsor.WindsorContainer, Castle.Windsor", false, false );
Assert.IsNotNull(windsor);
}
开发者ID:ralescano,项目名称:castle,代码行数:13,代码来源:AssemblyResolverComponentTestCase.cs
注:本文中的Castle.MicroKernel.DefaultKernel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论