本文整理汇总了C#中Funq.Container.AutoWire方法的典型用法代码示例。如果您正苦于以下问题:C# Container.AutoWire方法的具体用法?C# Container.AutoWire怎么用?C# Container.AutoWire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Funq.Container
的用法示例。
在下文中一共展示了Container.AutoWire方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test2
public void Test2()
{
var container = new Container();
var m = new TestFoo();
container.AutoWire(m);
Assert.Throws<ResolutionException>(() => container.Resolve<IBar>());
Assert.IsNull(m.Bar); // FAILS HERE
}
示例2: Test1
public void Test1()
{
var container = new Container();
var m = new TestFoo();
container.Register<IBar>(new Bar());
Assert.NotNull(container.Resolve<IBar>(), "Resolve");
container.AutoWire(m);
Assert.NotNull(m.Bar, "Autowire");
}
示例3: Configure
public override void Configure (Container container)
{
LogManager.LogFactory = new NLogFactory ();
this.RequestFilters.Add ((req, resp, requestDto) => {
ILog log = LogManager.GetLogger (GetType ());
log.Info (string.Format (
"REQ {0}: {1} {2} {3} {4} {5}\n",
DateTimeOffset.Now.Ticks, req.HttpMethod,
req.OperationName, req.RemoteIp, req.RawUrl, req.UserAgent));
});
this.RequestFilters.Add ((req, resp, requestDto) => {
ILog log = LogManager.GetLogger (GetType ());
log.Info (string.Format (
"RES {0}: {1} {2}\n",
DateTimeOffset.Now.Ticks, resp.StatusCode, resp.ContentType));
});
JsConfig.DateHandler = JsonDateHandler.ISO8601;
Plugins.Add (new AuthFeature (() => new AuthUserSession (),
new IAuthProvider[] { new BasicAuthProvider () })
);
Plugins.Add (new RegistrationFeature ());
Plugins.Add (new RequestLogsFeature ());
container.RegisterAutoWiredAs<Scheduler, IScheduler> ();
container.Register<ICacheClient> (new MemoryCacheClient ());
container.Register<IDbConnectionFactory> (new OrmLiteConnectionFactory
(@"Data Source=db.sqlite;Version=3;", SqliteOrmLiteDialectProvider.Instance));
//Use OrmLite DB Connection to persist the UserAuth and AuthProvider info
container.Register<IUserAuthRepository> (c => new OrmLiteAuthRepository (c.Resolve<IDbConnectionFactory> ()));
Plugins.Add (new ValidationFeature ());
container.RegisterValidators (typeof(AppHost).Assembly);
var config = new EndpointHostConfig ();
if (m_debugEnabled) {
config.DebugMode = true; //Show StackTraces in service responses during development
config.WriteErrorsToResponse = true;
config.ReturnsInnerException = true;
}
container.AutoWire (this);
SetConfig (config);
CreateMissingTables (container);
}
示例4: Can_AutoWire_Existing_Instance
public void Can_AutoWire_Existing_Instance()
{
var test = new Test();
var container = new Container();
container.Register<IFoo>(c => new Foo());
container.Register<IBar>(c => new Bar());
container.Register<int>(c => 10);
container.AutoWire(test);
Assert.That(test.Foo, Is.Not.Null);
Assert.That(test.Bar, Is.Not.Null);
Assert.That(test.Foo2 as Foo, Is.Null);
Assert.That(test.Names, Is.Not.Null);
Assert.That(test.Age, Is.EqualTo(0));
}