本文整理汇总了C#中System.ServiceModel.OperationContext.IncomingMessageHeaders属性的典型用法代码示例。如果您正苦于以下问题:C# OperationContext.IncomingMessageHeaders属性的具体用法?C# OperationContext.IncomingMessageHeaders怎么用?C# OperationContext.IncomingMessageHeaders使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.ServiceModel.OperationContext
的用法示例。
在下文中一共展示了OperationContext.IncomingMessageHeaders属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Push
class SampleService : ISampleService
{
#region ISampleService Members
public void Push(string msg)
{
Console.WriteLine("Proxy: " + msg);
this.WriteHeaders(OperationContext.Current.IncomingMessageHeaders);
MessageHeader outBoundHeader
= MessageHeader.CreateHeader(
"Client-Bound-One-Way-Header",
"http://Microsoft.WCF.Documentation",
"Custom Outbound Header"
);
OperationContext.Current.OutgoingMessageHeaders.Add(outBoundHeader);
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("OutgoingHeader:");
Console.Write("\t");
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(outBoundHeader.ToString());
Console.ResetColor();
OperationContext.Current.GetCallbackChannel<IClientCallbackContract>().PushBack("Here's something to examine in response.");
}
void WriteHeaders(MessageHeaders headers)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("IncomingHeader:");
Console.ForegroundColor = ConsoleColor.Blue;
foreach (MessageHeaderInfo h in headers)
{
if (!h.Actor.Equals(String.Empty))
Console.WriteLine("\t" + h.Actor);
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("\t" + h.Name);
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("\t" + h.Namespace);
Console.WriteLine("\t" + h.Relay);
if (h.IsReferenceParameter == true)
{
Console.WriteLine("IsReferenceParameter header detected: " + h.ToString());
}
}
Console.ResetColor();
}