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


C# ContainerBuilder.RegisterCumulus方法代码示例

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


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

示例1: SetUpBus

        private static void SetUpBus(ContainerBuilder builder)
        {
            //TODO: Set up your own connection string in app.config
            var connectionString = ConfigurationManager.AppSettings["AzureConnectionString"];

            // You'll want a logger. There's a ConsoleLogger and a NullLogger if you really don't care. You can roll your
            // own by implementing the ILogger interface if you want to hook it to an existing logging implementation.
            builder.RegisterType<SerilogStaticLogger>()
                   .AsImplementedInterfaces()
                   .SingleInstance();

            // This is how you tell Cumulus where to find all your message types and handlers.
            var typeProvider = new AssemblyScanningTypeProvider(Assembly.GetExecutingAssembly(),
                                                                typeof (OrderPizzaCommand).Assembly,
                                                                typeof (NewOrderRecieved).Assembly);
            
            builder.RegisterCumulus(typeProvider);
            builder.Register(componentContext => new BusBuilder()
                                 .Configure()
                                 .WithConnectionString(connectionString)
                                 .WithNames("Maker", Environment.MachineName)
                                 .WithTypesFrom(typeProvider)
                                 .WithAutofacDefaults(componentContext)
                                 .WithQueueAndTopicCreation(false)
                                 .Build())
                   .As<IBus>()
                   .AutoActivate()
                   .OnActivated(async c => await c.Instance.Start())
                   .SingleInstance();
        }
开发者ID:AtmosphereMessaging,项目名称:Cumulus,代码行数:30,代码来源:Program.cs

示例2: TheyShouldBeResolvable

        public void TheyShouldBeResolvable()
        {
            var interceptorTypes = new[] {typeof (DummyInterceptor)};

            var builder = new ContainerBuilder();
            var typeProvider = Substitute.For<ITypeProvider>();
            typeProvider.InterceptorTypes.Returns(interceptorTypes);

            builder.RegisterCumulus(typeProvider);

            using (var container = builder.Build())
            using (var dependencyResolver = container.Resolve<IDependencyResolver>())
            using (var scope = dependencyResolver.CreateChildScope())
            {
                var interceptorSetting = new GlobalOutboundInterceptorTypesSetting
                                         {
                                             Value = interceptorTypes
                                         };
                var outboundInterceptorFactory = new OutboundInterceptorFactory(interceptorSetting,
                                                                                new PropertyInjector(Substitute.For<IClock>(),
                                                                                                     Substitute.For<IDispatchContextManager>(),
                                                                                                     Substitute.For<ILargeMessageBodyStore>()));

                var dummyBrokeredMessage = new BrokeredMessage();
                var interceptors = outboundInterceptorFactory.CreateInterceptors(scope, dummyBrokeredMessage);

                interceptors.Count().ShouldBe(1);
            }
        }
开发者ID:AtmosphereMessaging,项目名称:Cumulus,代码行数:29,代码来源:WhenRegisteringInterceptorsWithAutofac.cs

示例3: CreateContainer

        private static IContainer CreateContainer()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType<DeepThought>();

            builder.RegisterType<SerilogStaticLogger>()
                   .As<ILogger>()
                   .SingleInstance();

            //TODO: Set up your own connection string in app.config
            var connectionString = ConfigurationManager.AppSettings["AzureConnectionString"];

            var handlerTypesProvider = new AssemblyScanningTypeProvider(Assembly.GetExecutingAssembly());
            builder.RegisterCumulus(handlerTypesProvider);
            builder.Register(componentContext => new BusBuilder()
                                 .Configure()
                                 .WithConnectionString(connectionString)
                                 .WithNames("MyApp", Environment.MachineName)
                                 .WithTypesFrom(handlerTypesProvider)
                                 .WithAutofacDefaults(componentContext)
                                 .Build())
                   .As<IBus>()
                   .AutoActivate()
                   .OnActivated(c => c.Instance.Start())
                   .SingleInstance();

            var container = builder.Build();
            return container;
        }
开发者ID:AtmosphereMessaging,项目名称:Cumulus,代码行数:30,代码来源:Program.cs

示例4: Load

        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            var connectionString = ConfigurationManager.AppSettings["AzureConnectionString"];

            // You'll want a logger. There's a ConsoleLogger and a NullLogger if you really don't care. You can roll your
            // own by implementing the ILogger interface if you want to hook it to an existing logging implementation.
            builder.RegisterType<ConsoleLogger>()
                   .AsImplementedInterfaces()
                   .SingleInstance();

            // This is how you tell Cumulus where to find all your message types and handlers.
            var pizzaOrderingMessagesAssembly = typeof (HowLongDoPizzasTakeRequest).Assembly;
            var pizzaMakerMessagesAssembly = typeof (PizzaIsReady).Assembly;
            var CumulusAssembly = typeof (Bus).Assembly; // for stock interceptors

            var handlerTypesProvider = new AssemblyScanningTypeProvider(ThisAssembly, pizzaOrderingMessagesAssembly, pizzaMakerMessagesAssembly, CumulusAssembly);

            builder.RegisterCumulus(handlerTypesProvider);
            builder.Register(componentContext => new BusBuilder()
                                 .Configure()
                                 .WithConnectionString(connectionString)
                                 .WithNames("MyApp", Environment.MachineName).WithTypesFrom(handlerTypesProvider)
                                 .WithAutofacDefaults(componentContext)
                                 .Build())
                   .As<IBus>()
                   .AutoActivate()
                   .OnActivated(async c => await c.Instance.Start())
                   .SingleInstance();
        }
开发者ID:AtmosphereMessaging,项目名称:Cumulus,代码行数:31,代码来源:BusModule.cs

示例5: NothingShouldGoBang

        public async Task NothingShouldGoBang()
        {
            var typeProvider = new AssemblyScanningTypeProvider(GetType().Assembly);

            var builder = new ContainerBuilder();
            builder.RegisterCumulus(typeProvider);

            using (builder.Build()) { }
        }
开发者ID:AtmosphereMessaging,项目名称:Cumulus,代码行数:9,代码来源:WhenRegisteringHandlerTypesUsingAutofac.cs

示例6: NothingShouldGoBang

        public void NothingShouldGoBang()
        {
            var builder = new ContainerBuilder();
            var typeProvider = new AssemblyScanningTypeProvider();

            builder.RegisterType<ConsoleLogger>()
                   .As<ILogger>()
                   .SingleInstance();

            builder.RegisterCumulus(typeProvider);

            var largeMessageBodyTempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Guid.NewGuid().ToString());

            builder.Register(c => new FileSystemStorageBuilder().Configure()
                                                                .WithStorageDirectory(largeMessageBodyTempPath)
                                                                .WithLogger(c.Resolve<ILogger>())
                                                                .Build())
                   .As<ILargeMessageBodyStore>()
                   .SingleInstance();

            builder.Register(c => new BusBuilder().Configure()
                                                  .WithNames("IntegrationTestHarness", Environment.MachineName)
                                                  .WithConnectionString(
                                                      @"Endpoint=sb://shouldnotexist.example.com/;SharedAccessKeyName=IntegrationTestHarness;SharedAccessKey=borkborkbork=")
                                                  .WithLargeMessageStorage(sc => sc.WithLargeMessageBodyStore(c.Resolve<ILargeMessageBodyStore>())
                                                                                   .WithMaxSmallMessageSize(50*1024)
                                                                                   .WithMaxLargeMessageSize(1024*1024))
                                                  .WithTypesFrom(typeProvider)
                                                  .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                                  .WithLogger(c.Resolve<ILogger>())
                                                  .Build())
                   .As<IBus>()
                   .SingleInstance();

            using (var container = builder.Build())
            {
                container.Resolve<IBus>();
            }
        }
开发者ID:AtmosphereMessaging,项目名称:Cumulus,代码行数:39,代码来源:WhenBuildingABusWithAutofacAndFileSystemMessageStorage.cs

示例7: Create

 public IDependencyResolver Create(ITypeProvider typeProvider)
 {
     var builder = new ContainerBuilder();
     builder.RegisterCumulus(typeProvider);
     return builder.Build().Resolve<IDependencyResolver>();
 }
开发者ID:AtmosphereMessaging,项目名称:Cumulus,代码行数:6,代码来源:AutofacDependencyResolverFactory.cs


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