本文整理汇总了C#中Catel.IoC.ServiceLocator.IsTypeRegistered方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceLocator.IsTypeRegistered方法的具体用法?C# ServiceLocator.IsTypeRegistered怎么用?C# ServiceLocator.IsTypeRegistered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Catel.IoC.ServiceLocator
的用法示例。
在下文中一共展示了ServiceLocator.IsTypeRegistered方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: RegisterExternalContainer_ValidContainerAndTestTypeRetrieval
public void RegisterExternalContainer_ValidContainerAndTestTypeRetrieval()
{
var serviceLocator = new ServiceLocator();
var ninjectContainer = new StandardKernel();
serviceLocator.RegisterExternalContainer(ninjectContainer);
ninjectContainer.Bind<ITestInterface>().To<TestClass1>();
Assert.IsTrue(serviceLocator.IsTypeRegistered(typeof(ITestInterface)));
}
示例3: ResolveType_UnregisteredType
public void ResolveType_UnregisteredType()
{
var serviceLocator = new ServiceLocator();
Assert.IsFalse(serviceLocator.IsTypeRegistered<ITestInterface>());
ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => serviceLocator.ResolveType(typeof(ITestInterface)));
}
示例4: ResolveType_Generic
public void ResolveType_Generic()
{
var serviceLocator = new ServiceLocator();
serviceLocator.RegisterType<ITestInterface, TestClass1>();
Assert.IsTrue(serviceLocator.IsTypeRegistered<ITestInterface>());
Assert.IsInstanceOfType(serviceLocator.ResolveType<ITestInterface>(), typeof(TestClass1));
}
示例5: ResoleType_Generic_SingletonLifestyle
public void ResoleType_Generic_SingletonLifestyle()
{
var serviceLocator = new ServiceLocator();
serviceLocator.RegisterType<ITestInterface, TestClass1>();
Assert.IsTrue(serviceLocator.IsTypeRegistered<ITestInterface>());
var firstInstance = serviceLocator.ResolveType<ITestInterface>();
Assert.IsInstanceOfType(firstInstance, typeof(TestClass1));
var secondInstance = serviceLocator.ResolveType<ITestInterface>();
Assert.IsInstanceOfType(secondInstance, typeof(TestClass1));
Assert.AreSame(firstInstance, secondInstance);
}
示例6: AllowsTheSameInterfaceDefinedTwiceWithDifferentTags
public void AllowsTheSameInterfaceDefinedTwiceWithDifferentTags()
{
var serviceLocator = new ServiceLocator();
serviceLocator.RegisterType(typeof(ITestInterface), typeof(TestClass1), "1");
serviceLocator.RegisterType(typeof(ITestInterface), typeof(TestClass1), "2");
Assert.IsFalse(serviceLocator.IsTypeRegistered(typeof(ITestInterface)));
Assert.IsTrue(serviceLocator.IsTypeRegistered(typeof(ITestInterface), "1"));
Assert.IsTrue(serviceLocator.IsTypeRegistered(typeof(ITestInterface), "2"));
}
示例7: DoesNotRegisterTheImplementationTypesAsTheInterfaceTypesByDefault
public void DoesNotRegisterTheImplementationTypesAsTheInterfaceTypesByDefault()
{
var serviceLocator = new ServiceLocator();
Assert.IsFalse(serviceLocator.IsTypeRegistered<IFooService>());
Assert.IsFalse(serviceLocator.IsTypeRegistered<IFooService2>());
}
示例8: 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));
}
示例9: RegisterInstance_Valid
public void RegisterInstance_Valid()
{
var serviceLocator = new ServiceLocator();
serviceLocator.RegisterInstance<ITestInterface>(new TestClass1 { Name = "My Instance" });
Assert.IsTrue(serviceLocator.IsTypeRegistered<ITestInterface>());
var instance = serviceLocator.ResolveType<ITestInterface>();
Assert.AreEqual("My Instance", instance.Name);
}
示例10: IsTypeRegistered_UnregisteredTypeRegisteredViaMissingTypeEvent
public void IsTypeRegistered_UnregisteredTypeRegisteredViaMissingTypeEvent()
{
var serviceLocator = new ServiceLocator();
Assert.IsFalse(serviceLocator.IsTypeRegistered(typeof(ITestInterface)));
serviceLocator.MissingType += (sender, e) => e.ImplementingType = typeof(TestClass1);
Assert.IsTrue(serviceLocator.IsTypeRegistered(typeof(ITestInterface)));
}
示例11: IsTypeRegistered_RegisteredAsTypeInServiceLocator
public void IsTypeRegistered_RegisteredAsTypeInServiceLocator()
{
var serviceLocator = new ServiceLocator();
serviceLocator.RegisterType<ITestInterface, TestClass1>();
Assert.IsTrue(serviceLocator.IsTypeRegistered(typeof(ITestInterface)));
}
示例12: IsTypeRegistered_RegisteredAsInstanceInServiceLocator
public void IsTypeRegistered_RegisteredAsInstanceInServiceLocator()
{
var serviceLocator = new ServiceLocator();
serviceLocator.RegisterInstance<ITestInterface>(new TestClass1());
Assert.IsTrue(serviceLocator.IsTypeRegistered(typeof(ITestInterface)));
}
示例13: IsTypeRegistered_UnregisteredTypeRegisteredInstanceViaMissingType
public void IsTypeRegistered_UnregisteredTypeRegisteredInstanceViaMissingType()
{
var serviceLocator = new ServiceLocator();
serviceLocator.MissingType += (sender, args) =>
{
args.ImplementingInstance = new TestClass1();
};
Assert.IsTrue(serviceLocator.IsTypeRegistered(typeof(ITestInterface)));
}
示例14: IsTypeRegistered_UnregisteredType
public void IsTypeRegistered_UnregisteredType()
{
var serviceLocator = new ServiceLocator();
Assert.IsFalse(serviceLocator.IsTypeRegistered(typeof(ITestInterface)));
}
示例15: IsTypeRegistered_Null
public void IsTypeRegistered_Null()
{
var serviceLocator = new ServiceLocator();
ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => serviceLocator.IsTypeRegistered(null));
}