本文整理汇总了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>();
}