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


C# BusConfiguration.Conventions方法代码示例

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


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

示例1: OnStart

    protected override void OnStart(string[] args)
    {
        var busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("SendNsbMessage");
        busConfiguration.UseSerialization<XmlSerializer>();

        if (Environment.UserInteractive && Debugger.IsAttached)
        {
            //TODO: For production use, please select a durable persistence.
            busConfiguration.UsePersistence<InMemoryPersistence>();

            //TODO: For production use, please script your installation.
            busConfiguration.EnableInstallers();
            busConfiguration.Conventions()
                .DefiningCommandsAs(t => t.Namespace != null && t.Namespace == "IntegrationSample.Messages.Commands");
            busConfiguration.Conventions()
                .DefiningEventsAs(t => t.Namespace != null && t.Namespace == "IntegrationSample.Messages.Events");
        }
        var startableBus = Bus.Create(busConfiguration);
        bus = startableBus.Start();
        Console.WriteLine("\r\nPress '1' to send an NSB message\r\n");

        while (true)
        {
            var key = Console.ReadKey(true);
            if (key.KeyChar == '1')
                bus.Send(new ProcessOrder()
                {
                    OrderId = Guid.NewGuid(),

                });
            Console.WriteLine("\r\nPress '1' to send an NSB message\r\n");
        }
    }
开发者ID:weralabaj,项目名称:Work,代码行数:34,代码来源:ProgramService.cs

示例2: Customize

        public void Customize(BusConfiguration configuration)
        {
            configuration.UseSerialization<JsonSerializer>();
            configuration.UsePersistence<InMemoryPersistence>();

            // configure message definitions
            configuration.Conventions().DefiningCommandsAs(e => e.Namespace != null & e.Namespace.EndsWith("Commands"));
            configuration.Conventions().DefiningEventsAs(e => e.Namespace != null & e.Namespace.EndsWith("Events"));
        }
开发者ID:twonder,项目名称:SimpleNSBPubSub,代码行数:9,代码来源:EndpointConfig.cs

示例3: Customize

        public void Customize(BusConfiguration config)
        {
            if (Environment.UserInteractive)
                Console.Title = "Saga";

            // herewith we can avoid implementation of the ICommand interface in the Nsb.Commands assembly
            config.Conventions().DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("Nsb") && t.Name.EndsWith("Command"));

            // herewith we can avoid implementation of the IMessage interface in the Nsb.Messages assembly
            config.Conventions().DefiningMessagesAs(t => t.Namespace != null && t.Namespace.StartsWith("Nsb") && t.Name.EndsWith("Message"));

            config.UsePersistence<InMemoryPersistence>();
        }
开发者ID:ristica,项目名称:nservicebus-sagas,代码行数:13,代码来源:EndpointConfig.cs

示例4: Should_not_throw_propertyType_is_not_serializable_if_a_IDataBusSerializer_is_already_registered

        public void Should_not_throw_propertyType_is_not_serializable_if_a_IDataBusSerializer_is_already_registered()
        {
            if (!Debugger.IsAttached)
            {
                Assert.Ignore("This only work in debug mode.");
            }

            var builder = new BusConfiguration();
            builder.EndpointName("xyz");
            builder.TypesToScan(new[]
                {
                    typeof(MessageWithNonSerializableDataBusProperty)
                });
            builder.Conventions().DefiningDataBusPropertiesAs(p => p.Name.EndsWith("DataBus"));
            builder.RegisterComponents(c =>
            {
                c.RegisterSingleton<IDataBus>(new InMemoryDataBus());
                c.ConfigureComponent<IDataBusSerializer>(() => new MyDataBusSerializer(), DependencyLifecycle.SingleInstance);
            });

            var config = builder.BuildConfiguration();
            var feature = new DataBus();

            Assert.DoesNotThrow(() => feature.CheckPrerequisites(new FeatureConfigurationContext(config)));
        }
开发者ID:ogdenmd,项目名称:NServiceBus,代码行数:25,代码来源:When_nservicebus_is_initalizing.cs

示例5: Main

        static void Main()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType<Program>();

            var container = builder.Build();

            var configuration = new BusConfiguration();

            configuration.UseContainer<AutofacBuilder>(c => c.ExistingLifetimeScope(container));

            configuration.UseTransport<AzureStorageQueueTransport>()
                .ConnectionString("UseDevelopmentStorage=true");
            configuration.UsePersistence<AzureStoragePersistence>();
            configuration.UseSerialization<JsonSerializer>();

            configuration.DisableFeature<Sagas>();
            configuration.DisableFeature<TimeoutManager>();

            configuration.Conventions().DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("NServiceBusDemo.Messages.Commands"));
            configuration.Conventions().DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("NServiceBusDemo.Messages.Events"));
            configuration.Conventions().DefiningMessagesAs(t => t.Namespace != null && t.Namespace.StartsWith("NServiceBusDemo.Messages.Responses"));

            Bus.Create(configuration).Start();

            using (var scope = container.BeginLifetimeScope())
            {
                scope.Resolve<Program>().Run();
            }
        }
开发者ID:Rommel-Villa,项目名称:NSB_Spike,代码行数:31,代码来源:Program.cs

示例6: Main

        static void Main()
        {
            // configure the bus
            var busConfiguration = new BusConfiguration();
            busConfiguration.UseSerialization<JsonSerializer>();
            busConfiguration.UsePersistence<RavenDBPersistence>();
            busConfiguration.Conventions().DefiningCommandsAs(e => e.Namespace != null & e.Namespace.EndsWith("Commands"));
            busConfiguration.Conventions().DefiningEventsAs(e => e.Namespace != null & e.Namespace.EndsWith("Events"));

            // start the bus
            var startableBus = Bus.Create(busConfiguration);
            using (var bus = startableBus.Start())
            {
                Start(bus);
            }
        }
开发者ID:twonder,项目名称:SimpleNSBPubSub,代码行数:16,代码来源:Program.cs

示例7: Customize

        public void Customize(BusConfiguration configuration)
        {
            XmlConfigurator.Configure();
            configuration.UseContainer<NinjectBuilder>(k => k.ExistingKernel(CreateKernel()));
            configuration.RegisterComponents(x => x.ConfigureComponent<IRepository>(
                builder =>
                {
                    return new Repository(() =>
                    {
                        var nh = builder.Build<NHibernateStorageContext>();
                        var e = new OrderContext((DbConnection)nh.Connection);
                        return e;
                    });
                },
                DependencyLifecycle.InstancePerUnitOfWork));
            configuration.RegisterComponents(components => components.ConfigureComponent<UnitOfWork>(DependencyLifecycle.InstancePerUnitOfWork));

            configuration.UsePersistence<NHibernatePersistence>();
            configuration.UseTransport<MsmqTransport>();
            configuration.UseDataBus<FileShareDataBus>().BasePath(Constants.NServiceBus_DataBusBasePath);
            configuration.RijndaelEncryptionService();
            configuration.Transactions();
            configuration.EnableOutbox();
            configuration.Conventions().OrderConventions();
            //
        }
开发者ID:eraj2587,项目名称:NserviceBusDemo,代码行数:26,代码来源:EndpointConfig.cs

示例8: Main

        static void Main( string[] args )
        {
            var config = new BusConfiguration();
            config.UsePersistence<InMemoryPersistence>();
            config.UseSerialization<JsonSerializer>();
            config.UseTransport<RabbitMQTransport>()
                .DisableCallbackReceiver();

            config.Transactions()
                .DisableDistributedTransactions();

            config.EnableInstallers();
            config.Conventions()
                .DefiningCommandsAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Commands" ) )
                .DefiningEventsAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Events" ) )
                .DefiningMessagesAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Messages" ) );

            using( var bus = Bus.Create( config ).Start() )
            {
                Logic.Run( setup =>
                {
                    setup.DefineAction( ConsoleKey.P, "Publish sample event", () =>
                    {
                        bus.Publish<IMessagePublished>(e =>
                        {
                            e.ClientId = "client-id";
                            e.MessageId = "sample-message-id";
                        });
                    } );
                } );
            }
        }
开发者ID:khaledm,项目名称:PoweringFrontEndApps,代码行数:32,代码来源:Program.cs

示例9: Main

        static void Main(string[] args)
        {
            Console.Title = "Complaint.Backend";

            Console.WriteLine("Complaint Backend starting up...");

            var configuration = new BusConfiguration();
            configuration.Conventions()
                .DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("SiriusCyberneticsCorp.InternalMessages"))
                .DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("SiriusCyberneticsCorp.Contract"));

            configuration.CustomConfigurationSource(new CustomConfigurationSource());

            configuration.UseSerialization<JsonSerializer>();
            configuration.UsePersistence<RavenDBPersistence>();
            configuration.UseTransport<MsmqTransport>();

            var bus = Bus.Create(configuration).Start();

            Console.WriteLine("Press any key to shut down.");

            Console.ReadLine();
            Console.WriteLine("Complaint Backend shutting down...");

            bus.Dispose();
        }
开发者ID:danielmarbach,项目名称:nservicebus.introduction,代码行数:26,代码来源:Program.cs

示例10: Main

    static void Main()
    {
        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.Scaleout.Sender");
        busConfiguration.EnableInstallers();
        busConfiguration.UseSerialization<JsonSerializer>();
        busConfiguration.UsePersistence<InMemoryPersistence>();
        busConfiguration.Conventions()
            .DefiningMessagesAs(t => t.GetInterfaces().Contains(typeof (IMessage)));

        using (IBus bus = Bus.Create(busConfiguration).Start())
        {
            Console.WriteLine("Press 'Enter' to send a message.");
            Console.WriteLine("Press any other key to exit.");
            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                Console.WriteLine();

                if (key.Key != ConsoleKey.Enter)
                {
                    return;
                }

                SendMessage(bus);
            }
        }
    }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:28,代码来源:Program.cs

示例11: Customize

        public void Customize(BusConfiguration configuration)
        {
            configuration.Conventions()
                .DefiningMessagesAs(t => t.Namespace != null && t.Namespace.EndsWith(".Contracts"));

            configuration.UsePersistence<RavenDBPersistence>();
        }
开发者ID:ramonsmits,项目名称:DeathToTheBatchJob,代码行数:7,代码来源:EndpointConfig.cs

示例12: Usage

 Usage(BusConfiguration busConfiguration)
 {
     #region DefiningEncryptedPropertiesAs
     ConventionsBuilder conventions = busConfiguration.Conventions();
     conventions.DefiningEncryptedPropertiesAs(info => info.Name.EndsWith("EncryptedProperty"));
     #endregion
 }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:7,代码来源:Usage.cs

示例13: Customize

 public void Customize(BusConfiguration config)
 {
     config.Conventions()
         .DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("Example2.Internal.Commands"))
         .DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("Example2.Contracts"))
         .DefiningMessagesAs(t => t.Namespace != null && t.Namespace.StartsWith("Example2.Internal.Messages"));
 }
开发者ID:siniypin,项目名称:NSB_Intro,代码行数:7,代码来源:MessageConventions.cs

示例14: Customize

 public void Customize(BusConfiguration configuration)
 {
     configuration.UseTransport<RabbitMQTransport>();
     configuration.UsePersistence<InMemoryPersistence>();
     configuration.RijndaelEncryptionService();
     UnobtrusiveMessageConventions.Init(configuration.Conventions());
 }
开发者ID:ghola,项目名称:NServiceBus.RabbitMQ.Samples,代码行数:7,代码来源:EndpointConfig.cs

示例15: Init

        public static void Init()
        {
            if (Bus != null)
            return;

              lock (SyncLock)
              {
            if (Bus != null)
              return;
            var cfg = new BusConfiguration();

            cfg.EndpointName(MethodBase.GetCurrentMethod().DeclaringType.Namespace);
            cfg.UseTransport<MsmqTransport>();
            cfg.UsePersistence<InMemoryPersistence>();
            cfg.EnableInstallers();
            cfg.UseSerialization<JsonSerializer>();

            cfg.Conventions()
               .DefiningMessagesAs(t => t.Namespace != null && t.Namespace.EndsWith(".Messages"))
               .DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Commands"))
               .DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Events"));

            Bus = NServiceBus.Bus.Create(cfg).Start();
              }
        }
开发者ID:rioka,项目名称:NsbServiceHostBasedGateway,代码行数:25,代码来源:ServiceBus.cs


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