当前位置: 首页>>代码示例>>C#>>正文


C# Container.AutoWire方法代码示例

本文整理汇总了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
 }         
开发者ID:CLupica,项目名称:ServiceStack,代码行数:8,代码来源:FunqTests.cs

示例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");
 }
开发者ID:CLupica,项目名称:ServiceStack,代码行数:9,代码来源:FunqTests.cs

示例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);
		}
开发者ID:frachstudia,项目名称:studies,代码行数:50,代码来源:AppHost.cs

示例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));
		}
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:17,代码来源:IoCTests.cs


注:本文中的Funq.Container.AutoWire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。