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


C# ContainerBuilder.Populate方法代码示例

本文整理汇总了C#中ContainerBuilder.Populate方法的典型用法代码示例。如果您正苦于以下问题:C# ContainerBuilder.Populate方法的具体用法?C# ContainerBuilder.Populate怎么用?C# ContainerBuilder.Populate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContainerBuilder的用法示例。


在下文中一共展示了ContainerBuilder.Populate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ServiceScopeFactoryIsRegistered

        public void ServiceScopeFactoryIsRegistered()
        {
            var builder = new ContainerBuilder();
            builder.Populate(Enumerable.Empty<ServiceDescriptor>());
            var container = builder.Build();

            container.AssertImplementation<IServiceScopeFactory, AutofacServiceScopeFactory>();
        }
开发者ID:arronchen,项目名称:Autofac,代码行数:8,代码来源:AutofacRegistrationTests.cs

示例2: PopulateRegistersServiceScopeFactory

        public void PopulateRegistersServiceScopeFactory()
        {
            var builder = new ContainerBuilder();
            builder.Populate(Enumerable.Empty<ServiceDescriptor>());
            var container = builder.Build();

            container.AssertRegistered<IServiceScopeFactory>();
        }
开发者ID:arronchen,项目名称:Autofac,代码行数:8,代码来源:AutofacRegistrationTests.cs

示例3: CorrectServiceProviderIsRegistered

        public void CorrectServiceProviderIsRegistered()
        {
            var builder = new ContainerBuilder();
            builder.Populate(Enumerable.Empty<ServiceDescriptor>());
            var container = builder.Build();

            container.AssertImplementation<IServiceProvider, AutofacServiceProvider>();
        }
开发者ID:arronchen,项目名称:Autofac,代码行数:8,代码来源:AutofacRegistrationTests.cs

示例4: CanRegisterGenericService

        public void CanRegisterGenericService()
        {
            var builder = new ContainerBuilder();
            var descriptor = new ServiceDescriptor(typeof(IList<>), typeof(List<>), LifecycleKind.Scoped);
            builder.Populate(new IServiceDescriptor[] { descriptor });
            var container = builder.Build();

            container.AssertRegistered<IList<IService>>();
        }
开发者ID:kcuzner,项目名称:Autofac,代码行数:9,代码来源:AutofacRegistrationTests.cs

示例5: CanRegisterFactoryService

        public void CanRegisterFactoryService()
        {
            var builder = new ContainerBuilder();
            var descriptor = new ServiceDescriptor(typeof(IService), sp => new Service(), LifecycleKind.Transient);
            builder.Populate(new IServiceDescriptor[] {descriptor});
            var container = builder.Build();

            container.AssertRegistered<Func<IServiceProvider, IService>>();
        }
开发者ID:kcuzner,项目名称:Autofac,代码行数:9,代码来源:AutofacRegistrationTests.cs

示例6: CanGenerateFactoryService

        public void CanGenerateFactoryService()
        {
            var builder = new ContainerBuilder();
            var descriptor = new ServiceDescriptor(typeof(IService), typeof(Service), ServiceLifetime.Transient);
            builder.Populate(new ServiceDescriptor[] {descriptor});
            var container = builder.Build();

            container.AssertRegistered<Func<IService>>();
        }
开发者ID:namld,项目名称:Autofac,代码行数:9,代码来源:AutofacRegistrationTests.cs

示例7: CanRegisterSingletonService

        public void CanRegisterSingletonService()
        {
            var builder = new ContainerBuilder();
            var descriptor = new ServiceDescriptor(typeof(IService), typeof(Service), LifecycleKind.Singleton);
            builder.Populate(new IServiceDescriptor[] {descriptor});
            var container = builder.Build();

            container.AssertLifetime<IService, RootScopeLifetime>();
            container.AssertSharing<IService>(InstanceSharing.Shared);
            container.AssertOwnership<IService>(InstanceOwnership.OwnedByLifetimeScope);
        }
开发者ID:kcuzner,项目名称:Autofac,代码行数:11,代码来源:AutofacRegistrationTests.cs

示例8: CanRegisterTransientService

        public void CanRegisterTransientService()
        {
            var builder = new ContainerBuilder();
            var descriptor = new ServiceDescriptor(typeof(IService), typeof(Service), ServiceLifetime.Transient);
            builder.Populate(new ServiceDescriptor[] { descriptor });
            var container = builder.Build();

            container.AssertLifetime<IService, CurrentScopeLifetime>();
            container.AssertSharing<IService>(InstanceSharing.None);
            container.AssertOwnership<IService>(InstanceOwnership.OwnedByLifetimeScope);
        }
开发者ID:arronchen,项目名称:Autofac,代码行数:11,代码来源:AutofacRegistrationTests.cs

示例9: ServiceCollectionConfigurationIsRetainedInRootContainer

        public void ServiceCollectionConfigurationIsRetainedInRootContainer()
        {
            var collection = new ServiceCollection();
            collection.AddOptions();
            collection.Configure<TestOptions>(options =>
            {
                options.Value = 5;
            });

            var builder = new ContainerBuilder();
            builder.Populate(collection);
            var container = builder.Build();

            var resolved = container.Resolve<IOptions<TestOptions>>();
            Assert.NotNull(resolved.Value);
            Assert.Equal(5, resolved.Value.Value);
        }
开发者ID:arronchen,项目名称:Autofac,代码行数:17,代码来源:AutofacRegistrationTests.cs


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