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


C# ContainerBuilder.RegisterConsumers方法代码示例

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


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

示例1: Load

        protected override void Load(ContainerBuilder builder)
        {
            // Registers all consumers with our container
            builder.RegisterConsumers(_assembliesToScan);

            // Creates our bus from the factory and registers it as a singleton against two interfaces
            builder.Register(c => Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var componentContext = c.Resolve<IComponentContext>();

                var host = sbc.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
                {
                    // Configure your host
                    h.Username(ConfigurationManager.AppSettings["RabbitMQUsername"]);
                    h.Password(ConfigurationManager.AppSettings["RabbitMQPassword"]);
                });

                sbc.ReceiveEndpoint(host, ConfigurationManager.AppSettings["MyMessageQueueName"], e =>
                {
                    // Configure your consumer(s)
                    e.PrefetchCount = 4;
                    e.LoadFrom(componentContext.Resolve<ILifetimeScope>());
                });
            }))
                .SingleInstance()
                .As<IBusControl>()
                .As<IBus>();
        }
开发者ID:AuthorProxy,项目名称:StarterKit-Autofac-MassTransit-Mvc,代码行数:28,代码来源:BusModule.cs

示例2: Registration_extension_method_for_consumers

        public void Registration_extension_method_for_consumers()
        {
            var builder = new ContainerBuilder();

            builder.RegisterConsumers(System.Reflection.Assembly.GetExecutingAssembly());

            var container = builder.Build();

            Assert.That(container.IsRegistered<TestConsumer>(), Is.True);
        }
开发者ID:jacobpovar,项目名称:MassTransit,代码行数:10,代码来源:AutofacRegistrationExtension_Specs.cs

示例3: Load

        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterConsumers(_assembliesToScan);

            // Creates our bus from the factory and registers it as a singleton against two interfaces
            builder.Register(c => Bus.Factory.CreateUsingRabbitMq(sbc => sbc.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
            {
                h.Username(ConfigurationManager.AppSettings["RabbitMQUsername"]);
                h.Password(ConfigurationManager.AppSettings["RabbitMQPassword"]);
            })))
                .As<IBusControl>()
                .As<IBus>()
                .SingleInstance();
        }
开发者ID:maldworth,项目名称:StarterKit-Autofac-MassTransit-Mvc-SignalR,代码行数:14,代码来源:BusModule.cs

示例4: Throw_them_under_the_bus

        public async Task Throw_them_under_the_bus()
        {
            var builder = new ContainerBuilder();

            builder.RegisterConsumers(Assembly.GetExecutingAssembly());
            builder.RegisterType<InMemorySagaRepository<SimpleSaga>>()
                .As<ISagaRepository<SimpleSaga>>()
                .SingleInstance();

            var container = builder.Build();

            var busControl = Bus.Factory.CreateUsingInMemory(x =>
            {
                x.ReceiveEndpoint("input_queue", e => e.LoadFrom(container));
            });

            var busHandle = await busControl.StartAsync();

            await busHandle.Ready;

            await busHandle.StopAsync();
        }
开发者ID:MassTransit,项目名称:MassTransit,代码行数:22,代码来源:AutofacRegistrationExtension_Specs.cs

示例5: Load

 protected override void Load(ContainerBuilder builder)
 {
     builder.RegisterConsumers(typeof(SendDocketLinkNotificationConsumer).Assembly);
 }
开发者ID:berczeck,项目名称:.Net,代码行数:4,代码来源:Program.cs


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