protected override void GenerateElementInfoMember(CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberElement member, XmlTypeMapElementInfo einfo, TypeData defaultType, string defaultNamespace, bool addAlwaysAttr, bool forceUseMemberName) { CodeAttributeDeclaration att = new CodeAttributeDeclaration("System.Xml.Serialization.XmlElement"); if (forceUseMemberName || einfo.ElementName != member.Name) { att.Arguments.Add(GetArg(einfo.ElementName)); } if (einfo.TypeData.FullTypeName != defaultType.FullTypeName) { att.Arguments.Add(GetTypeArg("Type", einfo.TypeData.FullTypeName)); } if (einfo.Namespace != defaultNamespace) { att.Arguments.Add(GetArg("Namespace", einfo.Namespace)); } if (einfo.Form == XmlSchemaForm.Unqualified) { att.Arguments.Add(GetEnumArg("Form", "System.Xml.Schema.XmlSchemaForm", einfo.Form.ToString())); } if (einfo.IsNullable) { att.Arguments.Add(GetArg("IsNullable", true)); } if (!TypeTranslator.IsDefaultPrimitiveTpeData(einfo.TypeData)) { att.Arguments.Add(GetArg("DataType", einfo.TypeData.XmlType)); } if (addAlwaysAttr || att.Arguments.Count > 0) { attributes.Add(att); } }
protected override void GenerateAttributeMember(CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberAttribute attinfo, string defaultNamespace, bool forceUseMemberName) { CodeAttributeDeclaration att = new CodeAttributeDeclaration("System.Xml.Serialization.XmlAttribute"); if (forceUseMemberName || attinfo.Name != attinfo.AttributeName) { att.Arguments.Add(GetArg(attinfo.AttributeName)); } if (attinfo.Namespace != defaultNamespace) { att.Arguments.Add(GetArg("Namespace", attinfo.Namespace)); } if (attinfo.Form != XmlSchemaForm.None) { att.Arguments.Add(GetEnumArg("Form", "System.Xml.Schema.XmlSchemaForm", attinfo.Form.ToString())); } if (!TypeTranslator.IsDefaultPrimitiveTpeData(attinfo.TypeData)) { att.Arguments.Add(GetArg("DataType", attinfo.TypeData.XmlType)); } attributes.Add(att); if (attinfo.Ignore) { attributes.Add(new CodeAttributeDeclaration("System.Xml.Serialization.XmlIgnoreAttribute")); } }
protected override void GenerateElementInfoMember(CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberElement member, XmlTypeMapElementInfo einfo, TypeData defaultType, string defaultNamespace, bool addAlwaysAttr, bool forceUseMemberName) { CodeAttributeDeclaration att = new CodeAttributeDeclaration("System.Xml.Serialization.SoapElement"); if (forceUseMemberName || einfo.ElementName != member.Name) { att.Arguments.Add(GetArg(einfo.ElementName)); } // if (einfo.IsNullable) att.Arguments.Add (GetArg ("IsNullable", true)); MS seems to ignore this if (!TypeTranslator.IsDefaultPrimitiveTpeData(einfo.TypeData)) { att.Arguments.Add(GetArg("DataType", einfo.TypeData.XmlType)); } if (addAlwaysAttr || att.Arguments.Count > 0) { attributes.Add(att); } }
protected override void GenerateAttributeMember(CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberAttribute attinfo, string defaultNamespace, bool forceUseMemberName) { CodeAttributeDeclaration att = new CodeAttributeDeclaration("System.Xml.Serialization.SoapAttribute"); if (attinfo.Name != attinfo.AttributeName) { att.Arguments.Add(GetArg(attinfo.AttributeName)); } if (attinfo.Namespace != defaultNamespace) { att.Arguments.Add(GetArg("Namespace", attinfo.Namespace)); } if (!TypeTranslator.IsDefaultPrimitiveTpeData(attinfo.TypeData)) { att.Arguments.Add(GetArg("DataType", attinfo.TypeData.XmlType)); } attributes.Add(att); }
public void AddMappingMetadata(CodeAttributeDeclarationCollection metadata, XmlMemberMapping member, bool forceUseMemberName) { TypeData memType = member.TypeMapMember.TypeData; CodeAttributeDeclaration att = new CodeAttributeDeclaration("System.Xml.Serialization.SoapElement"); if (forceUseMemberName || (member.ElementName != member.MemberName)) { att.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(member.ElementName))); } if (!TypeTranslator.IsDefaultPrimitiveTpeData(memType)) { att.Arguments.Add(new CodeAttributeArgument("DataType", new CodePrimitiveExpression(member.TypeName))); } if (att.Arguments.Count > 0) { metadata.Add(att); } }