本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
}
示例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"]);
}
示例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);
}