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


C# SendOptions.SetHeader方法代码示例

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


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

示例1: GetHeaders_Should_Return_Configured_Headers

        public void GetHeaders_Should_Return_Configured_Headers()
        {
            var options = new SendOptions();
            options.SetHeader("custom header key 1", "custom header value 1");
            options.SetHeader("custom header key 2", "custom header value 2");

            var result = options.GetHeaders();

            Assert.AreEqual(3, result.Count);
            CollectionAssert.Contains(result.Values, "custom header value 1");
            CollectionAssert.Contains(result.Values, "custom header value 2");
            CollectionAssert.Contains(result.Keys, Headers.MessageId);
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:13,代码来源:HeaderOptionExtensionsTests.cs

示例2: BuildSendOptions

        private static SendOptions BuildSendOptions(Guid routingSlipId, string[] destinations)
        {
            var routingSlip = new RoutingSlip(routingSlipId, destinations);

            var firstRouteDefinition = routingSlip.Itinerary.First();

            var json = JsonConvert.SerializeObject(routingSlip);

            var options = new SendOptions();
            options.SetHeader(Router.RoutingSlipHeaderKey, json);
            options.SetDestination(firstRouteDefinition.Address);
            return options;
        }
开发者ID:jbogard,项目名称:NServiceBus.MessageRouting,代码行数:13,代码来源:RoutableMessageBusExtensions.cs

示例3: CancelOrder

    public void CancelOrder(int orderNumber)
    {
        CancelOrder command = new CancelOrder
        {
            ClientId = Context.ConnectionId,
            OrderNumber = orderNumber
        };

        bool isDebug = (bool)Clients.Caller.debug;
        SendOptions sendOptions = new SendOptions();
        sendOptions.SetHeader("Debug", isDebug.ToString());
        MvcApplication.Endpoint.Send(command,sendOptions);
    }
开发者ID:vanwyngardenk,项目名称:docs.particular.net,代码行数:13,代码来源:OrdersHub.cs

示例4: Route

        public static async Task Route(this IBusContext bus, object message, Guid routingSlipId, params string[] destinations)
        {
            var routingSlip = new RoutingSlip(routingSlipId, destinations);

            var firstRouteDefinition = routingSlip.Itinerary.First();

            var json = JsonConvert.SerializeObject(routingSlip);

            var options = new SendOptions();
            options.SetHeader(Router.RoutingSlipHeaderKey, json);
            options.SetDestination(firstRouteDefinition.Address);

            await bus.Send(message, options);
        }
开发者ID:nmt1994,项目名称:NServiceBus.MessageRouting,代码行数:14,代码来源:RoutableMessageBusExtensions.cs

示例5: ShouldShallowCloneHeaders

        public void ShouldShallowCloneHeaders()
        {
            var message = new OutgoingLogicalMessage(typeof(object), new object());
            var options = new SendOptions();
            options.SetHeader("someHeader", "someValue");

            var testee = new OutgoingSendContext(message, options, new RootContext(null, null, null));
            testee.Headers["someHeader"] = "updatedValue";
            testee.Headers["anotherHeader"] = "anotherValue";

            Assert.AreEqual("someValue", options.OutgoingHeaders["someHeader"]);
            Assert.IsFalse(options.OutgoingHeaders.ContainsKey("anotherHeader"));
            Assert.AreEqual("updatedValue", testee.Headers["someHeader"]);
            Assert.AreEqual("anotherValue", testee.Headers["anotherHeader"]);
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:15,代码来源:OutgoingSendContextTests.cs

示例6: PlaceOrder

    public void PlaceOrder(string[] productIds)
    {
        bool isDebug = (bool)Clients.Caller.debug;
        if (isDebug)
        {
            Debugger.Break();
        }

        SubmitOrder command = new SubmitOrder
        {
            ClientId = Context.ConnectionId,
            OrderNumber = Interlocked.Increment(ref orderNumber),
            ProductIds = productIds,
            // This property will be encrypted. Therefore when viewing the message in the queue, the actual values will not be shown. 
            EncryptedCreditCardNumber = "4000 0000 0000 0008",
            // This property will be encrypted.
            EncryptedExpirationDate = "10/13" 
        };

        SendOptions sendOptions = new SendOptions();
        sendOptions.SetHeader("Debug", isDebug.ToString());
        MvcApplication.Endpoint.Send(command, sendOptions);
    }
开发者ID:vanwyngardenk,项目名称:docs.particular.net,代码行数:23,代码来源:OrdersHub.cs


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