public void AddMappingMetadata(CodeAttributeDeclarationCollection metadata, XmlTypeMapping member, string ns) { if ((member.TypeData.SchemaType == SchemaTypes.Primitive || member.TypeData.SchemaType == SchemaTypes.Array) && member.Namespace != XmlSchema.Namespace) { CodeAttributeDeclaration ratt = new CodeAttributeDeclaration("Mpd.Xml.Serialization.XmlRoot"); ratt.Arguments.Add(MapCodeGenerator.GetArg(member.ElementName)); ratt.Arguments.Add(MapCodeGenerator.GetArg("Namespace", member.Namespace)); ratt.Arguments.Add(MapCodeGenerator.GetArg("IsNullable", member.IsNullable)); metadata.Add(ratt); } }
public void AddMappingMetadata(CodeAttributeDeclarationCollection metadata, XmlMemberMapping member, string ns, bool forceUseMemberName) { CodeAttributeDeclaration att; TypeData memType = member.TypeMapMember.TypeData; if (member.Any) { XmlTypeMapElementInfoList list = (XmlTypeMapElementInfoList)((XmlTypeMapMemberElement)member.TypeMapMember).ElementInfo; foreach (XmlTypeMapElementInfo info in list) { if (info.IsTextElement) { metadata.Add(new CodeAttributeDeclaration("Mpd.Xml.Serialization.XmlText")); } else { att = new CodeAttributeDeclaration("Mpd.Xml.Serialization.XmlAnyElement"); if (!info.IsUnnamedAnyElement) { att.Arguments.Add(MapCodeGenerator.GetArg("Name", info.ElementName)); if (info.Namespace != ns) { att.Arguments.Add(MapCodeGenerator.GetArg("Namespace", member.Namespace)); } } metadata.Add(att); } } } else if (member.TypeMapMember is XmlTypeMapMemberList) { // Array parameter XmlTypeMapMemberList list = member.TypeMapMember as XmlTypeMapMemberList; ListMap listMap = (ListMap)list.ListTypeMapping.ObjectMap; codeGenerator.AddArrayAttributes(metadata, list, ns, forceUseMemberName); codeGenerator.AddArrayItemAttributes(metadata, listMap, memType.ListItemTypeData, list.Namespace, 0); } else if (member.TypeMapMember is XmlTypeMapMemberElement) { codeGenerator.AddElementMemberAttributes((XmlTypeMapMemberElement)member.TypeMapMember, ns, metadata, forceUseMemberName); } else if (member.TypeMapMember is XmlTypeMapMemberAttribute) { codeGenerator.AddAttributeMemberAttributes((XmlTypeMapMemberAttribute)member.TypeMapMember, ns, metadata, forceUseMemberName); } else { throw new NotSupportedException("Schema type not supported"); } }