本文整理汇总了C#中Container.Invoking方法的典型用法代码示例。如果您正苦于以下问题:C# Container.Invoking方法的具体用法?C# Container.Invoking怎么用?C# Container.Invoking使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container.Invoking方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: should_register_default_implementations
public void should_register_default_implementations()
{
var ns = typeof(IFoobar1).Namespace;
var container = new Container(x => x.Scan.AssemblyContainingTypeOf(this).Where(y => y.Namespace != null && y.Namespace.StartsWith(ns)).UseDefaultImplementations());
container.Invoking(x => x.Get<IFoobar1>()).ShouldNotThrow();
container.Invoking(x => x.Get<IFoobar2>()).ShouldNotThrow();
container.Invoking(x => x.Get<IFoobar3>()).ShouldThrow<ActivationException>();
container.Invoking(x => x.Get<IFoobar4>()).ShouldThrow<ActivationException>();
}
示例2: set_property_with_unresolvable_type_should_throw
public void set_property_with_unresolvable_type_should_throw()
{
var container = new Container(x => x.For<Foobar>().Use<Foobar>().Set(y => y.UnresolvableDependency));
container.Invoking(x => x.Get<Foobar>()).ShouldThrow<ActivationException>();
}
示例3: set_missing_property_should_throw
public void set_missing_property_should_throw()
{
var container = new Container(x => x.For<Foobar>().Use<Foobar>().Set("missing property"));
container.Invoking(x => x.Get<Foobar>()).ShouldThrow<ActivationException>();
}
示例4: try_set_property_with_unresolvable_type_should_work
public void try_set_property_with_unresolvable_type_should_work()
{
var container = new Container(x => x.For<Foobar>().Use<Foobar>().TrySet(y => y.UnresolvableDependency));
container.Invoking(x => x.Get<Foobar>()).ShouldNotThrow();
}