public static void SetHeaderMembers(SoapHeaderCollection headers, object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, bool client) { bool[] flagArray = new bool[headers.Count]; if (mappings != null) { for (int j = 0; j < mappings.Length; j++) { SoapHeaderMapping mapping = mappings[j]; if ((mapping.direction & direction) != 0) { if (mapping.repeats) { ArrayList list = new ArrayList(); for (int k = 0; k < headers.Count; k++) { SoapHeader header = headers[k]; if (!flagArray[k] && mapping.headerType.IsAssignableFrom(header.GetType())) { list.Add(header); flagArray[k] = true; } } MemberHelper.SetValue(mapping.memberInfo, target, list.ToArray(mapping.headerType)); } else { bool flag = false; for (int m = 0; m < headers.Count; m++) { SoapHeader header2 = headers[m]; if (!flagArray[m] && mapping.headerType.IsAssignableFrom(header2.GetType())) { if (flag) { header2.DidUnderstand = false; } else { flag = true; MemberHelper.SetValue(mapping.memberInfo, target, header2); flagArray[m] = true; } } } } } } } for (int i = 0; i < flagArray.Length; i++) { if (!flagArray[i]) { SoapHeader header3 = headers[i]; if (header3.MustUnderstand && !header3.DidUnderstand) { throw new SoapHeaderException(System.Web.Services.Res.GetString("WebCannotUnderstandHeader", new object[] { GetHeaderElementName(header3) }), new XmlQualifiedName("MustUnderstand", "http://schemas.xmlsoap.org/soap/envelope/")); } } } }
internal static void SetHeaderMembers(SoapHeaderCollection headers, object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, bool client) { bool[] headerHandled = new bool[headers.Count]; for (int i = 0; i < mappings.Length; i++) { SoapHeaderMapping mapping = mappings[i]; if ((mapping.direction & direction) == 0) { continue; } if (mapping.repeats) { ArrayList list = new ArrayList(); for (int j = 0; j < headers.Count; j++) { SoapHeader header = headers[j]; if (headerHandled[j]) { continue; } if (mapping.headerType.IsAssignableFrom(header.GetType())) { list.Add(header); headerHandled[j] = true; } } MemberHelper.SetValue(mapping.memberInfo, target, list.ToArray(mapping.headerType)); } else { bool handled = false; for (int j = 0; j < headers.Count; j++) { SoapHeader header = headers[j]; if (headerHandled[j]) { continue; } if (mapping.headerType.IsAssignableFrom(header.GetType())) { if (handled) { header.DidUnderstand = false; continue; } handled = true; MemberHelper.SetValue(mapping.memberInfo, target, header); headerHandled[j] = true; } } } } if (client) { for (int i = 0; i < headerHandled.Length; i++) { if (!headerHandled[i]) { SoapHeader header = headers[i]; if (header.MustUnderstand && !header.DidUnderstand) { throw new SoapHeaderException(Res.GetString(Res.WebCannotUnderstandHeader, GetHeaderElementName(header)), new XmlQualifiedName(Soap.MustUnderstandCode, Soap.Namespace)); } } } } }