本文整理汇总了C#中Funq.Container.RegisterAutoWiredType方法的典型用法代码示例。如果您正苦于以下问题:C# Container.RegisterAutoWiredType方法的具体用法?C# Container.RegisterAutoWiredType怎么用?C# Container.RegisterAutoWiredType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Funq.Container
的用法示例。
在下文中一共展示了Container.RegisterAutoWiredType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Factory
public static ISomeService Factory(Container c)
{
// Register the service by type...
c.RegisterAutoWiredType(typeof(SomeService), ReuseScope.Hierarchy);
// ... and force auto-wiring to happen.
ISomeService result = (ISomeService)c.TryResolve(typeof(SomeService));
return result;
}
示例2: With_Funq_and_Expressions
public void With_Funq_and_Expressions()
{
var container = new Container();
container.Register<IFoo>(c => new Foo());
container.Register<IBar>(c => new Bar());
container.RegisterAutoWiredType(typeof(AutoWireService));
Console.WriteLine("With_Funq_and_Expressions(): {0}", Measure(() => container.Resolve<AutoWireService>(), Times));
}
示例3: Can_AutoWire_types_dynamically_with_expressions
public void Can_AutoWire_types_dynamically_with_expressions()
{
var serviceType = typeof(AutoWireService);
var container = new Container();
container.Register<IFoo>(c => new Foo());
container.Register<IBar>(c => new Bar());
container.RegisterAutoWiredType(serviceType);
var service = container.Resolve<AutoWireService>();
Assert.That(service.Foo, Is.Not.Null);
Assert.That(service.Bar, Is.Not.Null);
}