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


C# Container.GetRegistration方法代碼示例

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


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

示例1: AllBrowsers

 private static IEnumerable<IWebDriver> AllBrowsers(Container container)
 {
     if (container.GetRegistration(typeof(ChromeDriver)) != null)
         yield return container.GetInstance<ChromeDriver>();
     if (container.GetRegistration(typeof(InternetExplorerDriver)) != null)
         yield return container.GetInstance<InternetExplorerDriver>();
     if (container.GetRegistration(typeof(FirefoxDriver)) != null)
         yield return container.GetInstance<FirefoxDriver>();
 }
開發者ID:danludwig,項目名稱:UCosmic,代碼行數:9,代碼來源:SimpleServiceProvider.cs

示例2: RegistersIDbInitializer_UsingGreenfieldDbInitializer_Transiently_WhenSettingIsGreenfield

        public void RegistersIDbInitializer_UsingGreenfieldDbInitializer_Transiently_WhenSettingIsGreenfield()
        {
            var container = new Container();
            container.ComposeRoot(new RootCompositionSettings { IsGreenfield = true, });
            var instance = container.GetInstance<IDatabaseInitializer<EntityDbContext>>();
            var registration = container.GetRegistration(typeof(IDatabaseInitializer<EntityDbContext>));

            instance.ShouldNotBeNull();
            instance.ShouldBeType<GreenfieldDbInitializer>();
            registration.Lifestyle.ShouldEqual(Lifestyle.Transient);
        }
開發者ID:phobos04,項目名稱:tripod,代碼行數:11,代碼來源:CompositionRootTests.cs

示例3: RegistersICustomizeDb_UsingSqlServerDbCustomizer_Transiently_WhenSettingIsGreenfield

        public void RegistersICustomizeDb_UsingSqlServerDbCustomizer_Transiently_WhenSettingIsGreenfield()
        {
            var container = new Container();
            container.ComposeRoot(new RootCompositionSettings { IsGreenfield = true, });
            var instance = container.GetInstance<ICustomizeDb>();
            var registration = container.GetRegistration(typeof(ICustomizeDb));

            instance.ShouldNotBeNull();
            instance.ShouldBeType<SqlServerScriptsCustomizer>();
            registration.Lifestyle.ShouldEqual(Lifestyle.Transient);
        }
開發者ID:phobos04,項目名稱:tripod,代碼行數:11,代碼來源:CompositionRootTests.cs

示例4: RegisterArrayResolver

 private static void RegisterArrayResolver(UnregisteredTypeEventArgs e, Container container, Type elementType)
 {
     var producer = container.GetRegistration(typeof(IEnumerable<>)
         .MakeGenericType(elementType));
     var enumerableExpression = producer.BuildExpression();
     var arrayMethod = typeof(Enumerable).GetMethod("ToArray")
         .MakeGenericMethod(elementType);
     var arrayExpression = Expression.Call(arrayMethod, enumerableExpression);
     e.Register(arrayExpression);
 }
開發者ID:uhaciogullari,項目名稱:MvcSiteMapProvider,代碼行數:10,代碼來源:MvcSiteMapProviderContainerInitializer.cs

示例5: RegistersIAuthenticationManager_UsingOwin_WhenCurrentHttpContext_HasOwinEnvironment

        public void RegistersIAuthenticationManager_UsingOwin_WhenCurrentHttpContext_HasOwinEnvironment()
        {
            HttpContext.Current = new HttpContext(new HttpRequest(null, "http://localhost", null), new HttpResponse(null));
            var owinEnvironment = new Dictionary<string, object>();
            var userStore = new Mock<IUserStore<User, int>>();
            var userManager = new UserManager<User, int>(userStore.Object);
            owinEnvironment["AspNet.Identity.Owin:" + userManager.GetType().AssemblyQualifiedName] = userManager;
            HttpContext.Current.Items.Add("owin.Environment", owinEnvironment);
            var container = new Container();
            container.RegisterConfiguration();
            container.RegisterCryptography();
            container.RegisterEntityFramework();
            container.RegisterSecurity();
            container.Verify();

            var registration = container.GetRegistration(typeof(IAuthenticationManager));
            registration.Lifestyle.ShouldEqual(Lifestyle.Transient);
            var instance = container.GetInstance<IAuthenticationManager>();
            instance.ShouldNotBeNull();
        }
開發者ID:phobos04,項目名稱:tripod,代碼行數:20,代碼來源:CompositionRootTests.cs

示例6: RegistersIAuthenticationManager_UsingBigFatPhony_WhenCurrentHttpContext_HasNoOwinEnvironment

        public void RegistersIAuthenticationManager_UsingBigFatPhony_WhenCurrentHttpContext_HasNoOwinEnvironment()
        {
            HttpContext.Current = new HttpContext(new HttpRequest(null, "http://localhost", null), new HttpResponse(null));
            var container = new Container();
            container.RegisterConfiguration();
            container.RegisterCryptography();
            container.RegisterEntityFramework();
            container.RegisterSecurity();
            container.Verify();

            var registration = container.GetRegistration(typeof(IAuthenticationManager));
            registration.Lifestyle.ShouldEqual(Lifestyle.Transient);
            var instance = container.GetInstance<IAuthenticationManager>();
            instance.ShouldNotBeNull();
            instance.ShouldBeType<BigFatPhonyAuthenticationManager>();
        }
開發者ID:phobos04,項目名稱:tripod,代碼行數:16,代碼來源:CompositionRootTests.cs

示例7: RegistersIAuthenticationManager_UsingBigFatPhony_WhenCurrentHttpContext_IsNull

        public void RegistersIAuthenticationManager_UsingBigFatPhony_WhenCurrentHttpContext_IsNull()
        {
            //var registration = Container.GetRegistration(typeof (IAuthenticationManager));
            //registration.Lifestyle.ShouldEqual(Lifestyle.Transient);
            //var instance = Container.GetInstance<IAuthenticationManager>();
            //instance.ShouldNotBeNull();
            //instance.ShouldBeType<BigFatPhonyAuthenticationManager>();
            HttpContext.Current = null;
            var container = new Container();
            container.RegisterConfiguration();
            container.RegisterCryptography();
            container.RegisterEntityFramework();
            container.RegisterSecurity();
            container.Verify();

            var registration = container.GetRegistration(typeof(IAuthenticationManager));
            registration.Lifestyle.ShouldEqual(Lifestyle.Transient);
            var instance = container.GetInstance<IAuthenticationManager>();
            instance.ShouldNotBeNull();
            instance.ShouldBeType<BigFatPhonyAuthenticationManager>();
        }
開發者ID:phobos04,項目名稱:tripod,代碼行數:21,代碼來源:CompositionRootTests.cs


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