本文整理汇总了C#中Catel.IoC.ServiceLocator.IsTypeRegisteredAsSingleton方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceLocator.IsTypeRegisteredAsSingleton方法的具体用法?C# ServiceLocator.IsTypeRegisteredAsSingleton怎么用?C# ServiceLocator.IsTypeRegisteredAsSingleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Catel.IoC.ServiceLocator
的用法示例。
在下文中一共展示了ServiceLocator.IsTypeRegisteredAsSingleton方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeServiceLocatorFromNonDefaultConfiguration
public void InitializeServiceLocatorFromNonDefaultConfiguration()
{
Configuration openExeConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var configurationSection = openExeConfiguration.GetSection<IoCConfigurationSection>("ioc", "catel");
var serviceLocatorConfiguration = configurationSection.GetServiceLocatorConfiguration("test");
Assert.IsNotNull(serviceLocatorConfiguration);
var serviceLocator = new ServiceLocator();
serviceLocatorConfiguration.Configure(serviceLocator);
Assert.AreEqual(serviceLocatorConfiguration.SupportDependencyInjection, serviceLocator.SupportDependencyInjection);
foreach (Registration registration in serviceLocatorConfiguration)
{
serviceLocator.IsTypeRegistered(registration.InterfaceType);
if (registration.RegistrationType == RegistrationType.Singleton)
{
serviceLocator.IsTypeRegisteredAsSingleton(registration.InterfaceType);
}
}
}
示例2: RegistersTheImplementationTypesAsInterfaceTypesIfIsSetToTrue
public void RegistersTheImplementationTypesAsInterfaceTypesIfIsSetToTrue()
{
var serviceLocator = new ServiceLocator { AutoRegisterTypesViaAttributes = true };
Assert.IsTrue(serviceLocator.IsTypeRegistered<IFooService>());
Assert.IsTrue(serviceLocator.IsTypeRegisteredAsSingleton<IFooService>());
Assert.IsTrue(serviceLocator.IsTypeRegistered<IFooService2>());
Assert.IsFalse(serviceLocator.IsTypeRegisteredAsSingleton<IFooService2>());
var resolveType = serviceLocator.ResolveType<IFooService>();
Assert.IsInstanceOfType(resolveType, typeof(FooService));
var resolveType2 = serviceLocator.ResolveType<IFooService2>();
Assert.IsInstanceOfType(resolveType2, typeof(FooService2));
}
示例3: TheIsTypeRegisteredAsSingleton_RegisteredInstanceViaMissingTypeEvent
public void TheIsTypeRegisteredAsSingleton_RegisteredInstanceViaMissingTypeEvent()
{
var serviceLocator = new ServiceLocator();
serviceLocator.MissingType += (sender, args) =>
{
args.ImplementingInstance = new TestClass1();
// NOTE: This value will be ignored, read the docs.
args.RegistrationType = RegistrationType.Transient;
};
Assert.IsTrue(serviceLocator.IsTypeRegisteredAsSingleton(typeof(ITestInterface)));
}
示例4: TheIsTypeRegisteredAsSingleton_RegisteredTypeViaMissingTypeEvent
public void TheIsTypeRegisteredAsSingleton_RegisteredTypeViaMissingTypeEvent()
{
var serviceLocator = new ServiceLocator();
serviceLocator.MissingType += (sender, args) =>
{
args.ImplementingType = typeof(TestClass1);
args.RegistrationType = RegistrationType.Transient;
};
Assert.IsFalse(serviceLocator.IsTypeRegisteredAsSingleton(typeof(ITestInterface)));
}
示例5: TheIsTypeRegisteredAsSingleton_UnRegisteredType
public void TheIsTypeRegisteredAsSingleton_UnRegisteredType()
{
var serviceLocator = new ServiceLocator();
Assert.IsFalse(serviceLocator.IsTypeRegisteredAsSingleton(typeof(ITestInterface)));
}
示例6: TheIsTypeRegisteredAsSingleton_NonSingleton
public void TheIsTypeRegisteredAsSingleton_NonSingleton()
{
var serviceLocator = new ServiceLocator();
serviceLocator.RegisterType<ITestInterface, TestClass1>(registrationType: RegistrationType.Transient);
Assert.IsFalse(serviceLocator.IsTypeRegisteredAsSingleton(typeof(ITestInterface)));
}
示例7: TheIsTypeRegisteredAsSingleton_Generic
public void TheIsTypeRegisteredAsSingleton_Generic()
{
var serviceLocator = new ServiceLocator();
serviceLocator.RegisterType<ITestInterface, TestClass1>();
Assert.IsTrue(serviceLocator.IsTypeRegisteredAsSingleton<ITestInterface>());
}