private static void AddUnknownHeader(MessageHeaderDescription unknownHeaderDescription, ArrayList unknownHeaders, XmlDocument xmlDoc, XmlDictionaryWriter bufferWriter, MessageHeaderInfo header, XmlDictionaryReader headerReader) { object content = xmlDoc.ReadNode(headerReader); if (bufferWriter != null) { ((XmlElement)content).WriteTo(bufferWriter); } if ((content != null) && unknownHeaderDescription.TypedHeader) { content = TypedHeaderManager.Create(unknownHeaderDescription.Type, content, header.MustUnderstand, header.Relay, header.Actor); } unknownHeaders.Add(content); }
internal object CreateMessageHeader(MessageHeaderDescription headerDescription, object headerValue) { if (headerDescription.Multiple) { IList <MessageHeader <object> > list = (IList <MessageHeader <object> >) this.attributes[headerDescription.Index]; object[] objArray = (object[])Array.CreateInstance(TypedHeaderManager.GetMessageHeaderType(headerDescription.Type), list.Count); Array array = (Array)headerValue; for (int i = 0; i < objArray.Length; i++) { MessageHeader <object> header = list[i]; objArray[i] = TypedHeaderManager.Create(headerDescription.Type, array.GetValue(i), header.MustUnderstand, header.Relay, header.Actor); } return(objArray); } MessageHeader <object> header2 = (MessageHeader <object>) this.attributes[headerDescription.Index]; return(TypedHeaderManager.Create(headerDescription.Type, headerValue, header2.MustUnderstand, header2.Relay, header2.Actor)); }
internal object CreateMessageHeader(MessageHeaderDescription headerDescription, object headerValue) { if (headerDescription.Multiple) { IList <MessageHeader <object> > messageHeaderOfTAttributes = (IList <MessageHeader <object> >)_attributes[headerDescription.Index]; object[] messageHeaderOfTArray = (object[])Array.CreateInstance(TypedHeaderManager.GetMessageHeaderType(headerDescription.Type), messageHeaderOfTAttributes.Count); Array headerValues = (Array)headerValue; for (int i = 0; i < messageHeaderOfTArray.Length; i++) { MessageHeader <object> messageHeaderOfTAttribute = messageHeaderOfTAttributes[i]; messageHeaderOfTArray[i] = TypedHeaderManager.Create(headerDescription.Type, headerValues.GetValue(i), messageHeaderOfTAttribute.MustUnderstand, messageHeaderOfTAttribute.Relay, messageHeaderOfTAttribute.Actor); } return(messageHeaderOfTArray); } else { MessageHeader <object> messageHeaderOfTAttribute = (MessageHeader <object>)_attributes[headerDescription.Index]; return(TypedHeaderManager.Create(headerDescription.Type, headerValue, messageHeaderOfTAttribute.MustUnderstand, messageHeaderOfTAttribute.Relay, messageHeaderOfTAttribute.Actor)); } }
protected override void GetHeadersFromMessage(Message message, MessageDescription messageDescription, object[] parameters, bool isRequest) { MessageInfo messageInfo = isRequest ? requestMessageInfo : replyMessageInfo; if (!messageInfo.AnyHeaders) { return; } MessageHeaders headers = message.Headers; KeyValuePair <Type, ArrayList>[] multipleHeaderValues = null; ArrayList elementList = null; if (messageInfo.UnknownHeaderDescription != null) { elementList = new ArrayList(); } for (int i = 0; i < headers.Count; i++) { MessageHeaderInfo header = headers[i]; MessageHeaderDescription headerDescription = messageInfo.HeaderDescriptionTable.Get(header.Name, header.Namespace); if (headerDescription != null) { if (header.MustUnderstand) { headers.UnderstoodHeaders.Add(header); } object item = null; XmlDictionaryReader headerReader = headers.GetReaderAtHeader(i); try { object dataValue = DeserializeHeaderContents(headerReader, messageDescription, headerDescription); if (headerDescription.TypedHeader) { item = TypedHeaderManager.Create(headerDescription.Type, dataValue, headers[i].MustUnderstand, headers[i].Relay, headers[i].Actor); } else { item = dataValue; } } finally { headerReader.Dispose(); } if (headerDescription.Multiple) { if (multipleHeaderValues == null) { multipleHeaderValues = new KeyValuePair <Type, ArrayList> [parameters.Length]; } if (multipleHeaderValues[headerDescription.Index].Key == null) { multipleHeaderValues[headerDescription.Index] = new KeyValuePair <System.Type, System.Collections.ArrayList>(headerDescription.TypedHeader ? TypedHeaderManager.GetMessageHeaderType(headerDescription.Type) : headerDescription.Type, new ArrayList()); } multipleHeaderValues[headerDescription.Index].Value.Add(item); } else { parameters[headerDescription.Index] = item; } } else if (messageInfo.UnknownHeaderDescription != null) { MessageHeaderDescription unknownHeaderDescription = messageInfo.UnknownHeaderDescription; XmlDictionaryReader headerReader = headers.GetReaderAtHeader(i); try { XmlDocument doc = new XmlDocument(); object dataValue = doc.ReadNode(headerReader); if (dataValue != null && unknownHeaderDescription.TypedHeader) { dataValue = TypedHeaderManager.Create(unknownHeaderDescription.Type, dataValue, headers[i].MustUnderstand, headers[i].Relay, headers[i].Actor); } elementList.Add(dataValue); } finally { headerReader.Dispose(); } } } if (multipleHeaderValues != null) { for (int i = 0; i < parameters.Length; i++) { if (multipleHeaderValues[i].Key != null) { parameters[i] = multipleHeaderValues[i].Value.ToArray(multipleHeaderValues[i].Key); } } } if (messageInfo.UnknownHeaderDescription != null) { parameters[messageInfo.UnknownHeaderDescription.Index] = elementList.ToArray(messageInfo.UnknownHeaderDescription.TypedHeader ? typeof(MessageHeader <XmlElement>) : typeof(XmlElement)); } }
protected override void GetHeadersFromMessage(Message message, MessageDescription messageDescription, object[] parameters, bool isRequest) { MessageInfo info = isRequest ? this.requestMessageInfo : this.replyMessageInfo; if (info.AnyHeaders) { MessageHeaders headers = message.Headers; KeyValuePair <System.Type, ArrayList>[] pairArray = null; ArrayList list = null; if (info.UnknownHeaderDescription != null) { list = new ArrayList(); } for (int i = 0; i < headers.Count; i++) { MessageHeaderInfo headerInfo = headers[i]; MessageHeaderDescription headerDescription = info.HeaderDescriptionTable.Get(headerInfo.Name, headerInfo.Namespace); if (headerDescription != null) { if (headerInfo.MustUnderstand) { headers.UnderstoodHeaders.Add(headerInfo); } object obj2 = null; XmlDictionaryReader readerAtHeader = headers.GetReaderAtHeader(i); try { object content = this.DeserializeHeaderContents(readerAtHeader, message.Version, headerDescription); if (headerDescription.TypedHeader) { obj2 = TypedHeaderManager.Create(headerDescription.Type, content, headers[i].MustUnderstand, headers[i].Relay, headers[i].Actor); } else { obj2 = content; } } finally { readerAtHeader.Close(); } if (headerDescription.Multiple) { if (pairArray == null) { pairArray = new KeyValuePair <System.Type, ArrayList> [parameters.Length]; } if (pairArray[headerDescription.Index].Key == null) { pairArray[headerDescription.Index] = new KeyValuePair <System.Type, ArrayList>(headerDescription.TypedHeader ? TypedHeaderManager.GetMessageHeaderType(headerDescription.Type) : headerDescription.Type, new ArrayList()); } pairArray[headerDescription.Index].Value.Add(obj2); } else { parameters[headerDescription.Index] = obj2; } } else if (info.UnknownHeaderDescription != null) { MessageHeaderDescription unknownHeaderDescription = info.UnknownHeaderDescription; XmlDictionaryReader reader = headers.GetReaderAtHeader(i); try { object obj4 = new XmlDocument().ReadNode(reader); if ((obj4 != null) && unknownHeaderDescription.TypedHeader) { obj4 = TypedHeaderManager.Create(unknownHeaderDescription.Type, obj4, headers[i].MustUnderstand, headers[i].Relay, headers[i].Actor); } list.Add(obj4); } finally { reader.Close(); } } } if (pairArray != null) { for (int j = 0; j < parameters.Length; j++) { if (pairArray[j].Key != null) { parameters[j] = pairArray[j].Value.ToArray(pairArray[j].Key); } } } if (info.UnknownHeaderDescription != null) { parameters[info.UnknownHeaderDescription.Index] = list.ToArray(info.UnknownHeaderDescription.TypedHeader ? typeof(MessageHeader <XmlElement>) : typeof(XmlElement)); } } }