示例#1
0
        /// <include file='doc\SoapReflectionImporter.uex' path='docs/doc[@for="XmlReflectionImporter.ImportTypeMapping1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlTypeMapping ImportTypeMapping(Type type, string defaultNamespace)
        {
            ElementAccessor element = new ElementAccessor();

            element.IsSoap    = true;
            element.Mapping   = ImportTypeMapping(_modelScope.GetTypeModel(type), new RecursionLimiter());
            element.Name      = element.Mapping.DefaultElementName;
            element.Namespace = element.Mapping.Namespace == null ? defaultNamespace : element.Mapping.Namespace;
            element.Form      = XmlSchemaForm.Qualified;
            XmlTypeMapping xmlMapping = new XmlTypeMapping(_typeScope, element);

            xmlMapping.SetKeyInternal(XmlMapping.GenerateKey(type, null, defaultNamespace));
            xmlMapping.IsSoap             = true;
            xmlMapping.GenerateSerializer = true;
            return(xmlMapping);
        }
示例#2
0
        public XmlTypeMapping ImportTypeMapping(Type type, string defaultNamespace)
        {
            ElementAccessor accessor;

            accessor = new ElementAccessor {
                IsSoap    = true,
                Mapping   = this.ImportTypeMapping(this.modelScope.GetTypeModel(type), new RecursionLimiter()),
                Name      = accessor.Mapping.DefaultElementName,
                Namespace = (accessor.Mapping.Namespace == null) ? defaultNamespace : accessor.Mapping.Namespace,
                Form      = XmlSchemaForm.Qualified
            };
            XmlTypeMapping mapping = new XmlTypeMapping(this.typeScope, accessor);

            mapping.SetKeyInternal(XmlMapping.GenerateKey(type, null, defaultNamespace));
            mapping.IsSoap             = true;
            mapping.GenerateSerializer = true;
            return(mapping);
        }
        static XmlTypeMapping GetKnownMapping(Type type, string ns)
        {
            if (ns != null && ns != string.Empty)
            {
                return(null);
            }
            TypeDesc typeDesc = (TypeDesc)TypeScope.PrimtiveTypes[type];

            if (typeDesc == null)
            {
                return(null);
            }
            ElementAccessor element = new ElementAccessor();

            element.Name = typeDesc.DataType.Name;
            XmlTypeMapping mapping = new XmlTypeMapping(null, element);

            mapping.SetKeyInternal(XmlMapping.GenerateKey(type, null, null));
            return(mapping);
        }
        private static XmlTypeMapping GetKnownMapping(Type type, string ns)
        {
            if ((ns != null) && (ns != string.Empty))
            {
                return(null);
            }
            TypeDesc desc = (TypeDesc)TypeScope.PrimtiveTypes[type];

            if (desc == null)
            {
                return(null);
            }
            ElementAccessor accessor = new ElementAccessor {
                Name = desc.DataType.Name
            };
            XmlTypeMapping mapping = new XmlTypeMapping(null, accessor);

            mapping.SetKeyInternal(XmlMapping.GenerateKey(type, null, null));
            return(mapping);
        }
 /// <include file='doc\SoapReflectionImporter.uex' path='docs/doc[@for="XmlReflectionImporter.ImportTypeMapping1"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public XmlTypeMapping ImportTypeMapping(Type type, string defaultNamespace) {
     ElementAccessor element = new ElementAccessor();
     element.IsSoap = true;
     element.Mapping = ImportTypeMapping(modelScope.GetTypeModel(type));
     element.Name = element.Mapping.DefaultElementName;
     element.Namespace = element.Mapping.Namespace == null ? defaultNamespace : element.Mapping.Namespace;
     element.Form = XmlSchemaForm.Qualified;
     XmlTypeMapping xmlMapping = new XmlTypeMapping(typeScope, element);
     xmlMapping.SetKeyInternal(XmlMapping.GenerateKey(type, null, defaultNamespace));
     xmlMapping.IsSoap = true;
     xmlMapping.GenerateSerializer = true;
     return xmlMapping;
 }
示例#6
0
 private static XmlTypeMapping GetKnownMapping(Type type, string ns)
 {
     if (ns != null && ns != string.Empty)
         return null;
     TypeDesc typeDesc;
     if (!TypeScope.PrimtiveTypes.TryGetValue(type, out typeDesc))
         return null;
     ElementAccessor element = new ElementAccessor();
     element.Name = typeDesc.DataType.Name;
     XmlTypeMapping mapping = new XmlTypeMapping(null, element);
     mapping.SetKeyInternal(XmlMapping.GenerateKey(type, null, null));
     return mapping;
 }
        // will create a shallow type mapping for a top-level type
        internal static XmlTypeMapping GetTopLevelMapping(Type type, string defaultNamespace) {
            XmlAttributes a = new XmlAttributes(type);
            TypeDesc typeDesc = new TypeScope().GetTypeDesc(type);
            ElementAccessor element = new ElementAccessor();

            if (typeDesc.Kind == TypeKind.Node) {
                element.Any = true;
            }
            else {
                string ns = a.XmlRoot == null ? defaultNamespace : a.XmlRoot.Namespace;
                string typeName = string.Empty;
                if (a.XmlType != null)
                    typeName = a.XmlType.TypeName;
                if (typeName.Length == 0) 
                    typeName = type.Name;

                element.Name = XmlConvert.EncodeLocalName(typeName);
                element.Namespace = ns;
            }
            XmlTypeMapping mapping = new XmlTypeMapping(null, element);
            mapping.SetKeyInternal(XmlMapping.GenerateKey(type, a.XmlRoot, defaultNamespace));
            return mapping;
        }
 /// <include file='doc\XmlReflectionImporter.uex' path='docs/doc[@for="XmlReflectionImporter.ImportTypeMapping3"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public XmlTypeMapping ImportTypeMapping(Type type, XmlRootAttribute root, string defaultNamespace) {
     if (type == null)
         throw new ArgumentNullException("type");
     XmlTypeMapping xmlMapping = new XmlTypeMapping(typeScope, ImportElement(modelScope.GetTypeModel(type), root, defaultNamespace));
     xmlMapping.SetKeyInternal(XmlMapping.GenerateKey(type, root, defaultNamespace));
     xmlMapping.GenerateSerializer = true;
     return xmlMapping;
 }
 private static XmlTypeMapping GetKnownMapping(Type type, string ns)
 {
     if ((ns != null) && (ns != string.Empty))
     {
         return null;
     }
     TypeDesc desc = (TypeDesc) TypeScope.PrimtiveTypes[type];
     if (desc == null)
     {
         return null;
     }
     ElementAccessor accessor = new ElementAccessor {
         Name = desc.DataType.Name
     };
     XmlTypeMapping mapping = new XmlTypeMapping(null, accessor);
     mapping.SetKeyInternal(XmlMapping.GenerateKey(type, null, null));
     return mapping;
 }
 internal static XmlTypeMapping GetTopLevelMapping(Type type, string defaultNamespace)
 {
     XmlAttributes attributes = new XmlAttributes(type);
     TypeDesc typeDesc = new TypeScope().GetTypeDesc(type);
     ElementAccessor accessor = new ElementAccessor();
     if (typeDesc.Kind == TypeKind.Node)
     {
         accessor.Any = true;
     }
     else
     {
         string str = (attributes.XmlRoot == null) ? defaultNamespace : attributes.XmlRoot.Namespace;
         string name = string.Empty;
         if (attributes.XmlType != null)
         {
             name = attributes.XmlType.TypeName;
         }
         if (name.Length == 0)
         {
             name = type.Name;
         }
         accessor.Name = XmlConvert.EncodeLocalName(name);
         accessor.Namespace = str;
     }
     XmlTypeMapping mapping = new XmlTypeMapping(null, accessor);
     mapping.SetKeyInternal(XmlMapping.GenerateKey(type, attributes.XmlRoot, defaultNamespace));
     return mapping;
 }
 public XmlTypeMapping ImportTypeMapping(Type type, XmlRootAttribute root, string defaultNamespace)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     XmlTypeMapping mapping = new XmlTypeMapping(this.typeScope, this.ImportElement(this.modelScope.GetTypeModel(type), root, defaultNamespace, new RecursionLimiter()));
     mapping.SetKeyInternal(XmlMapping.GenerateKey(type, root, defaultNamespace));
     mapping.GenerateSerializer = true;
     return mapping;
 }