本文整理匯總了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>();
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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>();
}
示例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>();
}