當前位置: 首頁>>代碼示例>>C#>>正文


C# IocContainer.DefaultLifetimeFactory方法代碼示例

本文整理匯總了C#中System.IocContainer.DefaultLifetimeFactory方法的典型用法代碼示例。如果您正苦於以下問題:C# IocContainer.DefaultLifetimeFactory方法的具體用法?C# IocContainer.DefaultLifetimeFactory怎麽用?C# IocContainer.DefaultLifetimeFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IocContainer的用法示例。


在下文中一共展示了IocContainer.DefaultLifetimeFactory方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CachedLifetimeCanBeSetAsDefaultLifetime

 public void CachedLifetimeCanBeSetAsDefaultLifetime()
 {
     using (var container = new IocContainer(() => new CachedLifetime()))
     {
         Assert.IsInstanceOfType(container.DefaultLifetimeFactory(), typeof(CachedLifetime));
     }
 }
開發者ID:GeorgeR,項目名稱:DynamoIOC,代碼行數:7,代碼來源:CachedLifetimeTest.cs

示例2: CanSetDefaultLifetimeToRequestLifetime

 public void CanSetDefaultLifetimeToRequestLifetime()
 {
     using (var container = new IocContainer(() => new RequestLifetime()))
     {
         Assert.IsInstanceOfType(container.DefaultLifetimeFactory(), typeof(RequestLifetime));
     }
 }
開發者ID:GeorgeR,項目名稱:DynamoIOC,代碼行數:7,代碼來源:RequestLifetimeTest.cs

示例3: ContainerCanSetDefaultsUsingTheConstructor

		public void ContainerCanSetDefaultsUsingTheConstructor()
		{
			Func<ILifetime> lifetimeFactory = () => new ContainerLifetime();
			var compileMode = CompileMode.Dynamic;
			var index = new DirectIndex();
			
			using (var container = new IocContainer(lifetimeFactory, compileMode, index))
			{
				Assert.IsInstanceOfType(container.DefaultLifetimeFactory(), typeof(ContainerLifetime));
				Assert.IsTrue(compileMode == container.DefaultCompileMode);
				Assert.AreSame(index, container.Index);
			}
		}
開發者ID:Kingefosa,項目名稱:Dynamo.IoC,代碼行數:13,代碼來源:ContainerTest.cs

示例4: ContainerIsCreatedWithCorrectDefaults

		public void ContainerIsCreatedWithCorrectDefaults()
		{
			using (var container = new IocContainer())
			{
				// Default Lifetime
				Assert.IsInstanceOfType(container.DefaultLifetimeFactory(), typeof(TransientLifetime));

				// Default CompileMode
				Assert.IsTrue(container.DefaultCompileMode == CompileMode.Delegate);

				// Default Index
				Assert.IsInstanceOfType(container.Index, typeof(DirectIndex));
			}
		}
開發者ID:Kingefosa,項目名稱:Dynamo.IoC,代碼行數:14,代碼來源:ContainerTest.cs

示例5: CanChangeLifetimeUsingSetLifetime

        public void CanChangeLifetimeUsingSetLifetime()
        {
            using (var container = new IocContainer(() => new TransientLifetime()))
            {
                Assert.IsInstanceOfType(container.DefaultLifetimeFactory(), typeof(TransientLifetime));

                var registration = container.Register<IFoo>(c => new Foo1()).SetLifetime(new ContainerLifetime());

                Assert.IsInstanceOfType(registration.Lifetime, typeof(ContainerLifetime));

                var foo1 = container.Resolve<IFoo>();
                var foo2 = container.Resolve<IFoo>();

                Assert.AreSame(foo1, foo2);
            }
        }
開發者ID:GeorgeR,項目名稱:DynamoIOC,代碼行數:16,代碼來源:ContainerTest.cs

示例6: ContainerUsesTheDefaultLifetimeSetWhenRegistering

        public void ContainerUsesTheDefaultLifetimeSetWhenRegistering()
        {
            // Make sure the set lifetime is not the default - if changed in the future !?
            // Create a default IocContainer and check that the default lifetime is not ContainerLifetime?

            using (var container = new IocContainer(() => new ContainerLifetime()))
            {
                var defaultLifetime = container.DefaultLifetimeFactory();

                // Default Lifetime
                Assert.IsInstanceOfType(defaultLifetime, typeof(ContainerLifetime));

                var result1 = container.Register<IFoo>(c => new Foo1());
                var result2 = container.Register<IBar>(c => new Bar1());

                Assert.IsInstanceOfType(result1.Lifetime, typeof(ContainerLifetime));
                Assert.IsInstanceOfType(result2.Lifetime, typeof(ContainerLifetime));
            }
        }
開發者ID:GeorgeR,項目名稱:DynamoIOC,代碼行數:19,代碼來源:ContainerTest.cs

示例7: ContainerUsesTheDefaultLifetimeWhenRegistering

		public void ContainerUsesTheDefaultLifetimeWhenRegistering()
		{
			using (var container = new IocContainer(() => new ContainerLifetime()))
			{
				var defaultLifetime = container.DefaultLifetimeFactory();

				// Default Lifetime
				Assert.IsInstanceOfType(defaultLifetime, typeof(ContainerLifetime));

				// Try registering with all Register methods using lifetime
				var result1 = container.Register<IFoo>(c => new Foo1());
				var result2 = container.Register<IFoo, Foo1>("Key1");
				var result3 = container.Register(typeof(IFoo), typeof(Foo1), "Key2");

				Assert.IsInstanceOfType(result1.Lifetime, typeof(ContainerLifetime));
				Assert.IsInstanceOfType(result2.Lifetime, typeof(ContainerLifetime));
				Assert.IsInstanceOfType(result3.Lifetime, typeof(ContainerLifetime));
			}
		}
開發者ID:Kingefosa,項目名稱:Dynamo.IoC,代碼行數:19,代碼來源:ContainerTest.cs


注:本文中的System.IocContainer.DefaultLifetimeFactory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。