public GetAttribute ( string name, string ns ) : System.Xml.Serialization.XmlTypeMapMemberAttribute | ||
name | string | |
ns | string | |
return | System.Xml.Serialization.XmlTypeMapMemberAttribute |
void ReadAttributeMembers(ClassMap map, object ob, bool isValueList) { XmlTypeMapMember anyAttrMember = map.DefaultAnyAttributeMember; int anyAttributeIndex = 0; object anyAttributeArray = null; while (Reader.MoveToNextAttribute()) { XmlTypeMapMemberAttribute member = map.GetAttribute(Reader.LocalName, Reader.NamespaceURI); if (member != null) { SetMemberValue(member, ob, GetValueFromXmlString(Reader.Value, member.TypeData, member.MappedType), isValueList); } else if (IsXmlnsAttribute(Reader.Name)) { // If the map has NamespaceDeclarations, // then store this xmlns to the given member. // If the instance doesn't exist, then create. if (map.NamespaceDeclarations != null) { XmlSerializerNamespaces nss = this.GetMemberValue(map.NamespaceDeclarations, ob, isValueList) as XmlSerializerNamespaces; if (nss == null) { nss = new XmlSerializerNamespaces(); SetMemberValue(map.NamespaceDeclarations, ob, nss, isValueList); } if (Reader.Prefix == "xmlns") { nss.Add(Reader.LocalName, Reader.Value); } else { nss.Add("", Reader.Value); } } } #if !MOONLIGHT else if (anyAttrMember != null) { XmlAttribute attr = (XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); AddListValue(anyAttrMember.TypeData, ref anyAttributeArray, anyAttributeIndex++, attr, true); } else { ProcessUnknownAttribute(ob); } #endif } #if !MOONLIGHT if (anyAttrMember != null) { anyAttributeArray = ShrinkArray((Array)anyAttributeArray, anyAttributeIndex, anyAttrMember.TypeData.Type.GetElementType(), true); SetMemberValue(anyAttrMember, ob, anyAttributeArray, isValueList); } #endif Reader.MoveToElement(); }
private void ReadAttributeMembers(ClassMap map, object ob, bool isValueList) { XmlTypeMapMember defaultAnyAttributeMember = map.DefaultAnyAttributeMember; int length = 0; object obj = null; while (base.Reader.MoveToNextAttribute()) { XmlTypeMapMemberAttribute attribute = map.GetAttribute(base.Reader.LocalName, base.Reader.NamespaceURI); if (attribute != null) { this.SetMemberValue(attribute, ob, this.GetValueFromXmlString(base.Reader.Value, attribute.TypeData, attribute.MappedType), isValueList); } else if (base.IsXmlnsAttribute(base.Reader.Name)) { if (map.NamespaceDeclarations != null) { XmlSerializerNamespaces xmlSerializerNamespaces = this.GetMemberValue(map.NamespaceDeclarations, ob, isValueList) as XmlSerializerNamespaces; if (xmlSerializerNamespaces == null) { xmlSerializerNamespaces = new XmlSerializerNamespaces(); this.SetMemberValue(map.NamespaceDeclarations, ob, xmlSerializerNamespaces, isValueList); } if (base.Reader.Prefix == "xmlns") { xmlSerializerNamespaces.Add(base.Reader.LocalName, base.Reader.Value); } else { xmlSerializerNamespaces.Add(string.Empty, base.Reader.Value); } } } else if (defaultAnyAttributeMember != null) { XmlAttribute xmlAttribute = (XmlAttribute)base.Document.ReadNode(base.Reader); base.ParseWsdlArrayType(xmlAttribute); this.AddListValue(defaultAnyAttributeMember.TypeData, ref obj, length++, xmlAttribute, true); } else { this.ProcessUnknownAttribute(ob); } } if (defaultAnyAttributeMember != null) { obj = base.ShrinkArray((Array)obj, length, defaultAnyAttributeMember.TypeData.Type.GetElementType(), true); this.SetMemberValue(defaultAnyAttributeMember, ob, obj, isValueList); } base.Reader.MoveToElement(); }
// Attributes might be redefined, so there is an existing attribute for the same name, skip it. // FIXME: this is nothing more than just a hack. // Basically it should use // XmlSchemaComplexType.AttributeUses. XmlSchemaObjectCollection CollectAttributeUsesNonOverlap ( XmlSchemaObjectCollection src, ClassMap map) { XmlSchemaObjectCollection atts = new XmlSchemaObjectCollection (); foreach (XmlSchemaAttribute a in src) if (map.GetAttribute (a.QualifiedName.Name, a.QualifiedName.Namespace) == null) atts.Add (a); return atts; }
void ReadAttributeMembers (ClassMap map, object ob, bool isValueList) { XmlTypeMapMember anyAttrMember = map.DefaultAnyAttributeMember; int anyAttributeIndex = 0; object anyAttributeArray = null; while (Reader.MoveToNextAttribute()) { XmlTypeMapMemberAttribute member = map.GetAttribute (Reader.LocalName, Reader.NamespaceURI); if (member != null) { SetMemberValue (member, ob, GetValueFromXmlString (Reader.Value, member.TypeData, member.MappedType), isValueList); } else if (IsXmlnsAttribute(Reader.Name)) { // If the map has NamespaceDeclarations, // then store this xmlns to the given member. // If the instance doesn't exist, then create. if (map.NamespaceDeclarations != null) { XmlSerializerNamespaces nss = this.GetMemberValue (map.NamespaceDeclarations, ob, isValueList) as XmlSerializerNamespaces; if (nss == null) { nss = new XmlSerializerNamespaces (); SetMemberValue (map.NamespaceDeclarations, ob, nss, isValueList); } if (Reader.Prefix == "xmlns") nss.Add (Reader.LocalName, Reader.Value); else nss.Add ("", Reader.Value); } } else if (anyAttrMember != null) { XmlAttribute attr = (XmlAttribute) Document.ReadNode(Reader); ParseWsdlArrayType (attr); AddListValue (anyAttrMember.TypeData, ref anyAttributeArray, anyAttributeIndex++, attr, true); } else ProcessUnknownAttribute(ob); } if (anyAttrMember != null) { anyAttributeArray = ShrinkArray ((Array)anyAttributeArray, anyAttributeIndex, anyAttrMember.TypeData.Type.GetElementType(), true); SetMemberValue (anyAttrMember, ob, anyAttributeArray, isValueList); } Reader.MoveToElement (); }
// Attributes might be redefined, so there is an existing attribute for the same name, skip it. // FIXME: this is nothing more than just a hack. // Basically it should use // XmlSchemaComplexType.AttributeUses. XmlSchemaObjectCollection CollectAttributeUsesNonOverlap ( XmlSchemaObjectCollection src, ClassMap map) { XmlSchemaObjectCollection atts = new XmlSchemaObjectCollection (); foreach (var a in EnumerateAttributes (src, new List<XmlSchemaAttributeGroup> ())) if (map.GetAttribute (a.QualifiedName.Name, a.QualifiedName.Namespace) == null) atts.Add (a); return atts; }
void ReadMembers (ClassMap map, object ob, bool isValueList, bool readByOrder) { // Set the default values of the members if (map.MembersWithDefault != null) { ArrayList members = map.MembersWithDefault; for (int n=0; n<members.Count; n++) { XmlTypeMapMember mem = (XmlTypeMapMember) members[n]; SetMemberValueFromAttr (mem, ob, mem.DefaultValue, isValueList); } } // Reads attributes XmlTypeMapMember anyAttrMember = map.DefaultAnyAttributeMember; int anyAttributeIndex = 0; object anyAttributeArray = null; while (Reader.MoveToNextAttribute()) { XmlTypeMapMemberAttribute member = map.GetAttribute (Reader.LocalName, Reader.NamespaceURI); if (member != null) { SetMemberValue (member, ob, GetValueFromXmlString (Reader.Value, member.TypeData, member.MappedType), isValueList); } else if (IsXmlnsAttribute(Reader.Name)) { // If the map has NamespaceDeclarations, // then store this xmlns to the given member. // If the instance doesn't exist, then create. if (map.NamespaceDeclarations != null) { XmlSerializerNamespaces nss = this.GetMemberValue (map.NamespaceDeclarations, ob, isValueList) as XmlSerializerNamespaces; if (nss == null) { nss = new XmlSerializerNamespaces (); SetMemberValue (map.NamespaceDeclarations, ob, nss, isValueList); } if (Reader.Prefix == "xmlns") nss.Add (Reader.LocalName, Reader.Value); else nss.Add ("", Reader.Value); } } else if (anyAttrMember != null) { XmlAttribute attr = (XmlAttribute) Document.ReadNode(Reader); ParseWsdlArrayType (attr); AddListValue (anyAttrMember.TypeData, ref anyAttributeArray, anyAttributeIndex++, attr, true); } else ProcessUnknownAttribute(ob); } if (anyAttrMember != null) { anyAttributeArray = ShrinkArray ((Array)anyAttributeArray, anyAttributeIndex, anyAttrMember.TypeData.Type.GetElementType(), true); SetMemberValue (anyAttrMember, ob, anyAttributeArray, isValueList); } if (!isValueList) { Reader.MoveToElement(); if (Reader.IsEmptyElement) return; Reader.ReadStartElement(); } // Reads elements bool[] readFlag = new bool[(map.ElementMembers != null) ? map.ElementMembers.Count : 0]; bool hasAnyReturnMember = (isValueList && _format == SerializationFormat.Encoded && map.ReturnMember != null && map.ReturnMember.TypeData.Type == typeof(object)); Reader.MoveToContent(); int[] indexes = null; object[] flatLists = null; Fixup fixup = null; int ind = 0; int maxInd; if (readByOrder) { if (map.ElementMembers != null) maxInd = map.ElementMembers.Count; else maxInd = 0; } else maxInd = int.MaxValue; if (map.FlatLists != null) { indexes = new int[map.FlatLists.Count]; flatLists = new object[map.FlatLists.Count]; foreach (XmlTypeMapMemberExpandable mem in map.FlatLists) if (IsReadOnly (mem, ob, isValueList)) flatLists[mem.FlatArrayIndex] = mem.GetValue (ob); } if (_format == SerializationFormat.Encoded && map.ElementMembers != null) { FixupCallbackInfo info = new FixupCallbackInfo (this, map, isValueList); fixup = new Fixup(ob, new XmlSerializationFixupCallback(info.FixupMembers), map.ElementMembers.Count); AddFixup (fixup); } while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && (ind < maxInd)) { if (Reader.NodeType == System.Xml.XmlNodeType.Element) { XmlTypeMapElementInfo info; if (readByOrder) { info = map.GetElement (ind++); } else if (hasAnyReturnMember) { info = (XmlTypeMapElementInfo) ((XmlTypeMapMemberElement)map.ReturnMember).ElementInfo[0]; hasAnyReturnMember = false; } else info = map.GetElement (Reader.LocalName, Reader.NamespaceURI); if (info != null && !readFlag[info.Member.Index] ) { if (info.Member.GetType() == typeof (XmlTypeMapMemberList)) { if (_format == SerializationFormat.Encoded && info.MultiReferenceType) { object list = ReadReferencingElement (out fixup.Ids[info.Member.Index]); if (fixup.Ids[info.Member.Index] == null) // Already read { if (IsReadOnly (info.Member, ob, isValueList)) throw CreateReadOnlyCollectionException (info.TypeData.FullTypeName); else SetMemberValue (info.Member, ob, list, isValueList); } else if (!info.MappedType.TypeData.Type.IsArray) { if (IsReadOnly (info.Member, ob, isValueList)) list = GetMemberValue (info.Member, ob, isValueList); else { list = CreateList (info.MappedType.TypeData.Type); SetMemberValue (info.Member, ob, list, isValueList); } AddFixup (new CollectionFixup (list, new XmlSerializationCollectionFixupCallback (FillList), fixup.Ids[info.Member.Index])); fixup.Ids[info.Member.Index] = null; // The member already has the value, no further fix needed. } } else { if (IsReadOnly (info.Member, ob, isValueList)) ReadListElement (info.MappedType, info.IsNullable, GetMemberValue (info.Member, ob, isValueList), false); else SetMemberValue (info.Member, ob, ReadListElement (info.MappedType, info.IsNullable, null, true), isValueList); } readFlag[info.Member.Index] = true; } else if (info.Member.GetType() == typeof (XmlTypeMapMemberFlatList)) { XmlTypeMapMemberFlatList mem = (XmlTypeMapMemberFlatList)info.Member; AddListValue (mem.TypeData, ref flatLists[mem.FlatArrayIndex], indexes[mem.FlatArrayIndex]++, ReadObjectElement (info), !IsReadOnly (info.Member, ob, isValueList)); } else if (info.Member.GetType() == typeof (XmlTypeMapMemberAnyElement)) { XmlTypeMapMemberAnyElement mem = (XmlTypeMapMemberAnyElement)info.Member; if (mem.TypeData.IsListType) AddListValue (mem.TypeData, ref flatLists[mem.FlatArrayIndex], indexes[mem.FlatArrayIndex]++, ReadXmlNode (mem.TypeData.ListItemTypeData, false), true); else SetMemberValue (mem, ob, ReadXmlNode (mem.TypeData, false), isValueList); } else if (info.Member.GetType() == typeof(XmlTypeMapMemberElement)) { object val; readFlag[info.Member.Index] = true; if (_format == SerializationFormat.Encoded) { val = ReadReferencingElement (out fixup.Ids[info.Member.Index]); if (info.MultiReferenceType) { if (fixup.Ids[info.Member.Index] == null) // already read SetMemberValue (info.Member, ob, val, isValueList); } else if (val != null) SetMemberValue (info.Member, ob, val, isValueList); } else SetMemberValue (info.Member, ob, ReadObjectElement (info), isValueList); } else throw new InvalidOperationException ("Unknown member type"); } else if (map.DefaultAnyElementMember != null) { XmlTypeMapMemberAnyElement mem = map.DefaultAnyElementMember; if (mem.TypeData.IsListType) AddListValue (mem.TypeData, ref flatLists[mem.FlatArrayIndex], indexes[mem.FlatArrayIndex]++, ReadXmlNode (mem.TypeData.ListItemTypeData, false), true); else SetMemberValue (mem, ob, ReadXmlNode (mem.TypeData, false), isValueList); } else ProcessUnknownElement(ob); } else if (Reader.NodeType == System.Xml.XmlNodeType.Text && map.XmlTextCollector != null) { if (map.XmlTextCollector is XmlTypeMapMemberExpandable) { XmlTypeMapMemberExpandable mem = (XmlTypeMapMemberExpandable)map.XmlTextCollector; XmlTypeMapMemberFlatList flatl = mem as XmlTypeMapMemberFlatList; TypeData itype = (flatl == null) ? mem.TypeData.ListItemTypeData : flatl.ListMap.FindTextElement().TypeData; object val = (itype.Type == typeof (string)) ? (object) Reader.ReadString() : (object) ReadXmlNode (itype, false); AddListValue (mem.TypeData, ref flatLists[mem.FlatArrayIndex], indexes[mem.FlatArrayIndex]++, val, true); } else { XmlTypeMapMemberElement mem = (XmlTypeMapMemberElement) map.XmlTextCollector; XmlTypeMapElementInfo info = (XmlTypeMapElementInfo) mem.ElementInfo [0]; if (info.TypeData.Type == typeof (string)) SetMemberValue (mem, ob, ReadString ((string) GetMemberValue (mem, ob, isValueList)), isValueList); else SetMemberValue (mem, ob, GetValueFromXmlString (Reader.ReadString(), info.TypeData, info.MappedType), isValueList); } } else UnknownNode(ob); Reader.Read(); Reader.MoveToContent(); } if (flatLists != null) { foreach (XmlTypeMapMemberExpandable mem in map.FlatLists) { Object list = flatLists[mem.FlatArrayIndex]; if (mem.TypeData.Type.IsArray) list = ShrinkArray ((Array)list, indexes[mem.FlatArrayIndex], mem.TypeData.Type.GetElementType(), true); if (!IsReadOnly (mem, ob, isValueList)) SetMemberValue (mem, ob, list, isValueList); } } }
void ReadMembers(ClassMap map, object ob, bool isValueList, bool readByOrder) { // Set the default values of the members if (map.MembersWithDefault != null) { ArrayList members = map.MembersWithDefault; for (int n = 0; n < members.Count; n++) { XmlTypeMapMember mem = (XmlTypeMapMember)members[n]; SetMemberValueFromAttr(mem, ob, mem.DefaultValue, isValueList); } } // Reads attributes XmlTypeMapMember anyAttrMember = map.DefaultAnyAttributeMember; int anyAttributeIndex = 0; object anyAttributeArray = null; while (Reader.MoveToNextAttribute()) { XmlTypeMapMemberAttribute member = map.GetAttribute(Reader.LocalName, Reader.NamespaceURI); if (member != null) { SetMemberValue(member, ob, GetValueFromXmlString(Reader.Value, member.TypeData, member.MappedType), isValueList); } else if (IsXmlnsAttribute(Reader.Name)) { // If the map has NamespaceDeclarations, // then store this xmlns to the given member. // If the instance doesn't exist, then create. if (map.NamespaceDeclarations != null) { XmlSerializerNamespaces nss = this.GetMemberValue(map.NamespaceDeclarations, ob, isValueList) as XmlSerializerNamespaces; if (nss == null) { nss = new XmlSerializerNamespaces(); SetMemberValue(map.NamespaceDeclarations, ob, nss, isValueList); } if (Reader.Prefix == "xmlns") { nss.Add(Reader.LocalName, Reader.Value); } else { nss.Add("", Reader.Value); } } } else if (anyAttrMember != null) { XmlAttribute attr = (XmlAttribute)Document.ReadNode(Reader); ParseWsdlArrayType(attr); AddListValue(anyAttrMember.TypeData, ref anyAttributeArray, anyAttributeIndex++, attr, true); } else { ProcessUnknownAttribute(ob); } } if (anyAttrMember != null) { anyAttributeArray = ShrinkArray((Array)anyAttributeArray, anyAttributeIndex, anyAttrMember.TypeData.Type.GetElementType(), true); SetMemberValue(anyAttrMember, ob, anyAttributeArray, isValueList); } if (!isValueList) { Reader.MoveToElement(); if (Reader.IsEmptyElement) { SetListMembersDefaults(map, ob, isValueList); return; } Reader.ReadStartElement(); } // Reads elements bool[] readFlag = new bool[(map.ElementMembers != null) ? map.ElementMembers.Count : 0]; bool hasAnyReturnMember = (isValueList && _format == SerializationFormat.Encoded && map.ReturnMember != null); Reader.MoveToContent(); int[] indexes = null; object[] flatLists = null; object[] flatListsChoices = null; Fixup fixup = null; int ind = 0; int maxInd; if (readByOrder) { if (map.ElementMembers != null) { maxInd = map.ElementMembers.Count; } else { maxInd = 0; } } else { maxInd = int.MaxValue; } if (map.FlatLists != null) { indexes = new int[map.FlatLists.Count]; flatLists = new object[map.FlatLists.Count]; foreach (XmlTypeMapMemberExpandable mem in map.FlatLists) { if (IsReadOnly(mem, mem.TypeData, ob, isValueList)) { flatLists[mem.FlatArrayIndex] = mem.GetValue(ob); } else if (mem.TypeData.Type.IsArray) { flatLists[mem.FlatArrayIndex] = InitializeList(mem.TypeData); } else { object list = mem.GetValue(ob); if (list == null) { list = InitializeList(mem.TypeData); SetMemberValue(mem, ob, list, isValueList); } flatLists[mem.FlatArrayIndex] = list; } if (mem.ChoiceMember != null) { if (flatListsChoices == null) { flatListsChoices = new object[map.FlatLists.Count]; } flatListsChoices[mem.FlatArrayIndex] = InitializeList(mem.ChoiceTypeData); } } } if (_format == SerializationFormat.Encoded && map.ElementMembers != null) { FixupCallbackInfo info = new FixupCallbackInfo(this, map, isValueList); fixup = new Fixup(ob, new XmlSerializationFixupCallback(info.FixupMembers), map.ElementMembers.Count); AddFixup(fixup); } while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && (ind < maxInd)) { if (Reader.NodeType == System.Xml.XmlNodeType.Element) { XmlTypeMapElementInfo info; if (readByOrder) { info = map.GetElement(ind++); } else if (hasAnyReturnMember) { info = (XmlTypeMapElementInfo)((XmlTypeMapMemberElement)map.ReturnMember).ElementInfo[0]; hasAnyReturnMember = false; } else { info = map.GetElement(Reader.LocalName, Reader.NamespaceURI); } if (info != null && !readFlag[info.Member.Index]) { if (info.Member.GetType() == typeof(XmlTypeMapMemberList)) { if (_format == SerializationFormat.Encoded && info.MultiReferenceType) { object list = ReadReferencingElement(out fixup.Ids[info.Member.Index]); if (fixup.Ids[info.Member.Index] == null) // Already read { if (IsReadOnly(info.Member, info.TypeData, ob, isValueList)) { throw CreateReadOnlyCollectionException(info.TypeData.FullTypeName); } else { SetMemberValue(info.Member, ob, list, isValueList); } } else if (!info.MappedType.TypeData.Type.IsArray) { if (IsReadOnly(info.Member, info.TypeData, ob, isValueList)) { list = GetMemberValue(info.Member, ob, isValueList); } else { list = CreateList(info.MappedType.TypeData.Type); SetMemberValue(info.Member, ob, list, isValueList); } AddFixup(new CollectionFixup(list, new XmlSerializationCollectionFixupCallback(FillList), fixup.Ids[info.Member.Index])); fixup.Ids[info.Member.Index] = null; // The member already has the value, no further fix needed. } } else { if (IsReadOnly(info.Member, info.TypeData, ob, isValueList)) { ReadListElement(info.MappedType, info.IsNullable, GetMemberValue(info.Member, ob, isValueList), false); } else if (info.MappedType.TypeData.Type.IsArray) { object list = ReadListElement(info.MappedType, info.IsNullable, null, true); if (list != null || info.IsNullable) { SetMemberValue(info.Member, ob, list, isValueList); } } else { // If the member already has a list, reuse that list. No need to create a new one. object list = GetMemberValue(info.Member, ob, isValueList); if (list == null) { list = CreateList(info.MappedType.TypeData.Type); SetMemberValue(info.Member, ob, list, isValueList); } ReadListElement(info.MappedType, info.IsNullable, list, true); } } readFlag[info.Member.Index] = true; } else if (info.Member.GetType() == typeof(XmlTypeMapMemberFlatList)) { XmlTypeMapMemberFlatList mem = (XmlTypeMapMemberFlatList)info.Member; AddListValue(mem.TypeData, ref flatLists[mem.FlatArrayIndex], indexes[mem.FlatArrayIndex]++, ReadObjectElement(info), !IsReadOnly(info.Member, info.TypeData, ob, isValueList)); if (mem.ChoiceMember != null) { AddListValue(mem.ChoiceTypeData, ref flatListsChoices[mem.FlatArrayIndex], indexes[mem.FlatArrayIndex] - 1, info.ChoiceValue, true); } } else if (info.Member.GetType() == typeof(XmlTypeMapMemberAnyElement)) { XmlTypeMapMemberAnyElement mem = (XmlTypeMapMemberAnyElement)info.Member; if (mem.TypeData.IsListType) { AddListValue(mem.TypeData, ref flatLists[mem.FlatArrayIndex], indexes[mem.FlatArrayIndex]++, ReadXmlNode(mem.TypeData.ListItemTypeData, false), true); } else { SetMemberValue(mem, ob, ReadXmlNode(mem.TypeData, false), isValueList); } } else if (info.Member.GetType() == typeof(XmlTypeMapMemberElement)) { object val; readFlag[info.Member.Index] = true; if (_format == SerializationFormat.Encoded) { if (info.Member.TypeData.SchemaType != SchemaTypes.Primitive) { val = ReadReferencingElement(out fixup.Ids[info.Member.Index]); } else { val = ReadReferencingElement(info.Member.TypeData.XmlType, System.Xml.Schema.XmlSchema.Namespace, out fixup.Ids[info.Member.Index]); } if (info.MultiReferenceType) { if (fixup.Ids[info.Member.Index] == null) // already read { SetMemberValue(info.Member, ob, val, isValueList); } } else if (val != null) { SetMemberValue(info.Member, ob, val, isValueList); } } else { SetMemberValue(info.Member, ob, ReadObjectElement(info), isValueList); if (info.ChoiceValue != null) { XmlTypeMapMemberElement imem = (XmlTypeMapMemberElement)info.Member; imem.SetChoice(ob, info.ChoiceValue); } } } else { throw new InvalidOperationException("Unknown member type"); } } else if (map.DefaultAnyElementMember != null) { XmlTypeMapMemberAnyElement mem = map.DefaultAnyElementMember; if (mem.TypeData.IsListType) { AddListValue(mem.TypeData, ref flatLists[mem.FlatArrayIndex], indexes[mem.FlatArrayIndex]++, ReadXmlNode(mem.TypeData.ListItemTypeData, false), true); } else { SetMemberValue(mem, ob, ReadXmlNode(mem.TypeData, false), isValueList); } } else { ProcessUnknownElement(ob); } } else if ((Reader.NodeType == System.Xml.XmlNodeType.Text || Reader.NodeType == System.Xml.XmlNodeType.CDATA) && map.XmlTextCollector != null) { if (map.XmlTextCollector is XmlTypeMapMemberExpandable) { XmlTypeMapMemberExpandable mem = (XmlTypeMapMemberExpandable)map.XmlTextCollector; XmlTypeMapMemberFlatList flatl = mem as XmlTypeMapMemberFlatList; TypeData itype = (flatl == null) ? mem.TypeData.ListItemTypeData : flatl.ListMap.FindTextElement().TypeData; object val = (itype.Type == typeof(string)) ? (object)Reader.ReadString() : (object)ReadXmlNode(itype, false); AddListValue(mem.TypeData, ref flatLists[mem.FlatArrayIndex], indexes[mem.FlatArrayIndex]++, val, true); } else { XmlTypeMapMemberElement mem = (XmlTypeMapMemberElement)map.XmlTextCollector; XmlTypeMapElementInfo info = (XmlTypeMapElementInfo)mem.ElementInfo[0]; if (info.TypeData.Type == typeof(string)) { SetMemberValue(mem, ob, ReadString((string)GetMemberValue(mem, ob, isValueList)), isValueList); } else { SetMemberValue(mem, ob, GetValueFromXmlString(Reader.ReadString(), info.TypeData, info.MappedType), isValueList); } } } else { UnknownNode(ob); } Reader.MoveToContent(); } if (flatLists != null) { foreach (XmlTypeMapMemberExpandable mem in map.FlatLists) { Object list = flatLists[mem.FlatArrayIndex]; if (mem.TypeData.Type.IsArray) { list = ShrinkArray((Array)list, indexes[mem.FlatArrayIndex], mem.TypeData.Type.GetElementType(), true); } if (!IsReadOnly(mem, mem.TypeData, ob, isValueList) && mem.TypeData.Type.IsArray) { SetMemberValue(mem, ob, list, isValueList); } } } if (flatListsChoices != null) { foreach (XmlTypeMapMemberExpandable mem in map.FlatLists) { Object list = flatListsChoices[mem.FlatArrayIndex]; if (list == null) { continue; } list = ShrinkArray((Array)list, indexes[mem.FlatArrayIndex], mem.ChoiceTypeData.Type.GetElementType(), true); XmlTypeMapMember.SetValue(ob, mem.ChoiceMember, list); } } SetListMembersDefaults(map, ob, isValueList); }