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


C# ServiceLocator.IsTypeRegisteredAsSingleton方法代码示例

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

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

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

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

示例5: TheIsTypeRegisteredAsSingleton_UnRegisteredType

 public void TheIsTypeRegisteredAsSingleton_UnRegisteredType()
 {
     var serviceLocator = new ServiceLocator();
     Assert.IsFalse(serviceLocator.IsTypeRegisteredAsSingleton(typeof(ITestInterface)));
 }
开发者ID:pars87,项目名称:Catel,代码行数:5,代码来源:ServiceLocatorFacts.cs

示例6: TheIsTypeRegisteredAsSingleton_NonSingleton

 public void TheIsTypeRegisteredAsSingleton_NonSingleton()
 {
     var serviceLocator = new ServiceLocator();
     serviceLocator.RegisterType<ITestInterface, TestClass1>(registrationType: RegistrationType.Transient);
     Assert.IsFalse(serviceLocator.IsTypeRegisteredAsSingleton(typeof(ITestInterface)));
 }
开发者ID:pars87,项目名称:Catel,代码行数:6,代码来源:ServiceLocatorFacts.cs

示例7: TheIsTypeRegisteredAsSingleton_Generic

 public void TheIsTypeRegisteredAsSingleton_Generic()
 {
     var serviceLocator = new ServiceLocator();
     serviceLocator.RegisterType<ITestInterface, TestClass1>();
     Assert.IsTrue(serviceLocator.IsTypeRegisteredAsSingleton<ITestInterface>());
 }
开发者ID:pars87,项目名称:Catel,代码行数:6,代码来源:ServiceLocatorFacts.cs


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