示例#1
0
        protected override void GenerateUnnamedAnyElementAttribute(CodeAttributeDeclarationCollection attributes, XmlTypeMapElementInfo einfo, string defaultNamespace)
        {
            CodeAttributeDeclaration uatt = new CodeAttributeDeclaration("Mpd.Xml.Serialization.XmlAnyElement");

            if (!einfo.IsUnnamedAnyElement)
            {
                uatt.Arguments.Add(GetArg("Name", einfo.ElementName));
            }
            if (einfo.Namespace != defaultNamespace)
            {
                uatt.Arguments.Add(GetArg("Namespace", einfo.Namespace));
            }
            attributes.Add(uatt);
        }
示例#2
0
        protected override void GenerateArrayItemAttributes(CodeAttributeDeclarationCollection attributes, ListMap listMap, TypeData type, XmlTypeMapElementInfo ainfo, string defaultName, string defaultNamespace, int nestingLevel)
        {
            bool needsType = (listMap.ItemInfo.Count > 1) ||
                             (ainfo.TypeData.FullTypeName != type.FullTypeName && !listMap.IsMultiArray);

            CodeAttributeDeclaration att = new CodeAttributeDeclaration("Mpd.Xml.Serialization.XmlArrayItem");

            if (ainfo.ElementName != defaultName)
            {
                att.Arguments.Add(GetArg("ElementName", ainfo.ElementName));
            }
            if (ainfo.Namespace != defaultNamespace && ainfo.Namespace != XmlSchema.Namespace)
            {
                att.Arguments.Add(GetArg("Namespace", ainfo.Namespace));
            }
            if (needsType)
            {
                att.Arguments.Add(GetTypeArg("Type", ainfo.TypeData.FullTypeName));
            }
            if (!ainfo.IsNullable)
            {
                att.Arguments.Add(GetArg("IsNullable", false));
            }
            if (ainfo.Form == XmlSchemaForm.Unqualified)
            {
                att.Arguments.Add(MapCodeGenerator.GetEnumArg("Form", "System.Xml.Schema.XmlSchemaForm", ainfo.Form.ToString()));
            }
            if (att.Arguments.Count > 0 && nestingLevel > 0)
            {
                att.Arguments.Add(GetArg("NestingLevel", nestingLevel));
            }

            if (att.Arguments.Count > 0)
            {
                attributes.Add(att);
            }
        }
示例#3
0
        protected override void GenerateTextElementAttribute(CodeAttributeDeclarationCollection attributes, XmlTypeMapElementInfo einfo, TypeData defaultType)
        {
            CodeAttributeDeclaration uatt = new CodeAttributeDeclaration("Mpd.Xml.Serialization.XmlTextAttribute");

            if (einfo.TypeData.FullTypeName != defaultType.FullTypeName)
            {
                uatt.Arguments.Add(GetTypeArg("Type", einfo.TypeData.FullTypeName));
            }
            attributes.Add(uatt);
        }
示例#4
0
        protected override void GenerateElementInfoMember(CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberElement member, XmlTypeMapElementInfo einfo, TypeData defaultType, string defaultNamespace, bool addAlwaysAttr, bool forceUseMemberName)
        {
            CodeAttributeDeclaration att = new CodeAttributeDeclaration("Mpd.Xml.Serialization.XmlElementAttribute");

            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);
            }
        }