예제 #1
0
 internal bool Match(AccessorMapping mapping)
 {
     if (Elements != null && Elements.Length > 0)
     {
         if (!ElementsMatch(Elements, mapping.Elements))
         {
             return(false);
         }
         if (Text == null)
         {
             return(mapping.Text == null);
         }
     }
     if (Attribute != null)
     {
         if (mapping.Attribute == null)
         {
             return(false);
         }
         return(Attribute.Name == mapping.Attribute.Name && Attribute.Namespace == mapping.Attribute.Namespace && Attribute.Form == mapping.Attribute.Form);
     }
     if (Text != null)
     {
         return(mapping.Text != null);
     }
     return(mapping.Accessor == null);
 }
예제 #2
0
        /// <include file='doc\XmlCodeExporter.uex' path='docs/doc[@for="XmlCodeExporter.ExportMembersMapping"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void ExportMembersMapping(XmlMembersMapping xmlMembersMapping)
        {
            xmlMembersMapping.CheckShallow();
            CheckScope(xmlMembersMapping.Scope);

            for (int i = 0; i < xmlMembersMapping.Count; i++)
            {
                AccessorMapping mapping = xmlMembersMapping[i].Mapping;
                if (mapping.Xmlns == null)
                {
                    if (mapping.Attribute != null)
                    {
                        ExportType(mapping.Attribute.Mapping, Accessor.UnescapeName(mapping.Attribute.Name), mapping.Attribute.Namespace, null, false);
                    }
                    if (mapping.Elements != null)
                    {
                        for (int j = 0; j < mapping.Elements.Length; j++)
                        {
                            ElementAccessor element = mapping.Elements[j];
                            ExportType(element.Mapping, Accessor.UnescapeName(element.Name), element.Namespace, null, false);
                        }
                    }
                    if (mapping.Text != null)
                    {
                        ExportType(mapping.Text.Mapping, Accessor.UnescapeName(mapping.Text.Name), mapping.Text.Namespace, null, false);
                    }
                }
            }
        }
예제 #3
0
 protected AccessorMapping(AccessorMapping mapping)
     : base(mapping)
 {
     _typeDesc         = mapping._typeDesc;
     _attribute        = mapping._attribute;
     _elements         = mapping._elements;
     _sortedElements   = mapping._sortedElements;
     _text             = mapping._text;
     _choiceIdentifier = mapping._choiceIdentifier;
     _xmlns            = mapping._xmlns;
     _ignore           = mapping._ignore;
 }
예제 #4
0
        // UNDONE Nullable
        private void SetArrayMappingType(ArrayMapping mapping)
        {
            bool useDefaultNs = false;

            string itemTypeName;
            string itemTypeNamespace;

            TypeMapping itemTypeMapping;

            if (mapping.Elements.Length == 1)
            {
                itemTypeMapping = mapping.Elements[0].Mapping;
            }
            else
            {
                itemTypeMapping = null;
            }

            if (itemTypeMapping is EnumMapping)
            {
                itemTypeNamespace = itemTypeMapping.Namespace;
                itemTypeName      = itemTypeMapping.TypeName;
            }
            else if (itemTypeMapping is PrimitiveMapping)
            {
                itemTypeNamespace = itemTypeMapping.TypeDesc.IsXsdType ? XmlSchema.Namespace : UrtTypes.Namespace;
                itemTypeName      = itemTypeMapping.TypeDesc.DataType.Name;
                useDefaultNs      = true;
            }
            else if (itemTypeMapping is StructMapping)
            {
                if (itemTypeMapping.TypeDesc.IsRoot)
                {
                    itemTypeNamespace = XmlSchema.Namespace;
                    itemTypeName      = Soap.UrType;
                    useDefaultNs      = true;
                }
                else
                {
                    itemTypeNamespace = itemTypeMapping.Namespace;
                    itemTypeName      = itemTypeMapping.TypeName;
                }
            }
            else if (itemTypeMapping is ArrayMapping)
            {
                itemTypeNamespace = itemTypeMapping.Namespace;
                itemTypeName      = itemTypeMapping.TypeName;
            }
            else
            {
                throw new InvalidOperationException(string.Format(ResXml.XmlInvalidSoapArray, mapping.TypeDesc.FullName));
            }

            itemTypeName = CodeIdentifier.MakePascal(itemTypeName);
            string      uniqueName      = "ArrayOf" + itemTypeName;
            string      ns              = useDefaultNs ? _defaultNs : itemTypeNamespace;
            int         i               = 1;
            TypeMapping existingMapping = (TypeMapping)_types[uniqueName, ns];

            while (existingMapping != null)
            {
                if (existingMapping is ArrayMapping)
                {
                    ArrayMapping arrayMapping = (ArrayMapping)existingMapping;
                    if (AccessorMapping.ElementsMatch(arrayMapping.Elements, mapping.Elements))
                    {
                        break;
                    }
                }
                // need to re-name the mapping
                uniqueName      = itemTypeName + i.ToString();
                existingMapping = (TypeMapping)_types[uniqueName, ns];
                i++;
            }
            mapping.Namespace = ns;
            mapping.TypeName  = uniqueName;
        }