本文整理汇总了C#中MessageInfo.SetHeaderDescriptionTable方法的典型用法代码示例。如果您正苦于以下问题:C# MessageInfo.SetHeaderDescriptionTable方法的具体用法?C# MessageInfo.SetHeaderDescriptionTable怎么用?C# MessageInfo.SetHeaderDescriptionTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageInfo
的用法示例。
在下文中一共展示了MessageInfo.SetHeaderDescriptionTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateHeaderDescriptionTable
private void CreateHeaderDescriptionTable(MessageDescription message, MessageInfo info, XmlMembersMapping headersMapping)
{
int headerNameIndex = 0;
OperationFormatter.MessageHeaderDescriptionTable headerDescriptionTable = new OperationFormatter.MessageHeaderDescriptionTable();
info.SetHeaderDescriptionTable(headerDescriptionTable);
foreach (MessageHeaderDescription header in message.Headers)
{
if (header.IsUnknownHeaderCollection)
info.SetUnknownHeaderDescription(header);
else if (headersMapping != null)
{
XmlMemberMapping memberMapping = headersMapping[headerNameIndex++];
if (GeneratedXmlSerializers.IsInitialized)
{
// If GeneratedXmlSerializers has been initialized, we would use the
// mappings generated by .Net Native tools. In that case, the mappings
// we genrated at Runtime are just fake mapping instance which have
// no valid name/namespace. Therefore we cannot do the checks in the
// else block. Those checks should have been done during NET Native
// precompilation.
headerDescriptionTable.Add(header.Name, header.Namespace, header);
}
else
{
string headerName, headerNs;
headerName = memberMapping.XsdElementName;
headerNs = memberMapping.Namespace;
if (headerName != header.Name)
{
if (message.MessageType != null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNameMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Name, headerName)));
else
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNameMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Name, headerName)));
}
if (headerNs != header.Namespace)
{
if (message.MessageType != null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNamespaceMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Namespace, headerNs)));
else
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNamespaceMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Namespace, headerNs)));
}
headerDescriptionTable.Add(headerName, headerNs, header);
}
}
}
}
示例2: CreateHeaderDescriptionTable
private void CreateHeaderDescriptionTable(MessageDescription message, MessageInfo info, XmlMembersMapping headersMapping)
{
int headerNameIndex = 0;
OperationFormatter.MessageHeaderDescriptionTable headerDescriptionTable = new OperationFormatter.MessageHeaderDescriptionTable();
info.SetHeaderDescriptionTable(headerDescriptionTable);
foreach (MessageHeaderDescription header in message.Headers)
{
if (header.IsUnknownHeaderCollection)
info.SetUnknownHeaderDescription(header);
else if (headersMapping != null)
{
XmlMemberMapping memberMapping = headersMapping[headerNameIndex++];
string headerName, headerNs;
if (IsEncoded)
{
headerName = memberMapping.TypeName;
headerNs = memberMapping.TypeNamespace;
}
else
{
headerName = memberMapping.XsdElementName;
headerNs = memberMapping.Namespace;
}
if (headerName != header.Name)
{
if (message.MessageType != null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxHeaderNameMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Name, headerName)));
else
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxHeaderNameMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Name, headerName)));
}
if (headerNs != header.Namespace)
{
if (message.MessageType != null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxHeaderNamespaceMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Namespace, headerNs)));
else
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxHeaderNamespaceMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Namespace, headerNs)));
}
headerDescriptionTable.Add(headerName, headerNs, header);
}
}
}