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


C# MessageInfo.SetUnknownHeaderDescription方法代码示例

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


在下文中一共展示了MessageInfo.SetUnknownHeaderDescription方法的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);
                            }
                        }
                    }
                }
开发者ID:weshaggard,项目名称:wcf,代码行数:48,代码来源:XmlSerializerOperationBehavior.cs

示例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);
                        }
                    }
                }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:42,代码来源:XmlSerializerOperationBehavior.cs


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