Inheritance: TypeMapping
Ejemplo n.º 1
0
        internal XmlMembersMapping(TypeScope scope, ElementAccessor accessor, XmlMappingAccess access) : base(scope, accessor, access)
        {
            MembersMapping mapping = (MembersMapping)accessor.Mapping !;
            StringBuilder  key     = new StringBuilder();

            key.Append(':');
            _mappings = new XmlMemberMapping[mapping.Members !.Length];
Ejemplo n.º 2
0
        /// <include file='doc\SoapSchemaImporter.uex' path='docs/doc[@for="SoapSchemaImporter.ImportMembersMapping"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlMembersMapping ImportMembersMapping(string name, string ns, SoapSchemaMember member)
        {
            TypeMapping typeMapping = ImportType(member.MemberType, true);

            if (!(typeMapping is StructMapping))
            {
                return(ImportMembersMapping(name, ns, new SoapSchemaMember[] { member }));
            }

            MembersMapping mapping = new MembersMapping();

            mapping.TypeDesc          = Scope.GetTypeDesc(typeof(object[]));
            mapping.Members           = ((StructMapping)typeMapping).Members;
            mapping.HasWrapperElement = true;

            ElementAccessor accessor = new ElementAccessor();

            accessor.IsSoap     = true;
            accessor.Name       = name;
            accessor.Namespace  = typeMapping.Namespace != null ? typeMapping.Namespace : ns;
            accessor.Mapping    = mapping;
            accessor.IsNullable = false;
            accessor.Form       = XmlSchemaForm.Qualified;

            return(new XmlMembersMapping(Scope, accessor, XmlMappingAccess.Read | XmlMappingAccess.Write));
        }
Ejemplo n.º 3
0
        internal XmlMembersMapping(TypeScope scope, ElementAccessor accessor) : base(scope)
        {
            this.accessor = accessor;
            MembersMapping mapping = (MembersMapping)accessor.Mapping;

            mappings = new XmlMemberMapping[mapping.Members.Length];
            for (int i = 0; i < mappings.Length; i++)
            {
                mappings[i] = new XmlMemberMapping(scope, mapping.Members[i]);
            }
        }
Ejemplo n.º 4
0
        XmlSchemaType ExportMembersMapping(MembersMapping mapping, string ns)
        {
            XmlSchemaComplexType type = new XmlSchemaComplexType();

            ExportTypeMembers(type, mapping.Members, mapping.TypeName, ns, false);

            if (mapping.XmlnsMember != null)
            {
                AddXmlnsAnnotation(type, mapping.XmlnsMember.Name);
            }

            return(type);
        }
Ejemplo n.º 5
0
        /// <include file='doc\XmlSchemaExporter.uex' path='docs/doc[@for="XmlSchemaExporter.ExportTypeMapping1"]/*' />
        public XmlQualifiedName ExportTypeMapping(XmlMembersMapping xmlMembersMapping)
        {
            CheckScope(xmlMembersMapping.Scope);
            MembersMapping mapping = (MembersMapping)xmlMembersMapping.Accessor.Mapping;

            if (mapping.Members.Length == 1 && mapping.Members[0].Elements[0].Mapping is SpecialMapping)
            {
                SpecialMapping special = (SpecialMapping)mapping.Members[0].Elements[0].Mapping;
                XmlSchemaType  type    = ExportSpecialMapping(special, xmlMembersMapping.Accessor.Namespace, false);
                type.Name = xmlMembersMapping.Accessor.Name;
                AddSchemaItem(type, xmlMembersMapping.Accessor.Namespace, null);
                ExportRootIfNecessary(xmlMembersMapping.Scope);
                return(new XmlQualifiedName(xmlMembersMapping.Accessor.Name, xmlMembersMapping.Accessor.Namespace));
            }
            return(null);
        }
        MembersMapping ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, string ns, bool hasWrapperElement, bool writeAccessors, bool validateWrapperElement)
        {
            MembersMapping members = new MembersMapping();

            members.TypeDesc = typeScope.GetTypeDesc(typeof(object[]));
            MemberMapping[] mappings = new MemberMapping[xmlReflectionMembers.Length];
            for (int i = 0; i < mappings.Length; i++)
            {
                try {
                    XmlReflectionMember member  = xmlReflectionMembers[i];
                    MemberMapping       mapping = ImportMemberMapping(member, ns, xmlReflectionMembers, hasWrapperElement ? XmlSchemaForm.Unqualified : XmlSchemaForm.Qualified);
                    if (member.IsReturnValue && writeAccessors)   // no special treatment for return values with doc/enc
                    {
                        if (i > 0)
                        {
                            throw new InvalidOperationException(Res.GetString(Res.XmlInvalidReturnPosition));
                        }
                        mapping.IsReturnValue = true;
                    }
                    mappings[i] = mapping;
                }
                catch (Exception e) {
                    if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException)
                    {
                        throw;
                    }
                    throw ReflectionException(xmlReflectionMembers[i].MemberName, e);
                }
                catch {
                    throw ReflectionException(xmlReflectionMembers[i].MemberName, null);
                }
            }
            members.Members           = mappings;
            members.HasWrapperElement = hasWrapperElement;
            if (hasWrapperElement)
            {
                members.ValidateRpcWrapperElement = validateWrapperElement;
            }
            members.WriteAccessors = writeAccessors;
            members.IsSoap         = true;
            if (hasWrapperElement && !writeAccessors)
            {
                members.Namespace = ns;
            }
            return(members);
        }
Ejemplo n.º 7
0
        private MembersMapping ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, string ns, bool hasWrapperElement, bool writeAccessors, bool validateWrapperElement, RecursionLimiter limiter)
        {
            MembersMapping mapping = new MembersMapping {
                TypeDesc = this.typeScope.GetTypeDesc(typeof(object[]))
            };

            MemberMapping[] mappingArray = new MemberMapping[xmlReflectionMembers.Length];
            for (int i = 0; i < mappingArray.Length; i++)
            {
                try
                {
                    XmlReflectionMember xmlReflectionMember = xmlReflectionMembers[i];
                    MemberMapping       mapping2            = this.ImportMemberMapping(xmlReflectionMember, ns, xmlReflectionMembers, hasWrapperElement ? XmlSchemaForm.Unqualified : XmlSchemaForm.Qualified, limiter);
                    if (xmlReflectionMember.IsReturnValue && writeAccessors)
                    {
                        if (i > 0)
                        {
                            throw new InvalidOperationException(Res.GetString("XmlInvalidReturnPosition"));
                        }
                        mapping2.IsReturnValue = true;
                    }
                    mappingArray[i] = mapping2;
                }
                catch (Exception exception)
                {
                    if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException))
                    {
                        throw;
                    }
                    throw this.ReflectionException(xmlReflectionMembers[i].MemberName, exception);
                }
            }
            mapping.Members           = mappingArray;
            mapping.HasWrapperElement = hasWrapperElement;
            if (hasWrapperElement)
            {
                mapping.ValidateRpcWrapperElement = validateWrapperElement;
            }
            mapping.WriteAccessors = writeAccessors;
            mapping.IsSoap         = true;
            if (hasWrapperElement && !writeAccessors)
            {
                mapping.Namespace = ns;
            }
            return(mapping);
        }
Ejemplo n.º 8
0
        /// <include file='doc\SoapSchemaImporter.uex' path='docs/doc[@for="SoapSchemaImporter.ImportMembersMapping3"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlMembersMapping ImportMembersMapping(string name, string ns, SoapSchemaMember[] members, bool hasWrapperElement, Type baseType, bool baseTypeCanBeIndirect)
        {
            XmlSchemaComplexType type = new XmlSchemaComplexType();
            XmlSchemaSequence    seq  = new XmlSchemaSequence();

            type.Particle = seq;
            foreach (SoapSchemaMember member in members)
            {
                XmlSchemaElement element = new XmlSchemaElement();
                element.Name           = member.MemberName;
                element.SchemaTypeName = member.MemberType;
                seq.Items.Add(element);
            }

            CodeIdentifiers identifiers = new CodeIdentifiers();

            identifiers.UseCamelCasing = true;
            MembersMapping mapping = new MembersMapping();

            mapping.TypeDesc          = Scope.GetTypeDesc(typeof(object[]));
            mapping.Members           = ImportTypeMembers(type, ns, identifiers);
            mapping.HasWrapperElement = hasWrapperElement;

            if (baseType != null)
            {
                for (int i = 0; i < mapping.Members.Length; i++)
                {
                    MemberMapping member = mapping.Members[i];
                    if (member.Accessor.Mapping is StructMapping)
                    {
                        MakeDerived((StructMapping)member.Accessor.Mapping, baseType, baseTypeCanBeIndirect);
                    }
                }
            }
            ElementAccessor accessor = new ElementAccessor();

            accessor.IsSoap     = true;
            accessor.Name       = name;
            accessor.Namespace  = ns;
            accessor.Mapping    = mapping;
            accessor.IsNullable = false;
            accessor.Form       = XmlSchemaForm.Qualified;

            return(new XmlMembersMapping(Scope, accessor, XmlMappingAccess.Read | XmlMappingAccess.Write));
        }
Ejemplo n.º 9
0
        public XmlMembersMapping ImportMembersMapping(string name, string ns, SoapSchemaMember member)
        {
            TypeMapping mapping = this.ImportType(member.MemberType, true);

            if (!(mapping is StructMapping))
            {
                return(this.ImportMembersMapping(name, ns, new SoapSchemaMember[] { member }));
            }
            MembersMapping mapping2 = new MembersMapping {
                TypeDesc          = base.Scope.GetTypeDesc(typeof(object[])),
                Members           = ((StructMapping)mapping).Members,
                HasWrapperElement = true
            };

            return(new XmlMembersMapping(base.Scope, new ElementAccessor {
                IsSoap = true, Name = name, Namespace = (mapping.Namespace != null) ? mapping.Namespace : ns, Mapping = mapping2, IsNullable = false, Form = XmlSchemaForm.Qualified
            }, XmlMappingAccess.Write | XmlMappingAccess.Read));
        }
Ejemplo n.º 10
0
        internal XmlMembersMapping(TypeScope scope, ElementAccessor accessor, XmlMappingAccess access) : base(scope, accessor, access)
        {
            MembersMapping mapping = (MembersMapping)accessor.Mapping;
            StringBuilder  builder = new StringBuilder();

            builder.Append(":");
            this.mappings = new XmlMemberMapping[mapping.Members.Length];
            for (int i = 0; i < this.mappings.Length; i++)
            {
                if (mapping.Members[i].TypeDesc.Type != null)
                {
                    builder.Append(XmlMapping.GenerateKey(mapping.Members[i].TypeDesc.Type, null, null));
                    builder.Append(":");
                }
                this.mappings[i] = new XmlMemberMapping(mapping.Members[i]);
            }
            base.SetKeyInternal(builder.ToString());
        }
Ejemplo n.º 11
0
        internal XmlMembersMapping(TypeScope scope, ElementAccessor accessor, XmlMappingAccess access) : base(scope, accessor, access)
        {
            MembersMapping mapping = (MembersMapping)accessor.Mapping;
            StringBuilder  key     = new StringBuilder();

            key.Append(":");
            mappings = new XmlMemberMapping[mapping.Members.Length];
            for (int i = 0; i < mappings.Length; i++)
            {
                if (mapping.Members[i].TypeDesc.Type != null)
                {
                    key.Append(GenerateKey(mapping.Members[i].TypeDesc.Type, null, null));
                    key.Append(":");
                }
                mappings[i] = new XmlMemberMapping(mapping.Members[i]);
            }
            SetKeyInternal(key.ToString());
        }
        XmlQualifiedName ExportMembersMapping(MembersMapping mapping, string ns)
        {
            XmlSchemaComplexType type = (XmlSchemaComplexType)types[mapping];

            if (type == null)
            {
                CheckForDuplicateType(mapping.TypeName, mapping.Namespace);
                type      = new XmlSchemaComplexType();
                type.Name = mapping.TypeName;
                types.Add(mapping, type);
                AddSchemaItem(type, mapping.Namespace, ns);
                ExportTypeMembers(type, mapping.Members, mapping.Namespace);
            }
            else
            {
                AddSchemaImport(mapping.Namespace, ns);
            }
            return(new XmlQualifiedName(type.Name, mapping.Namespace));
        }
        /// <include file='doc\SoapSchemaExporter.uex' path='docs/doc[@for="SoapSchemaExporter.ExportMembersMapping1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void ExportMembersMapping(XmlMembersMapping xmlMembersMapping, bool exportEnclosingType)
        {
            CheckScope(xmlMembersMapping.Scope);
            MembersMapping membersMapping = (MembersMapping)xmlMembersMapping.Accessor.Mapping;

            if (exportEnclosingType)
            {
                ExportTypeMapping(membersMapping, null);
            }
            else
            {
                foreach (MemberMapping memberMapping in membersMapping.Members)
                {
                    if (memberMapping.Elements.Length > 0)
                    {
                        ExportTypeMapping(memberMapping.Elements[0].Mapping, null);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public XmlMembersMapping ImportMembersMapping(string name, string ns, SoapSchemaMember[] members, bool hasWrapperElement, Type baseType, bool baseTypeCanBeIndirect)
        {
            XmlSchemaComplexType type     = new XmlSchemaComplexType();
            XmlSchemaSequence    sequence = new XmlSchemaSequence();

            type.Particle = sequence;
            foreach (SoapSchemaMember member in members)
            {
                XmlSchemaElement item = new XmlSchemaElement {
                    Name           = member.MemberName,
                    SchemaTypeName = member.MemberType
                };
                sequence.Items.Add(item);
            }
            CodeIdentifiers identifiers = new CodeIdentifiers {
                UseCamelCasing = true
            };
            MembersMapping mapping = new MembersMapping {
                TypeDesc          = base.Scope.GetTypeDesc(typeof(object[])),
                Members           = this.ImportTypeMembers(type, ns, identifiers),
                HasWrapperElement = hasWrapperElement
            };

            if (baseType != null)
            {
                for (int i = 0; i < mapping.Members.Length; i++)
                {
                    MemberMapping mapping2 = mapping.Members[i];
                    if (mapping2.Accessor.Mapping is StructMapping)
                    {
                        base.MakeDerived((StructMapping)mapping2.Accessor.Mapping, baseType, baseTypeCanBeIndirect);
                    }
                }
            }
            return(new XmlMembersMapping(base.Scope, new ElementAccessor {
                IsSoap = true, Name = name, Namespace = ns, Mapping = mapping, IsNullable = false, Form = XmlSchemaForm.Qualified
            }, XmlMappingAccess.Write | XmlMappingAccess.Read));
        }
Ejemplo n.º 15
0
        /// <include file='doc\XmlSchemaExporter.uex' path='docs/doc[@for="XmlSchemaExporter.ExportMembersMapping"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void ExportMembersMapping(XmlMembersMapping xmlMembersMapping)
        {
            MembersMapping mapping = (MembersMapping)xmlMembersMapping.Accessor.Mapping;

            CheckScope(xmlMembersMapping.Scope);
            if (mapping.HasWrapperElement)
            {
                ExportElement(xmlMembersMapping.Accessor);
            }
            else
            {
                foreach (MemberMapping member in mapping.Members)
                {
                    if (member.Attribute != null)
                    {
                        throw new InvalidOperationException(Res.GetString(Res.XmlBareAttributeMember, member.Attribute.Name));
                    }
                    else if (member.Text != null)
                    {
                        throw new InvalidOperationException(Res.GetString(Res.XmlBareTextMember, member.Text.Name));
                    }
                    else if (member.Elements == null || member.Elements.Length == 0)
                    {
                        continue;
                    }

                    if (member.TypeDesc.IsArray && !(member.Elements[0].Mapping is ArrayMapping))
                    {
                        throw new InvalidOperationException(Res.GetString(Res.XmlIllegalArrayElement, member.Elements[0].Name));
                    }

                    ExportElement(member.Elements[0]);
                }
            }
            ExportRootIfNecessary(xmlMembersMapping.Scope);
        }
Ejemplo n.º 16
0
        /// <include file='doc\XmlSchemaImporter.uex' path='docs/doc[@for="XmlSchemaImporter.ImportMembersMapping2"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlMembersMapping ImportMembersMapping(XmlQualifiedName[] names, Type baseType, bool baseTypeCanBeIndirect) {
            CodeIdentifiers memberScope = new CodeIdentifiers();
            memberScope.UseCamelCasing = true;
            MemberMapping[] members = new MemberMapping[names.Length];
            for (int i = 0; i < names.Length; i++) {
                XmlQualifiedName name = EncodeQName(names[i]);
                ElementAccessor accessor = ImportElement(name, typeof(TypeMapping), baseType);
                if (baseType != null && accessor.Mapping is StructMapping)
                    MakeDerived((StructMapping)accessor.Mapping, baseType, baseTypeCanBeIndirect);

                MemberMapping member = new MemberMapping();
                member.Name = CodeIdentifier.MakeValid(Accessor.UnescapeName(accessor.Name));
                member.Name = memberScope.AddUnique(member.Name, member);
                member.TypeDesc = accessor.Mapping.TypeDesc;
                member.Elements = new ElementAccessor[] { accessor };
                members[i] = member;
            }

            MembersMapping mapping = new MembersMapping();
            mapping.HasWrapperElement = false;
            mapping.TypeDesc = scope.GetTypeDesc(typeof(object[]));
            mapping.Members = members;
            ElementAccessor element = new ElementAccessor();
            element.Mapping = mapping;
            return new XmlMembersMapping(scope, element);
        }
 private XmlSchemaType ExportMembersMapping(MembersMapping mapping, string ns)
 {
     XmlSchemaComplexType type = new XmlSchemaComplexType();
     this.ExportTypeMembers(type, mapping.Members, mapping.TypeName, ns, false, false);
     if (mapping.XmlnsMember != null)
     {
         this.AddXmlnsAnnotation(type, mapping.XmlnsMember.Name);
     }
     return type;
 }
 public XmlMembersMapping ImportMembersMapping(XmlQualifiedName[] names, Type baseType, bool baseTypeCanBeIndirect)
 {
     CodeIdentifiers identifiers = new CodeIdentifiers {
         UseCamelCasing = true
     };
     MemberMapping[] mappingArray = new MemberMapping[names.Length];
     for (int i = 0; i < names.Length; i++)
     {
         MemberMapping mapping;
         XmlQualifiedName name = names[i];
         ElementAccessor accessor = this.ImportElement(name, typeof(TypeMapping), baseType);
         if ((baseType != null) && (accessor.Mapping is StructMapping))
         {
             base.MakeDerived((StructMapping) accessor.Mapping, baseType, baseTypeCanBeIndirect);
         }
         mappingArray[i] = new MemberMapping { Name = CodeIdentifier.MakeValid(Accessor.UnescapeName(accessor.Name)), Name = identifiers.AddUnique(mapping.Name, mapping), TypeDesc = accessor.Mapping.TypeDesc, Elements = new ElementAccessor[] { accessor } };
     }
     MembersMapping mapping2 = new MembersMapping {
         HasWrapperElement = false,
         TypeDesc = base.Scope.GetTypeDesc(typeof(object[])),
         Members = mappingArray
     };
     return new XmlMembersMapping(base.Scope, new ElementAccessor { Mapping = mapping2 }, XmlMappingAccess.Write | XmlMappingAccess.Read);
 }
 private MembersMapping ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, string ns, bool hasWrapperElement, bool rpc, bool openModel, RecursionLimiter limiter)
 {
     MembersMapping mapping = new MembersMapping {
         TypeDesc = this.typeScope.GetTypeDesc(typeof(object[]))
     };
     MemberMapping[] mappingArray = new MemberMapping[xmlReflectionMembers.Length];
     System.Xml.Serialization.NameTable elements = new System.Xml.Serialization.NameTable();
     System.Xml.Serialization.NameTable attributes = new System.Xml.Serialization.NameTable();
     TextAccessor text = null;
     bool isSequence = false;
     for (int i = 0; i < mappingArray.Length; i++)
     {
         try
         {
             MemberMapping member = this.ImportMemberMapping(xmlReflectionMembers[i], ns, xmlReflectionMembers, rpc, openModel, limiter);
             if (!hasWrapperElement && (member.Attribute != null))
             {
                 if (rpc)
                 {
                     throw new InvalidOperationException(Res.GetString("XmlRpcLitAttributeAttributes"));
                 }
                 throw new InvalidOperationException(Res.GetString("XmlInvalidAttributeType", new object[] { "XmlAttribute" }));
             }
             if (rpc && xmlReflectionMembers[i].IsReturnValue)
             {
                 if (i > 0)
                 {
                     throw new InvalidOperationException(Res.GetString("XmlInvalidReturnPosition"));
                 }
                 member.IsReturnValue = true;
             }
             mappingArray[i] = member;
             isSequence |= member.IsSequence;
             if (!xmlReflectionMembers[i].XmlAttributes.XmlIgnore)
             {
                 AddUniqueAccessor(member, elements, attributes, isSequence);
             }
             mappingArray[i] = member;
             if (member.Text != null)
             {
                 if (text != null)
                 {
                     throw new InvalidOperationException(Res.GetString("XmlIllegalMultipleTextMembers"));
                 }
                 text = member.Text;
             }
             if (member.Xmlns != null)
             {
                 if (mapping.XmlnsMember != null)
                 {
                     throw new InvalidOperationException(Res.GetString("XmlMultipleXmlnsMembers"));
                 }
                 mapping.XmlnsMember = member;
             }
         }
         catch (Exception exception)
         {
             if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException))
             {
                 throw;
             }
             throw this.CreateReflectionException(xmlReflectionMembers[i].MemberName, exception);
         }
     }
     if (isSequence)
     {
         throw new InvalidOperationException(Res.GetString("XmlSequenceMembers", new object[] { "Order" }));
     }
     mapping.Members = mappingArray;
     mapping.HasWrapperElement = hasWrapperElement;
     return mapping;
 }
        MembersMapping ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, string ns, bool hasWrapperElement, bool rpc, bool openModel) {
            MembersMapping members = new MembersMapping();
            members.TypeDesc = typeScope.GetTypeDesc(typeof(object[]));
            MemberMapping[] mappings = new MemberMapping[xmlReflectionMembers.Length];
            NameTable elements = new NameTable();
            NameTable attributes = new NameTable();
            TextAccessor textAccessor = null;
            bool isSequence = false;

            for (int i = 0; i < mappings.Length; i++) {
                try {
                    MemberMapping mapping = ImportMemberMapping(xmlReflectionMembers[i], ns, xmlReflectionMembers, rpc, openModel);
                    if (!hasWrapperElement) {
                        if (mapping.Attribute != null) {
                            if (rpc) {
                                throw new InvalidOperationException(Res.GetString(Res.XmlRpcLitAttributeAttributes));
                            }
                            else {
                                throw new InvalidOperationException(Res.GetString(Res.XmlInvalidAttributeType, "XmlAttribute"));
                            }
                        }
                    }
                    if (rpc && xmlReflectionMembers[i].IsReturnValue) {
                        if (i > 0) throw new InvalidOperationException(Res.GetString(Res.XmlInvalidReturnPosition));
                        mapping.IsReturnValue = true;
                    }
                    mappings[i] = mapping;
                    isSequence |= mapping.IsSequence;
                    if (!xmlReflectionMembers[i].XmlAttributes.XmlIgnore) {
                        // add All memeber accessors to the scope accessors
                        AddUniqueAccessor(mapping, elements, attributes, isSequence);
                    }

                    mappings[i] = mapping;
                    if (mapping.Text != null) {
                        if (textAccessor != null) {
                            throw new InvalidOperationException(Res.GetString(Res.XmlIllegalMultipleTextMembers));
                        }
                        textAccessor = mapping.Text;
                    }

                    if (mapping.Xmlns != null) {
                        if (members.XmlnsMember != null)
                            throw new InvalidOperationException(Res.GetString(Res.XmlMultipleXmlnsMembers));
                        members.XmlnsMember = mapping;
                    }
                }
                catch (Exception e) {
                    if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) {
                        throw;
                    }
                    throw CreateReflectionException(xmlReflectionMembers[i].MemberName, e);
                }
                catch {
                    throw CreateReflectionException(xmlReflectionMembers[i].MemberName, null);
                }
            }
            if (isSequence) {
                throw new InvalidOperationException(Res.GetString(Res.XmlSequenceMembers, "Order"));
            }
            members.Members = mappings;
            members.HasWrapperElement = hasWrapperElement;
            return members;
        }
Ejemplo n.º 21
0
        MembersMapping ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, string ns, bool hasWrapperElement) {
            MembersMapping members = new MembersMapping();
            members.TypeDesc = typeScope.GetTypeDesc(typeof(object[]));
            MemberMapping[] mappings = new MemberMapping[xmlReflectionMembers.Length];
            NameTable elements = new NameTable();
            NameTable attributes = new NameTable();
            TextAccessor textAccessor = null;

            for (int i = 0; i < mappings.Length; i++) {
                try {
                    MemberMapping mapping = ImportMemberMapping(xmlReflectionMembers[i], ns, xmlReflectionMembers);
                    if (!hasWrapperElement) {
                        if (mapping.Attribute != null) throw new InvalidOperationException(Res.GetString(Res.XmlInvalidAttributeType, "XmlAttribute"));
                    }
                    // add All memeber accessors to the scope accessors
                    AddUniqueAccessor(mapping, elements, attributes);

                    mappings[i] = mapping;
                    if (mapping.Text != null) {
                        if (textAccessor != null) {
                            throw new InvalidOperationException(Res.GetString(Res.XmlIllegalMultipleTextMembers));
                        }
                        textAccessor = mapping.Text;
                    }

                    if (mapping.Xmlns != null) {
                        if (members.XmlnsMember != null)
                            throw new InvalidOperationException(Res.GetString(Res.XmlMultipleXmlnsMembers));
                        members.XmlnsMember = mapping;
                    }
                }
                catch (Exception e) {
                    throw ReflectionException(xmlReflectionMembers[i].MemberName, e);
                }
            }
            members.Members = mappings;
            members.HasWrapperElement = hasWrapperElement;
            return members;
        }
 public XmlMembersMapping ImportMembersMapping(string name, string ns, SoapSchemaMember[] members, bool hasWrapperElement, Type baseType, bool baseTypeCanBeIndirect)
 {
     XmlSchemaComplexType type = new XmlSchemaComplexType();
     XmlSchemaSequence sequence = new XmlSchemaSequence();
     type.Particle = sequence;
     foreach (SoapSchemaMember member in members)
     {
         XmlSchemaElement item = new XmlSchemaElement {
             Name = member.MemberName,
             SchemaTypeName = member.MemberType
         };
         sequence.Items.Add(item);
     }
     CodeIdentifiers identifiers = new CodeIdentifiers {
         UseCamelCasing = true
     };
     MembersMapping mapping = new MembersMapping {
         TypeDesc = base.Scope.GetTypeDesc(typeof(object[])),
         Members = this.ImportTypeMembers(type, ns, identifiers),
         HasWrapperElement = hasWrapperElement
     };
     if (baseType != null)
     {
         for (int i = 0; i < mapping.Members.Length; i++)
         {
             MemberMapping mapping2 = mapping.Members[i];
             if (mapping2.Accessor.Mapping is StructMapping)
             {
                 base.MakeDerived((StructMapping) mapping2.Accessor.Mapping, baseType, baseTypeCanBeIndirect);
             }
         }
     }
     return new XmlMembersMapping(base.Scope, new ElementAccessor { IsSoap = true, Name = name, Namespace = ns, Mapping = mapping, IsNullable = false, Form = XmlSchemaForm.Qualified }, XmlMappingAccess.Write | XmlMappingAccess.Read);
 }
        /// <include file='doc\SoapSchemaImporter.uex' path='docs/doc[@for="SoapSchemaImporter.ImportMembersMapping3"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlMembersMapping ImportMembersMapping(string name, string ns, SoapSchemaMember[] members, bool hasWrapperElement, Type baseType, bool baseTypeCanBeIndirect) {
            XmlSchemaComplexType type = new XmlSchemaComplexType();
            XmlSchemaSequence seq = new XmlSchemaSequence();
            type.Particle = seq;
            foreach (SoapSchemaMember member in members) {
                XmlSchemaElement element = new XmlSchemaElement();
                element.Name = member.MemberName;
                element.SchemaTypeName = member.MemberType;
                seq.Items.Add(element);
            }

            CodeIdentifiers identifiers = new CodeIdentifiers();
            identifiers.UseCamelCasing = true;
            MembersMapping mapping = new MembersMapping();
            mapping.TypeDesc = Scope.GetTypeDesc(typeof(object[]));
            mapping.Members = ImportTypeMembers(type, ns, identifiers);
            mapping.HasWrapperElement = hasWrapperElement;
            
            if (baseType != null) {
                for (int i = 0; i < mapping.Members.Length; i++) {
                    MemberMapping member = mapping.Members[i];
                    if (member.Accessor.Mapping is StructMapping)
                        MakeDerived((StructMapping)member.Accessor.Mapping, baseType, baseTypeCanBeIndirect);
                }
            }
            ElementAccessor accessor = new ElementAccessor();
            accessor.IsSoap = true;
            accessor.Name = name;
            accessor.Namespace = ns;
            accessor.Mapping = mapping;
            accessor.IsNullable = false;
            accessor.Form = XmlSchemaForm.Qualified;

            return new XmlMembersMapping(Scope, accessor, XmlMappingAccess.Read | XmlMappingAccess.Write);
        }
Ejemplo n.º 24
0
 XmlQualifiedName ExportMembersMapping(MembersMapping mapping, string ns) {
     XmlSchemaComplexType type = (XmlSchemaComplexType)types[mapping];
     if(type == null) {
         CheckForDuplicateType(mapping.TypeName, mapping.Namespace);
         type = new XmlSchemaComplexType();
         type.Name = mapping.TypeName;
         types.Add(mapping, type);
         AddSchemaItem(type, mapping.Namespace, ns);
         ExportTypeMembers(type, mapping.Members, mapping.Namespace);
     }
     else {
         AddSchemaImport(mapping.Namespace, ns);
     }
     return new XmlQualifiedName(type.Name, mapping.Namespace);
 }
Ejemplo n.º 25
0
 private MembersMapping ImportMembersType(XmlSchemaType type, string typeNs, string identifier)
 {
     if (!type.DerivedFrom.IsEmpty) throw new InvalidOperationException(SR.XmlMembersDeriveError);
     CodeIdentifiers memberScope = new CodeIdentifiers();
     memberScope.UseCamelCasing = true;
     bool needExplicitOrder = false;
     MemberMapping[] members = ImportTypeMembers(type, typeNs, identifier, memberScope, new CodeIdentifiers(), new NameTable(), ref needExplicitOrder, false, false);
     MembersMapping mappings = new MembersMapping();
     mappings.HasWrapperElement = true;
     mappings.TypeDesc = Scope.GetTypeDesc(typeof(object[]));
     mappings.Members = members;
     return mappings;
 }
        /// <include file='doc\SoapSchemaImporter.uex' path='docs/doc[@for="SoapSchemaImporter.ImportMembersMapping"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlMembersMapping ImportMembersMapping(string name, string ns, SoapSchemaMember member) {
            TypeMapping typeMapping = ImportType(member.MemberType, true);
            if (!(typeMapping is StructMapping)) return ImportMembersMapping(name, ns, new SoapSchemaMember[] { member });

            MembersMapping mapping = new MembersMapping();
            mapping.TypeDesc = Scope.GetTypeDesc(typeof(object[]));
            mapping.Members = ((StructMapping)typeMapping).Members;
            mapping.HasWrapperElement = true;
            
            ElementAccessor accessor = new ElementAccessor();
            accessor.IsSoap = true;
            accessor.Name = name;
            accessor.Namespace = typeMapping.Namespace != null ? typeMapping.Namespace : ns;
            accessor.Mapping = mapping;
            accessor.IsNullable = false;
            accessor.Form = XmlSchemaForm.Qualified;

            return new XmlMembersMapping(Scope, accessor, XmlMappingAccess.Read | XmlMappingAccess.Write);
        }
Ejemplo n.º 27
0
 MembersMapping ImportMembersType(XmlSchemaType type, string typeNs, string identifier) {
     if (!type.DerivedFrom.IsEmpty) throw new InvalidOperationException(Res.GetString(Res.XmlMembersDeriveError));
     CodeIdentifiers memberScope = new CodeIdentifiers();
     memberScope.UseCamelCasing = true;
     MemberMapping[] members = ImportTypeMembers(type, typeNs, identifier, memberScope);
     MembersMapping mappings = new MembersMapping();
     mappings.HasWrapperElement = true;
     mappings.TypeDesc = scope.GetTypeDesc(typeof(object[]));
     mappings.Members = members;
     return mappings;
 }
 MembersMapping ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, string ns, bool hasWrapperElement, bool writeAccessors, bool validateWrapperElement) {
     MembersMapping members = new MembersMapping();
     members.TypeDesc = typeScope.GetTypeDesc(typeof(object[]));
     MemberMapping[] mappings = new MemberMapping[xmlReflectionMembers.Length];
     for (int i = 0; i < mappings.Length; i++) {
         try {
             XmlReflectionMember member = xmlReflectionMembers[i];
             MemberMapping mapping = ImportMemberMapping(member, ns, xmlReflectionMembers, hasWrapperElement ? XmlSchemaForm.Unqualified : XmlSchemaForm.Qualified);
             if (member.IsReturnValue && writeAccessors) { // no special treatment for return values with doc/enc
                 if (i > 0) throw new InvalidOperationException(Res.GetString(Res.XmlInvalidReturnPosition));
                 mapping.IsReturnValue = true;
             }
             mappings[i] = mapping;
         }
         catch (Exception e) {
             if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) {
                 throw;
             }
             throw ReflectionException(xmlReflectionMembers[i].MemberName, e);
         }
         catch {
             throw ReflectionException(xmlReflectionMembers[i].MemberName, null);
         }
     }
     members.Members = mappings;
     members.HasWrapperElement = hasWrapperElement;
     if (hasWrapperElement) {
         members.ValidateRpcWrapperElement = validateWrapperElement;
     }
     members.WriteAccessors = writeAccessors;
     members.IsSoap = true;
     if (hasWrapperElement && !writeAccessors)
         members.Namespace = ns;
     return members;
 }
 public XmlMembersMapping ImportMembersMapping(string name, string ns, SoapSchemaMember member)
 {
     TypeMapping mapping = this.ImportType(member.MemberType, true);
     if (!(mapping is StructMapping))
     {
         return this.ImportMembersMapping(name, ns, new SoapSchemaMember[] { member });
     }
     MembersMapping mapping2 = new MembersMapping {
         TypeDesc = base.Scope.GetTypeDesc(typeof(object[])),
         Members = ((StructMapping) mapping).Members,
         HasWrapperElement = true
     };
     return new XmlMembersMapping(base.Scope, new ElementAccessor { IsSoap = true, Name = name, Namespace = (mapping.Namespace != null) ? mapping.Namespace : ns, Mapping = mapping2, IsNullable = false, Form = XmlSchemaForm.Qualified }, XmlMappingAccess.Write | XmlMappingAccess.Read);
 }