当前位置: 首页>>代码示例>>C#>>正文


C# ServiceLocator.IsTypeRegistered方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:pars87,项目名称:Catel,代码行数:20,代码来源:IoCConfigurationSectionTests.cs

示例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)));
            }
开发者ID:pars87,项目名称:Catel,代码行数:9,代码来源:ServiceLocatorFacts.cs

示例3: ResolveType_UnregisteredType

            public void ResolveType_UnregisteredType()
            {
                var serviceLocator = new ServiceLocator();

                Assert.IsFalse(serviceLocator.IsTypeRegistered<ITestInterface>());
                ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => serviceLocator.ResolveType(typeof(ITestInterface)));
            }
开发者ID:pars87,项目名称:Catel,代码行数:7,代码来源:ServiceLocatorFacts.cs

示例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));
            }
开发者ID:pars87,项目名称:Catel,代码行数:8,代码来源:ServiceLocatorFacts.cs

示例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);
            }
开发者ID:pars87,项目名称:Catel,代码行数:14,代码来源:ServiceLocatorFacts.cs

示例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"));
            }
开发者ID:pars87,项目名称:Catel,代码行数:10,代码来源:ServiceLocatorFacts.cs

示例7: DoesNotRegisterTheImplementationTypesAsTheInterfaceTypesByDefault

 public void DoesNotRegisterTheImplementationTypesAsTheInterfaceTypesByDefault()
 {
     var serviceLocator = new ServiceLocator();
     Assert.IsFalse(serviceLocator.IsTypeRegistered<IFooService>());
     Assert.IsFalse(serviceLocator.IsTypeRegistered<IFooService2>());
 }
开发者ID:pars87,项目名称:Catel,代码行数:6,代码来源:ServiceLocatorFacts.cs

示例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));
            }
开发者ID:pars87,项目名称:Catel,代码行数:16,代码来源:ServiceLocatorFacts.cs

示例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);
            }
开发者ID:pars87,项目名称:Catel,代码行数:10,代码来源:ServiceLocatorFacts.cs

示例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)));
            }
开发者ID:pars87,项目名称:Catel,代码行数:8,代码来源:ServiceLocatorFacts.cs

示例11: IsTypeRegistered_RegisteredAsTypeInServiceLocator

            public void IsTypeRegistered_RegisteredAsTypeInServiceLocator()
            {
                var serviceLocator = new ServiceLocator();
                serviceLocator.RegisterType<ITestInterface, TestClass1>();

                Assert.IsTrue(serviceLocator.IsTypeRegistered(typeof(ITestInterface)));
            }
开发者ID:pars87,项目名称:Catel,代码行数:7,代码来源:ServiceLocatorFacts.cs

示例12: IsTypeRegistered_RegisteredAsInstanceInServiceLocator

            public void IsTypeRegistered_RegisteredAsInstanceInServiceLocator()
            {
                var serviceLocator = new ServiceLocator();
                serviceLocator.RegisterInstance<ITestInterface>(new TestClass1());

                Assert.IsTrue(serviceLocator.IsTypeRegistered(typeof(ITestInterface)));
            }
开发者ID:pars87,项目名称:Catel,代码行数:7,代码来源:ServiceLocatorFacts.cs

示例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)));
            }
开发者ID:pars87,项目名称:Catel,代码行数:10,代码来源:ServiceLocatorFacts.cs

示例14: IsTypeRegistered_UnregisteredType

            public void IsTypeRegistered_UnregisteredType()
            {
                var serviceLocator = new ServiceLocator();

                Assert.IsFalse(serviceLocator.IsTypeRegistered(typeof(ITestInterface)));
            }
开发者ID:pars87,项目名称:Catel,代码行数:6,代码来源:ServiceLocatorFacts.cs

示例15: IsTypeRegistered_Null

 public void IsTypeRegistered_Null()
 {
     var serviceLocator = new ServiceLocator();
     ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => serviceLocator.IsTypeRegistered(null));
 }
开发者ID:pars87,项目名称:Catel,代码行数:5,代码来源:ServiceLocatorFacts.cs


注:本文中的Catel.IoC.ServiceLocator.IsTypeRegistered方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。