本文整理汇总了C#中MessageHeaders.WriteHeader方法的典型用法代码示例。如果您正苦于以下问题:C# MessageHeaders.WriteHeader方法的具体用法?C# MessageHeaders.WriteHeader怎么用?C# MessageHeaders.WriteHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageHeaders
的用法示例。
在下文中一共展示了MessageHeaders.WriteHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplySecurityAndWriteHeaders
public void ApplySecurityAndWriteHeaders(MessageHeaders headers, XmlDictionaryWriter writer, SecurityIdGenerator securityIdGenerator)
{
// There is no way to look through the headers attributes without changing the way
// Headers.WriterStartHeader / headers.writeHeadercontents writes the header
// So i'm using a copy that I can change without worries.
MessageHeaders copyHeaders = new MessageHeaders(headers);
for (int i = 0; i < headers.Count; i++)
{
MessageHeaderInfo header = headers[i];
// We are not supporting another d:Security header, throw if there is already one in the message
if (this.IsSecurityElement(header))
{
throw new ArgumentException("The message already contains a d:security header.");
}
if (this.ShouldProtectHeader(header))
{
string headerId;
bool idInserted;
this.GetHeaderId(copyHeaders.GetReaderAtHeader(i), securityIdGenerator, true, out headerId, out idInserted);
// Add a reference for this header
this.signer.AddReference(headers, i, writer, headerId, idInserted);
}
else
{
headers.WriteHeader(i, writer);
}
}
}