< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.XmlSerializerOperationFormatter
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/XmlSerializerOperationFormatter.cs
Line coverage
48%
Covered lines: 132
Uncovered lines: 139
Coverable lines: 271
Total lines: 617
Line coverage: 48.7%
Branch coverage
44%
Covered branches: 71
Total branches: 158
Branch coverage: 44.9%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)75%4485.71%
AddHeadersToMessage(...)53.57%282866.66%
GetHeadersFromMessage(...)57.14%424272.3%
AddUnknownHeader(...)0%660%
WriteBodyAttributes(...)100%44100%
SerializeBody(...)25%161627.58%
SerializeBody(...)75%8891.66%
DeserializeBody(...)20%101021.05%
DeserializeBody(...)56.25%161657.14%
GetEncoding(...)75%4466.66%
.ctor(...)100%110%
GetContentAndSaveHeaderAttributes(...)0%660%
GetHeaderAttributes(...)0%660%
SetHeaderAttributes(...)0%440%
CreateMessageHeader(...)0%440%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/XmlSerializerOperationFormatter.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using System.Collections;
 6using System.Collections.Generic;
 7using System.IO;
 8using System.Reflection;
 9using System.Xml;
 10using System.Xml.Serialization;
 11using CoreWCF.Channels;
 12using CoreWCF.Description;
 13
 14namespace CoreWCF.Dispatcher
 15{
 16    internal class XmlSerializerOperationFormatter : OperationFormatter
 17    {
 18        private const string soap11Encoding = "http://schemas.xmlsoap.org/soap/encoding/";
 19        private const string soap12Encoding = "http://www.w3.org/2003/05/soap-encoding";
 20        private readonly bool _isEncoded;
 21        private readonly MessageInfo _requestMessageInfo;
 22        private readonly MessageInfo _replyMessageInfo;
 23
 24        public XmlSerializerOperationFormatter(OperationDescription description, XmlSerializerFormatAttribute xmlSeriali
 25            MessageInfo requestMessageInfo, MessageInfo replyMessageInfo) :
 5026            base(description, xmlSerializerFormatAttribute.Style == OperationFormatStyle.Rpc, xmlSerializerFormatAttribu
 27        {
 5028            if (xmlSerializerFormatAttribute.IsEncoded && xmlSerializerFormatAttribute.Style != OperationFormatStyle.Rpc
 29            {
 030                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFx
 31            }
 32
 5033            _isEncoded = xmlSerializerFormatAttribute.IsEncoded;
 34
 5035            _requestMessageInfo = requestMessageInfo;
 5036            _replyMessageInfo = replyMessageInfo;
 5037        }
 38
 39        protected override void AddHeadersToMessage(Message message, MessageDescription messageDescription, object[] par
 40        {
 41            XmlSerializer serializer;
 42            MessageHeaderDescriptionTable headerDescriptionTable;
 43            MessageHeaderDescription unknownHeaderDescription;
 44            bool mustUnderstand;
 45            bool relay;
 46            string actor;
 47            try
 48            {
 2149                if (isRequest)
 50                {
 051                    serializer = _requestMessageInfo.HeaderSerializer;
 052                    headerDescriptionTable = _requestMessageInfo.HeaderDescriptionTable;
 053                    unknownHeaderDescription = _requestMessageInfo.UnknownHeaderDescription;
 54                }
 55                else
 56                {
 2157                    serializer = _replyMessageInfo.HeaderSerializer;
 2158                    headerDescriptionTable = _replyMessageInfo.HeaderDescriptionTable;
 2159                    unknownHeaderDescription = _replyMessageInfo.UnknownHeaderDescription;
 60                }
 2161                if (serializer != null)
 62                {
 163                    object[] headerValues = new object[headerDescriptionTable.Count];
 164                    MessageHeaderOfTHelper messageHeaderOfTHelper = null;
 165                    int headerIndex = 0;
 66
 667                    foreach (MessageHeaderDescription headerDescription in messageDescription.Headers)
 68                    {
 269                        object parameterValue = parameters[headerDescription.Index];
 270                        if (!headerDescription.IsUnknownHeaderCollection)
 71                        {
 272                            if (headerDescription.TypedHeader)
 73                            {
 074                                if (messageHeaderOfTHelper == null)
 75                                {
 076                                    messageHeaderOfTHelper = new MessageHeaderOfTHelper(parameters.Length);
 77                                }
 78
 079                                headerValues[headerIndex++] = messageHeaderOfTHelper.GetContentAndSaveHeaderAttributes(p
 80                            }
 81                            else
 82                            {
 283                                headerValues[headerIndex++] = parameterValue;
 84                            }
 85                        }
 86                    }
 87
 188                    MemoryStream memoryStream = new MemoryStream();
 189                    XmlDictionaryWriter bufferWriter = XmlDictionaryWriter.CreateTextWriter(memoryStream);
 190                    bufferWriter.WriteStartElement("root");
 191                    serializer.Serialize(bufferWriter, headerValues, null, _isEncoded ? GetEncoding(message.Version.Enve
 192                    bufferWriter.WriteEndElement();
 193                    bufferWriter.Flush();
 194                    XmlDocument doc = new XmlDocument();
 195                    memoryStream.Position = 0;
 196                    doc.Load(memoryStream);
 97
 98                    //TODO: XmlTextReader supported in .Net Standard 1.7, prohibiting DtdProcessing is important
 99                    //doc.Load(new XmlTextReader(memoryStream) { DtdProcessing = DtdProcessing.Prohibit });
 100                    //doc.Save(Console.Out);
 101
 10102                    foreach (XmlElement element in doc.DocumentElement.ChildNodes)
 103                    {
 4104                        MessageHeaderDescription matchingHeaderDescription = headerDescriptionTable.Get(element.LocalNam
 4105                        if (matchingHeaderDescription == null)
 106                        {
 0107                            message.Headers.Add(new XmlElementMessageHeader(this, message.Version, element.LocalName, el
 0108                                                                            false/*mustUnderstand*/, null/*actor*/, fals
 109                        }
 110                        else
 111                        {
 4112                            if (matchingHeaderDescription.TypedHeader)
 113                            {
 0114                                messageHeaderOfTHelper.GetHeaderAttributes(matchingHeaderDescription, out mustUnderstand
 115                            }
 116                            else
 117                            {
 4118                                mustUnderstand = matchingHeaderDescription.MustUnderstand;
 4119                                relay = matchingHeaderDescription.Relay;
 4120                                actor = matchingHeaderDescription.Actor;
 121                            }
 4122                            message.Headers.Add(new XmlElementMessageHeader(this, message.Version, element.LocalName, el
 4123                                                                            mustUnderstand, actor, relay, element));
 124                        }
 125                    }
 126                }
 21127                if (unknownHeaderDescription != null && parameters[unknownHeaderDescription.Index] != null)
 128                {
 0129                    foreach (object unknownHeader in (IEnumerable)parameters[unknownHeaderDescription.Index])
 130                    {
 0131                        XmlElement element = (XmlElement)GetContentOfMessageHeaderOfT(unknownHeaderDescription, unknownH
 0132                        if (element != null)
 133                        {
 0134                            message.Headers.Add(new XmlElementMessageHeader(this, message.Version, element.LocalName, el
 0135                                                                  mustUnderstand, actor, relay, element));
 136                        }
 137                    }
 138                }
 21139            }
 0140            catch (InvalidOperationException e)
 141            {
 0142                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
 0143                    SR.Format(SR.SFxErrorSerializingHeader, messageDescription.MessageName, e.Message), e));
 144            }
 21145        }
 146
 147        protected override void GetHeadersFromMessage(Message message, MessageDescription messageDescription, object[] p
 148        {
 149            try
 150            {
 151                XmlSerializer serializer;
 152                MessageHeaderDescriptionTable headerDescriptionTable;
 153                MessageHeaderDescription unknownHeaderDescription;
 21154                if (isRequest)
 155                {
 21156                    serializer = _requestMessageInfo.HeaderSerializer;
 21157                    headerDescriptionTable = _requestMessageInfo.HeaderDescriptionTable;
 21158                    unknownHeaderDescription = _requestMessageInfo.UnknownHeaderDescription;
 159                }
 160                else
 161                {
 0162                    serializer = _replyMessageInfo.HeaderSerializer;
 0163                    headerDescriptionTable = _replyMessageInfo.HeaderDescriptionTable;
 0164                    unknownHeaderDescription = _replyMessageInfo.UnknownHeaderDescription;
 165                }
 21166                MessageHeaders headers = message.Headers;
 21167                ArrayList unknownHeaders = null;
 21168                XmlDocument xmlDoc = null;
 21169                if (unknownHeaderDescription != null)
 170                {
 0171                    unknownHeaders = new ArrayList();
 0172                    xmlDoc = new XmlDocument();
 173                }
 21174                if (serializer == null)
 175                {
 20176                    if (unknownHeaderDescription != null)
 177                    {
 0178                        for (int headerIndex = 0; headerIndex < headers.Count; headerIndex++)
 179                        {
 0180                            AddUnknownHeader(unknownHeaderDescription, unknownHeaders, xmlDoc, null/*bufferWriter*/, hea
 181                        }
 182
 0183                        parameters[unknownHeaderDescription.Index] = unknownHeaders.ToArray(unknownHeaderDescription.Typ
 184                    }
 20185                    return;
 186                }
 187
 188
 1189                MemoryStream memoryStream = new MemoryStream();
 1190                XmlDictionaryWriter bufferWriter = XmlDictionaryWriter.CreateTextWriter(memoryStream);
 1191                message.WriteStartEnvelope(bufferWriter);
 1192                message.WriteStartHeaders(bufferWriter);
 1193                MessageHeaderOfTHelper messageHeaderOfTHelper = null;
 14194                for (int headerIndex = 0; headerIndex < headers.Count; headerIndex++)
 195                {
 6196                    MessageHeaderInfo header = headers[headerIndex];
 6197                    XmlDictionaryReader headerReader = headers.GetReaderAtHeader(headerIndex);
 6198                    MessageHeaderDescription matchingHeaderDescription = headerDescriptionTable.Get(header.Name, header.
 6199                    if (matchingHeaderDescription != null)
 200                    {
 4201                        if (header.MustUnderstand)
 202                        {
 0203                            headers.UnderstoodHeaders.Add(header);
 204                        }
 205
 4206                        if (matchingHeaderDescription.TypedHeader)
 207                        {
 0208                            if (messageHeaderOfTHelper == null)
 209                            {
 0210                                messageHeaderOfTHelper = new MessageHeaderOfTHelper(parameters.Length);
 211                            }
 212
 0213                            messageHeaderOfTHelper.SetHeaderAttributes(matchingHeaderDescription, header.MustUnderstand,
 214                        }
 215                    }
 6216                    if (matchingHeaderDescription == null && unknownHeaderDescription != null)
 217                    {
 0218                        AddUnknownHeader(unknownHeaderDescription, unknownHeaders, xmlDoc, bufferWriter, header, headerR
 219                    }
 220                    else
 221                    {
 6222                        bufferWriter.WriteNode(headerReader, false);
 223                    }
 224
 6225                    headerReader.Dispose();
 226                }
 1227                bufferWriter.WriteEndElement();
 1228                bufferWriter.WriteEndElement();
 1229                bufferWriter.Flush();
 230
 231                /*
 232                XmlDocument doc = new XmlDocument();
 233                memoryStream.Position = 0;
 234                doc.Load(memoryStream);
 235                doc.Save(Console.Out);
 236                */
 237
 1238                memoryStream.Position = 0;
 1239                memoryStream.TryGetBuffer(out ArraySegment<byte> memoryBuffer);
 1240                XmlDictionaryReader bufferReader = XmlDictionaryReader.CreateTextReader(memoryBuffer.Array, 0, (int)memo
 241
 1242                bufferReader.ReadStartElement();
 1243                bufferReader.MoveToContent();
 1244                if (!bufferReader.IsEmptyElement)
 245                {
 1246                    bufferReader.ReadStartElement();
 1247                    object[] headerValues = (object[])serializer.Deserialize(bufferReader, _isEncoded ? GetEncoding(mess
 1248                    int headerIndex = 0;
 6249                    foreach (MessageHeaderDescription headerDescription in messageDescription.Headers)
 250                    {
 2251                        if (!headerDescription.IsUnknownHeaderCollection)
 252                        {
 2253                            object parameterValue = headerValues[headerIndex++];
 2254                            if (headerDescription.TypedHeader && parameterValue != null)
 255                            {
 0256                                parameterValue = messageHeaderOfTHelper.CreateMessageHeader(headerDescription, parameter
 257                            }
 258
 2259                            parameters[headerDescription.Index] = parameterValue;
 260                        }
 261                    }
 1262                    bufferReader.Dispose();
 263                }
 1264                if (unknownHeaderDescription != null)
 265                {
 0266                    parameters[unknownHeaderDescription.Index] = unknownHeaders.ToArray(unknownHeaderDescription.TypedHe
 267                }
 1268            }
 0269            catch (InvalidOperationException e)
 270            {
 271                // all exceptions from XmlSerializer get wrapped in InvalidOperationException,
 272                // so we must be conservative and never turn this into a fault
 0273                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
 0274                    SR.Format(SR.SFxErrorDeserializingHeader, messageDescription.MessageName), e));
 275            }
 21276        }
 277
 278        private static void AddUnknownHeader(MessageHeaderDescription unknownHeaderDescription, ArrayList unknownHeaders
 279        {
 0280            object unknownHeader = xmlDoc.ReadNode(headerReader);
 0281            if (bufferWriter != null)
 282            {
 0283                ((XmlElement)unknownHeader).WriteTo(bufferWriter);
 284            }
 285
 0286            if (unknownHeader != null && unknownHeaderDescription.TypedHeader)
 287            {
 0288                unknownHeader = TypedHeaderManager.Create(unknownHeaderDescription.Type, unknownHeader, header.MustUnder
 289            }
 290
 0291            unknownHeaders.Add(unknownHeader);
 0292        }
 293
 294        protected override void WriteBodyAttributes(XmlDictionaryWriter writer, MessageVersion version)
 295        {
 21296            if (_isEncoded && version.Envelope == EnvelopeVersion.Soap11)
 297            {
 1298                string encoding = GetEncoding(version.Envelope);
 1299                writer.WriteAttributeString("encodingStyle", version.Envelope.Namespace, encoding);
 300            }
 21301            writer.WriteAttributeString("xmlns", "xsi", null, XmlUtil.XmlSerializerSchemaInstanceNamespace);
 21302            writer.WriteAttributeString("xmlns", "xsd", null, XmlUtil.XmlSerializerSchemaNamespace);
 21303        }
 304
 305        protected override void SerializeBody(XmlDictionaryWriter writer, MessageVersion version, string action, Message
 306        {
 20307            if (writer == null)
 308            {
 0309                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(writer)));
 310            }
 311
 20312            if (parameters == null)
 313            {
 0314                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(parameters)))
 315            }
 316
 317            try
 318            {
 319                MessageInfo messageInfo;
 20320                if (isRequest)
 321                {
 0322                    messageInfo = _requestMessageInfo;
 323                }
 324                else
 325                {
 20326                    messageInfo = _replyMessageInfo;
 327                }
 328
 20329                if (messageInfo.RpcEncodedTypedMessageBodyParts == null)
 330                {
 20331                    SerializeBody(writer, version, messageInfo.BodySerializer, messageDescription.Body.ReturnValue, mess
 20332                    return;
 333                }
 334
 0335                object[] bodyPartValues = new object[messageInfo.RpcEncodedTypedMessageBodyParts.Count];
 0336                object bodyObject = parameters[messageDescription.Body.Parts[0].Index];
 0337                if (bodyObject == null)
 338                {
 0339                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 340                }
 341
 0342                int i = 0;
 0343                foreach (MessagePartDescription bodyPart in messageInfo.RpcEncodedTypedMessageBodyParts)
 344                {
 0345                    MemberInfo member = bodyPart.MemberInfo;
 0346                    FieldInfo field = member as FieldInfo;
 0347                    if (field != null)
 348                    {
 0349                        bodyPartValues[i++] = field.GetValue(bodyObject);
 350                    }
 351                    else
 352                    {
 0353                        PropertyInfo property = member as PropertyInfo;
 0354                        if (property != null)
 355                        {
 0356                            bodyPartValues[i++] = property.GetValue(bodyObject, null);
 357                        }
 358                    }
 359                }
 0360                SerializeBody(writer, version, messageInfo.BodySerializer, null/*returnPart*/, messageInfo.RpcEncodedTyp
 0361            }
 0362            catch (InvalidOperationException e)
 363            {
 0364                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
 0365                    SR.Format(SR.SFxErrorSerializingBody, messageDescription.MessageName, e.Message), e));
 366            }
 20367        }
 368
 369        private void SerializeBody(XmlDictionaryWriter writer, MessageVersion version, XmlSerializer serializer, Message
 370        {
 20371            if (serializer == null)
 372            {
 0373                return;
 374            }
 375
 20376            bool hasReturnValue = IsValidReturnValue(returnPart);
 20377            object[] bodyParameters = new object[bodyParts.Count + (hasReturnValue ? 1 : 0)];
 20378            int paramIndex = 0;
 379
 20380            if (hasReturnValue)
 381            {
 16382                bodyParameters[paramIndex++] = returnValue;
 383            }
 384
 54385            for (int i = 0; i < bodyParts.Count; i++)
 386            {
 7387                bodyParameters[paramIndex++] = parameters[bodyParts[i].Index];
 388            }
 389
 20390            string encoding = _isEncoded ? GetEncoding(version.Envelope) : null;
 20391            serializer.Serialize(writer, bodyParameters, null, encoding);
 20392        }
 393
 394
 395        protected override object DeserializeBody(XmlDictionaryReader reader, MessageVersion version, string action, Mes
 396        {
 397            MessageInfo messageInfo;
 20398            if (isRequest)
 399            {
 20400                messageInfo = _requestMessageInfo;
 401            }
 402            else
 403            {
 0404                messageInfo = _replyMessageInfo;
 405            }
 406
 20407            if (messageInfo.RpcEncodedTypedMessageBodyParts == null)
 408            {
 20409                return DeserializeBody(reader, version, messageInfo.BodySerializer, messageDescription.Body.ReturnValue,
 410            }
 411
 0412            object[] bodyPartValues = new object[messageInfo.RpcEncodedTypedMessageBodyParts.Count];
 0413            DeserializeBody(reader, version, messageInfo.BodySerializer, null/*returnPart*/, messageInfo.RpcEncodedTyped
 0414            object bodyObject = Activator.CreateInstance(messageDescription.Body.Parts[0].Type);
 0415            int i = 0;
 0416            foreach (MessagePartDescription bodyPart in messageInfo.RpcEncodedTypedMessageBodyParts)
 417            {
 0418                MemberInfo member = bodyPart.MemberInfo;
 0419                FieldInfo field = member as FieldInfo;
 0420                if (field != null)
 421                {
 0422                    field.SetValue(bodyObject, bodyPartValues[i++]);
 423                }
 424                else
 425                {
 0426                    PropertyInfo property = member as PropertyInfo;
 0427                    if (property != null)
 428                    {
 0429                        property.SetValue(bodyObject, bodyPartValues[i++], null);
 430                    }
 431                }
 432            }
 0433            parameters[messageDescription.Body.Parts[0].Index] = bodyObject;
 0434            return null;
 435        }
 436
 437        private object DeserializeBody(XmlDictionaryReader reader, MessageVersion version, XmlSerializer serializer, Mes
 438        {
 439            try
 440            {
 20441                if (reader == null)
 442                {
 0443                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(reader)))
 444                }
 445
 20446                if (parameters == null)
 447                {
 0448                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(parameter
 449                }
 450
 20451                object returnValue = null;
 20452                if (serializer == null)
 453                {
 0454                    return null;
 455                }
 20456                if (reader.NodeType == XmlNodeType.EndElement)
 457                {
 0458                    return null;
 459                }
 460
 20461                object[] bodyParameters = (object[])serializer.Deserialize(reader, _isEncoded ? GetEncoding(version.Enve
 462
 20463                int paramIndex = 0;
 20464                if (IsValidReturnValue(returnPart))
 465                {
 0466                    returnValue = bodyParameters[paramIndex++];
 467                }
 468
 86469                for (int i = 0; i < bodyParts.Count; i++)
 470                {
 23471                    parameters[bodyParts[i].Index] = bodyParameters[paramIndex++];
 472                }
 473
 20474                return returnValue;
 475            }
 0476            catch (InvalidOperationException e)
 477            {
 478                // all exceptions from XmlSerializer get wrapped in InvalidOperationException,
 479                // so we must be conservative and never turn this into a fault
 0480                string resourceKey = isRequest ? SR.SFxErrorDeserializingRequestBody : SR.SFxErrorDeserializingReplyBody
 481
 0482                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
 0483                    SR.Format(resourceKey, OperationName), e));
 484            }
 20485        }
 486
 487        internal static string GetEncoding(EnvelopeVersion version)
 488        {
 13489            if (version == EnvelopeVersion.Soap11)
 490            {
 11491                return soap11Encoding;
 492            }
 2493            else if (version == EnvelopeVersion.Soap12)
 494            {
 2495                return soap12Encoding;
 496            }
 497            else
 498            {
 0499                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(version),
 0500                    SR.Format(SR.EnvelopeVersionNotSupported, version));
 501            }
 502        }
 503
 504        internal abstract class MessageInfo
 505        {
 506            internal abstract XmlSerializer BodySerializer { get; }
 507            internal abstract XmlSerializer HeaderSerializer { get; }
 508            internal abstract MessageHeaderDescriptionTable HeaderDescriptionTable { get; }
 509            internal abstract MessageHeaderDescription UnknownHeaderDescription { get; }
 510            internal abstract MessagePartDescriptionCollection RpcEncodedTypedMessageBodyParts { get; }
 511        }
 512
 513        private class MessageHeaderOfTHelper
 514        {
 515            private readonly object[] _attributes;
 0516            internal MessageHeaderOfTHelper(int parameterCount)
 517            {
 0518                _attributes = new object[parameterCount];
 0519            }
 520            internal object GetContentAndSaveHeaderAttributes(object parameterValue, MessageHeaderDescription headerDesc
 521            {
 0522                if (parameterValue == null)
 523                {
 0524                    return null;
 525                }
 526
 527                bool mustUnderstand;
 528                bool relay;
 529                string actor;
 0530                if (headerDescription.Multiple)
 531                {
 0532                    object[] messageHeaderOfTArray = (object[])parameterValue;
 0533                    MessageHeader<object>[] messageHeaderOfTAttributes = new MessageHeader<object>[messageHeaderOfTArray
 0534                    Array tArray = Array.CreateInstance(headerDescription.Type, messageHeaderOfTArray.Length);
 0535                    for (int i = 0; i < tArray.Length; i++)
 536                    {
 0537                        tArray.SetValue(GetContentOfMessageHeaderOfT(headerDescription, messageHeaderOfTArray[i], out mu
 0538                        messageHeaderOfTAttributes[i] = new MessageHeader<object>(null, mustUnderstand, actor, relay);
 539                    }
 0540                    _attributes[headerDescription.Index] = messageHeaderOfTAttributes;
 0541                    return tArray;
 542                }
 543                else
 544                {
 0545                    object content = GetContentOfMessageHeaderOfT(headerDescription, parameterValue, out mustUnderstand,
 0546                    _attributes[headerDescription.Index] = new MessageHeader<object>(null, mustUnderstand, actor, relay)
 0547                    return content;
 548                }
 549            }
 550
 551            internal void GetHeaderAttributes(MessageHeaderDescription headerDescription, out bool mustUnderstand, out b
 552            {
 0553                MessageHeader<object> matchingMessageHeaderOfTAttribute = null;
 0554                if (headerDescription.Multiple)
 555                {
 0556                    MessageHeader<object>[] messageHeaderOfTAttributes = (MessageHeader<object>[])_attributes[headerDesc
 0557                    for (int i = 0; i < messageHeaderOfTAttributes.Length; i++)
 558                    {
 0559                        if (messageHeaderOfTAttributes[i] != null)
 560                        {
 0561                            matchingMessageHeaderOfTAttribute = messageHeaderOfTAttributes[i];
 0562                            messageHeaderOfTAttributes[i] = null;
 0563                            break;
 564                        }
 565                    }
 566                    //assert(matchingMessageHeaderOfTAttribute != null);
 567
 568                }
 569                else
 570                {
 0571                    matchingMessageHeaderOfTAttribute = (MessageHeader<object>)_attributes[headerDescription.Index];
 572                }
 573
 0574                mustUnderstand = matchingMessageHeaderOfTAttribute.MustUnderstand;
 0575                relay = matchingMessageHeaderOfTAttribute.Relay;
 0576                actor = matchingMessageHeaderOfTAttribute.Actor;
 0577            }
 578
 579            internal void SetHeaderAttributes(MessageHeaderDescription headerDescription, bool mustUnderstand, bool rela
 580            {
 0581                if (headerDescription.Multiple)
 582                {
 0583                    if (_attributes[headerDescription.Index] == null)
 584                    {
 0585                        _attributes[headerDescription.Index] = new List<MessageHeader<object>>();
 0586                    } ((List<MessageHeader<object>>)_attributes[headerDescription.Index]).Add(new MessageHeader<object>(
 587                }
 588                else
 589                {
 0590                    _attributes[headerDescription.Index] = new MessageHeader<object>(null, mustUnderstand, actor, relay)
 591                }
 0592            }
 593            internal object CreateMessageHeader(MessageHeaderDescription headerDescription, object headerValue)
 594            {
 0595                if (headerDescription.Multiple)
 596                {
 0597                    IList<MessageHeader<object>> messageHeaderOfTAttributes = (IList<MessageHeader<object>>)_attributes[
 0598                    object[] messageHeaderOfTArray = (object[])Array.CreateInstance(TypedHeaderManager.GetMessageHeaderT
 0599                    Array headerValues = (Array)headerValue;
 0600                    for (int i = 0; i < messageHeaderOfTArray.Length; i++)
 601                    {
 0602                        MessageHeader<object> messageHeaderOfTAttribute = messageHeaderOfTAttributes[i];
 0603                        messageHeaderOfTArray[i] = TypedHeaderManager.Create(headerDescription.Type, headerValues.GetVal
 0604                                                                      messageHeaderOfTAttribute.MustUnderstand, messageH
 605                    }
 0606                    return messageHeaderOfTArray;
 607                }
 608                else
 609                {
 0610                    MessageHeader<object> messageHeaderOfTAttribute = (MessageHeader<object>)_attributes[headerDescripti
 0611                    return TypedHeaderManager.Create(headerDescription.Type, headerValue,
 0612                                                                  messageHeaderOfTAttribute.MustUnderstand, messageHeade
 613                }
 614            }
 615        }
 616    }
 617}

Methods/Properties

.ctor(CoreWCF.Description.OperationDescription,CoreWCF.XmlSerializerFormatAttribute,CoreWCF.Dispatcher.XmlSerializerOperationFormatter/MessageInfo,CoreWCF.Dispatcher.XmlSerializerOperationFormatter/MessageInfo)
AddHeadersToMessage(CoreWCF.Channels.Message,CoreWCF.Description.MessageDescription,System.Object[],System.Boolean)
GetHeadersFromMessage(CoreWCF.Channels.Message,CoreWCF.Description.MessageDescription,System.Object[],System.Boolean)
AddUnknownHeader(CoreWCF.Description.MessageHeaderDescription,System.Collections.ArrayList,System.Xml.XmlDocument,System.Xml.XmlDictionaryWriter,CoreWCF.Channels.MessageHeaderInfo,System.Xml.XmlDictionaryReader)
WriteBodyAttributes(System.Xml.XmlDictionaryWriter,CoreWCF.Channels.MessageVersion)
SerializeBody(System.Xml.XmlDictionaryWriter,CoreWCF.Channels.MessageVersion,System.String,CoreWCF.Description.MessageDescription,System.Object,System.Object[],System.Boolean)
SerializeBody(System.Xml.XmlDictionaryWriter,CoreWCF.Channels.MessageVersion,System.Xml.Serialization.XmlSerializer,CoreWCF.Description.MessagePartDescription,CoreWCF.Description.MessagePartDescriptionCollection,System.Object,System.Object[])
DeserializeBody(System.Xml.XmlDictionaryReader,CoreWCF.Channels.MessageVersion,System.String,CoreWCF.Description.MessageDescription,System.Object[],System.Boolean)
DeserializeBody(System.Xml.XmlDictionaryReader,CoreWCF.Channels.MessageVersion,System.Xml.Serialization.XmlSerializer,CoreWCF.Description.MessagePartDescription,CoreWCF.Description.MessagePartDescriptionCollection,System.Object[],System.Boolean)
GetEncoding(CoreWCF.EnvelopeVersion)
.ctor(System.Int32)
GetContentAndSaveHeaderAttributes(System.Object,CoreWCF.Description.MessageHeaderDescription)
GetHeaderAttributes(CoreWCF.Description.MessageHeaderDescription,System.Boolean&,System.Boolean&,System.String&)
SetHeaderAttributes(CoreWCF.Description.MessageHeaderDescription,System.Boolean,System.Boolean,System.String)
CreateMessageHeader(CoreWCF.Description.MessageHeaderDescription,System.Object)