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


C# BusConfiguration.Routing方法代码示例

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


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

示例1: AsyncMain

        static async Task AsyncMain()
        {
            var configuration = new BusConfiguration();
            configuration.EndpointName("Gru");
            configuration.UseSerialization<JsonSerializer>();
            configuration.UsePersistence<InMemoryPersistence>();
            configuration.EnableInstallers();
            configuration.SendFailedMessagesTo("error");


            var minionEndpoint = new EndpointName("Minion");
            configuration.Routing().UnicastRoutingTable.AddStatic(typeof(DoSomethingNaughty), minionEndpoint);
            configuration.Routing().UseFileBasedEndpointInstanceLists().LookForFilesIn(@".\");

            var endpoint = await Endpoint.Start(configuration);
            var busContext = endpoint.CreateBusContext();

            Console.WriteLine("Press enter to send a message");
            Console.WriteLine("Press any key to exit");

            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                Console.WriteLine();

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

                Console.WriteLine("Commanding to do something naughty.");
                await busContext.Send<DoSomethingNaughty>(m => m.Data = "Go minion, go!");
            }
        }
开发者ID:SeanFeldman,项目名称:DeathToTheDistributor,代码行数:35,代码来源:Program.cs

示例2: StaticRoutes

 public void StaticRoutes()
 {
     var busConfig = new BusConfiguration();
     #region Routing-StaticRoutes
     busConfig.Routing().UnicastRoutingTable.AddStatic(typeof(OrderAccepted), new EndpointName("Sales"));
     busConfig.Routing().UnicastRoutingTable.AddStatic(typeof(OrderAccepted), new EndpointInstanceName(new EndpointName("Sales"), "1", null));
     busConfig.Routing().UnicastRoutingTable.AddStatic(typeof(OrderAccepted), "[email protected]");
     #endregion
 }
开发者ID:mdaquel,项目名称:docs.particular.net,代码行数:9,代码来源:NewOutingAPIs.cs

示例3: StaticRoutes

        public void StaticRoutes()
        {
            BusConfiguration busConfiguration = new BusConfiguration();
            #region Routing-StaticRoutes-Endpoint
            busConfiguration.Routing().UnicastRoutingTable.RouteToEndpoint(typeof(AcceptOrder), "Sales");
            #endregion

            #region Routing-StaticRoutes-Address
            busConfiguration.Routing().UnicastRoutingTable.RouteToAddress(typeof(AcceptOrder), "[email protected]");
            #endregion
        }
开发者ID:vanwyngardenk,项目名称:docs.particular.net,代码行数:11,代码来源:RoutingAPIs.cs

示例4: StaticEndpointMappingWithDiscriminators

 public void StaticEndpointMappingWithDiscriminators()
 {
     var busConfig = new BusConfiguration();
     #region Routing-StaticEndpointMappingWithDiscriminators
     EndpointName sales = new EndpointName("Sales");
     busConfig.Routing().EndpointInstances.AddStaticUsingTransportDiscriminators(sales, "MachineA", "MachineB");
     #endregion
 }
开发者ID:mdaquel,项目名称:docs.particular.net,代码行数:8,代码来源:NewOutingAPIs.cs

示例5: StaticEndpointMapping

 public void StaticEndpointMapping()
 {
     var busConfig = new BusConfiguration();
     #region Routing-StaticEndpointMapping
     EndpointName sales = new EndpointName("Sales");
     busConfig.Routing().EndpointInstances.AddStatic(sales, new EndpointInstanceName(sales, "1", null), new EndpointInstanceName(sales, "2", null));
     #endregion
 }
开发者ID:mdaquel,项目名称:docs.particular.net,代码行数:8,代码来源:NewOutingAPIs.cs

示例6: SpecialCaseTransportAddress

 public void SpecialCaseTransportAddress()
 {
     var busConfiguration = new BusConfiguration();
     #region Routing-SpecialCaseTransportAddress
     busConfiguration.Routing().TransportAddresses
         .AddSpecialCase(new EndpointInstance("Sales", "1"), "[email protected]");
     #endregion
 }
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:8,代码来源:RoutingAPIs.cs

示例7: CustomRoutingStore

 public void CustomRoutingStore()
 {
     var busConfig = new BusConfiguration();
     #region Routing-CustomRoutingStore
     busConfig.Routing().UnicastRoutingTable.AddDynamic((t, c) => {
         var destinations = LoadFromCache(t) ?? LoadFromDatabaseAndPutToCache(t);
         return destinations;
     });
     #endregion
 }
开发者ID:mdaquel,项目名称:docs.particular.net,代码行数:10,代码来源:NewOutingAPIs.cs

示例8: CustomRoutingStore

        public void CustomRoutingStore()
        {
            var busConfiguration = new BusConfiguration();

            #region Routing-CustomRoutingStore

            busConfiguration.Routing().UnicastRoutingTable.AddDynamic((t, c) =>
                LoadFromCache(t) ?? LoadFromDatabaseAndPutToCache(t));

            #endregion
        }
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:11,代码来源:RoutingAPIs.cs

示例9: DynamicRoutes

 public void DynamicRoutes()
 {
     var busConfig = new BusConfiguration();
     #region Routing-DynamicRoutes
     busConfig.Routing().UnicastRoutingTable.AddDynamic((t, c) => new[]
     {
         new UnicastRoutingDestination(new EndpointName("Sales")), //Use endpoint name
         new UnicastRoutingDestination(new EndpointInstanceName(new EndpointName("Sales"), "1", null)), //Use endpoint instance name
         new UnicastRoutingDestination("[email protected]"), //Use transport address (e.g. MSMQ)
     });
     #endregion
 }
开发者ID:mdaquel,项目名称:docs.particular.net,代码行数:12,代码来源:NewOutingAPIs.cs

示例10: DynamicRoutes

 public void DynamicRoutes()
 {
     var busConfiguration = new BusConfiguration();
     #region Routing-DynamicRoutes
     busConfiguration.Routing().UnicastRoutingTable
         .AddDynamic((types, contextBag) => new[]
         {
             //Use endpoint name
             new UnicastRoute("Sales"),
             //Use endpoint instance name
             new UnicastRoute(new EndpointInstance("Sales", "1")),
             //Use transport address (e.g. MSMQ)
             new UnicastRoute("[email protected]")
         });
     #endregion
 }
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:16,代码来源:RoutingAPIs.cs

示例11: DynamicEndpointMapping

 public void DynamicEndpointMapping()
 {
     var busConfig = new BusConfiguration();
     #region Routing-DynamicEndpointMapping
     EndpointName sales = new EndpointName("Sales");
     busConfig.Routing().EndpointInstances.AddDynamic(e =>
     {
         if (e.ToString().StartsWith("Sales"))
         {
             return new[]
             {
                 new EndpointInstanceName(e, "1", "MachineA"),
                 new EndpointInstanceName(e, "2", "MachineB")
             };
         }
         return null;
     });
     #endregion
 }
开发者ID:mdaquel,项目名称:docs.particular.net,代码行数:19,代码来源:NewOutingAPIs.cs

示例12: DynamicEndpointMapping

        public void DynamicEndpointMapping()
        {
            var busConfiguration = new BusConfiguration();

            #region Routing-DynamicEndpointMapping

            busConfiguration.Routing().EndpointInstances.AddDynamic(e =>
            {
                if (e.ToString().StartsWith("Sales"))
                {
                    EndpointInstance[] instances =
                    {
                        new EndpointInstance(e, "1").SetProperty("SomeProp", "SomeValue"),
                        new EndpointInstance(e, "2").AtMachine("B")
                    };
                    return Task.FromResult<IEnumerable<EndpointInstance>>(instances);
                }
                return null;
            });

            #endregion
        }
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:22,代码来源:RoutingAPIs.cs

示例13: TransportAddressRules

 // ReSharper disable once ConvertClosureToMethodGroup
 public void TransportAddressRules()
 {
     var busConfig = new BusConfiguration();
     #region Routing-TransportAddressRule
     EndpointName sales = new EndpointName("Sales");
     busConfig.Routing().TransportAddresses.AddRule(i => CustomTranslationRule(i));
     #endregion
 }
开发者ID:mdaquel,项目名称:docs.particular.net,代码行数:9,代码来源:NewOutingAPIs.cs

示例14: SpecialCaseTransportAddress

 public void SpecialCaseTransportAddress()
 {
     var busConfig = new BusConfiguration();
     #region Routing-SpecialCaseTransportAddress
     EndpointName sales = new EndpointName("Sales");
     busConfig.Routing().TransportAddresses.AddException(new EndpointInstanceName(sales, "1", null), "[email protected]");
     #endregion
 }
开发者ID:mdaquel,项目名称:docs.particular.net,代码行数:8,代码来源:NewOutingAPIs.cs

示例15: TransportAddressRules

 // ReSharper disable once ConvertClosureToMethodGroup
 public void TransportAddressRules()
 {
     var busConfiguration = new BusConfiguration();
     #region Routing-TransportAddressRule
     busConfiguration.Routing().TransportAddresses.AddRule(i => CustomTranslationRule(i));
     #endregion
 }
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:8,代码来源:RoutingAPIs.cs


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