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


C# ContainerBuilder.RegisterAggregateService方法代码示例

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


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

示例1: RegisterAggregateService_WithType_RegistersServiceInterface

        public void RegisterAggregateService_WithType_RegistersServiceInterface()
        {
            var builder = new ContainerBuilder();
            builder.RegisterAggregateService(typeof(IMyContext));
            var container = builder.Build();

            Assert.That(container.IsRegistered<IMyContext>());
        }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:8,代码来源:ContainerBuilderExtensionsFixture.cs

示例2: Load

        protected override void Load(ContainerBuilder builder)
        {
            // Aggregate Services
            builder.RegisterAggregateService<IComponents>();

            // Settings
            builder.RegisterType<CodeGenerator>().As<ICodeGenerator>();
            builder.RegisterType<EmailSender>().As<IEmailSender>();
            builder.RegisterType<SmsSender>().As<ISmsSender>();
        }
开发者ID:nguyenminhthu,项目名称:TeleConsult,代码行数:10,代码来源:ComponentsModule.cs

示例3: RegisterAggregateService_IsPerDependencyScoped

        public void RegisterAggregateService_IsPerDependencyScoped()
        {
            var builder = new ContainerBuilder();
            builder.RegisterAggregateService<IMyContext>();
            builder.RegisterInstance(new Mock<IMyService>().Object);
            var container = builder.Build();

            var firstInstance = container.Resolve<IMyContext>();
            var secondInstance = container.Resolve<IMyContext>();

            Assert.That(firstInstance, Is.Not.SameAs(secondInstance));
        }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:12,代码来源:ContainerBuilderExtensionsFixture.cs

示例4: Setup

        public void Setup()
        {
            _someDependencyMock = new Mock<ISomeDependency>().Object;
            _someOtherDependencyMock = new Mock<ISomeOtherDependency>().Object;

            var builder = new ContainerBuilder();
            builder.RegisterAggregateService<ISubService>();
            builder.RegisterInstance(_someDependencyMock);
            builder.RegisterInstance(_someOtherDependencyMock);
            _container = builder.Build();

            _aggregateService = _container.Resolve<ISubService>();
        }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:13,代码来源:AggregateServiceInheritanceFixture.cs

示例5: RegisterAggregateService_DifferentLifeTimeScopes_YieldsDifferentInstances

        public void RegisterAggregateService_DifferentLifeTimeScopes_YieldsDifferentInstances()
        {
            var builder = new ContainerBuilder();
            builder.RegisterAggregateService(typeof(IMyContext));
            builder.RegisterType<MyServiceImpl>()
                .As<IMyService>()
                .InstancePerLifetimeScope();
            var container = builder.Build();

            var rootScope = container.Resolve<IMyContext>();
            var subScope = container.BeginLifetimeScope().Resolve<IMyContext>();

            Assert.That(rootScope.MyService, Is.Not.SameAs(subScope.MyService));
        }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:14,代码来源:ContainerBuilderExtensionsFixture.cs

示例6: Load

        protected override void Load(ContainerBuilder builder)
        {
            // Aggregate Services
            builder.RegisterAggregateService<IServices>();
            builder.RegisterAggregateService<IAdminServices>();

            // All Services
            builder.RegisterAssemblyTypes(ThisAssembly)
                .Where(t => t.Name.EndsWith("Service"))
                .PropertiesAutowired()
                .AsImplementedInterfaces();

            // Settings
            builder.RegisterType<DictionaryAdapterFactory>().As<IDictionaryAdapterFactory>().SingleInstance();

            // Resolve ISettings by resolving the DictionaryAdapterFactory and initialising it with AppSettings from web.config
            builder.Register(x => x.Resolve<IDictionaryAdapterFactory>()
                .GetAdapter<ISettings>(ConfigurationManager.AppSettings))
                .As<ISettings>().SingleInstance();

            // Resolve the specified settings by resolving ISettings then just taking the appropriate property
            builder.Register(x => x.Resolve<ISettings>().Twilio).As<ITwilioSettings>();
            builder.Register(x => x.Resolve<ISettings>().Aws).As<IAwsSettings>();
        }
开发者ID:nguyenminhthu,项目名称:TeleConsult,代码行数:24,代码来源:ServicesModule.cs

示例7: Load

        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType<RiskContext>().As<IRiskContext>().InstancePerRequest();
            builder.RegisterType<RiskContext>().As<DbContext>().InstancePerRequest();

            builder.RegisterAggregateService<IServices>();

            builder.RegisterType<CustomerService>().As<ICustomerService>();
            builder.RegisterType<SettledBetService>().As<ISettledBetService>();
            builder.RegisterType<UnsettledBetService>().As<IUnsettledBetService>();
            builder.RegisterType<CustomerAnalysisService>().As<ICustomerAnalysisService>();
            builder.RegisterType<UnsettledBetAnalysisService>().As<IUnsettledBetAnalysisService>();
            builder.RegisterType<CustomerCalculatorService>().As<ICustomerCalculatorService>();
            builder.RegisterType<BetCalculatorService>().As<IBetCalculatorService>();

            base.Load(builder);
        }
开发者ID:desflan,项目名称:RiskAnalysis,代码行数:17,代码来源:CoreModule.cs

示例8: Setup

        public void Setup()
        {
            _someDependencyMock = new Mock<ISomeDependency>().Object;

            var builder = new ContainerBuilder();
            builder.RegisterAggregateService<IMyContext>();
            builder.RegisterType<MyServiceImpl>()
                .As<IMyService>()
                .InstancePerDependency();
            builder.RegisterInstance(_someDependencyMock);
            _container = builder.Build();

            _aggregateService = _container.Resolve<IMyContext>();
        }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:14,代码来源:AggregateServiceFixture.cs

示例9: RegisterAggregateService_WithNullInterfaceType_ThrowsArgumentNullException

 public void RegisterAggregateService_WithNullInterfaceType_ThrowsArgumentNullException()
 {
     var builder = new ContainerBuilder();
     builder.RegisterAggregateService(null);
 }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:5,代码来源:ContainerBuilderExtensionsFixture.cs

示例10: RegisterAggregateService_WithNonInterfaceType_ThrowsArgumentException

 public void RegisterAggregateService_WithNonInterfaceType_ThrowsArgumentException()
 {
     var builder = new ContainerBuilder();
     builder.RegisterAggregateService(typeof(MyServiceImpl));
 }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:5,代码来源:ContainerBuilderExtensionsFixture.cs


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