XmlSerializer GetSerializer(MessageBodyDescription desc)
        {
            if (bodySerializers.ContainsKey(desc))
            {
                return(bodySerializers [desc]);
            }

            int count = desc.Parts.Count + (HasReturnValue(desc) ? 1 : 0);

            XmlReflectionMember [] members = new XmlReflectionMember [count];

            int ind = 0;

            if (HasReturnValue(desc))
            {
                members [ind++] = CreateReflectionMember(desc.ReturnValue, true);
            }

            foreach (MessagePartDescription partDesc in desc.Parts)
            {
                members [ind++] = CreateReflectionMember(partDesc, false);
            }

            XmlReflectionImporter xmlImporter = new XmlReflectionImporter();

            // Register known types into xmlImporter.
            foreach (var type in OperationKnownTypes)
            {
                xmlImporter.IncludeType(type);
            }
            XmlMembersMapping [] partsMapping = new XmlMembersMapping [1];
            partsMapping [0]       = xmlImporter.ImportMembersMapping(desc.WrapperName, desc.WrapperNamespace, members, true);
            bodySerializers [desc] = XmlSerializer.FromMappings(partsMapping) [0];
            return(bodySerializers [desc]);
        }
Beispiel #2
0
        /// <include file='doc\XmlSerializer.uex' path='docs/doc[@for="XmlSerializer.XmlSerializer7"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            DefaultNamespace = defaultNamespace;
            rootType         = type;
            XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);

            if (extraTypes != null)
            {
                for (int i = 0; i < extraTypes.Length; i++)
                {
                    importer.IncludeType(extraTypes[i]);
                }
            }
            _mapping = importer.ImportTypeMapping(type, root, defaultNamespace);
            if (location != null)
            {
                DemandForUserLocationOrEvidence();
            }

#if !uapaot
            _tempAssembly = GenerateTempAssembly(_mapping, type, defaultNamespace, location);
#endif
        }
Beispiel #3
0
        XmlTypeMapping GetLiteralTypeMapping()
        {
            XmlRootAttribute root = new XmlRootAttribute("rootroot");

            Type[] types             = new Type[] { typeof(UknTestPart), typeof(AnotherTestPart), typeof(DblStringContainer) };
            XmlReflectionImporter ri = new XmlReflectionImporter();

            foreach (Type t in types)
            {
                ri.IncludeType(t);
            }
            return(ri.ImportTypeMapping(typeof(Test), root));
        }
Beispiel #4
0
        private XmlTypeMapping GenerateXmlTypeMapping(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace)
        {
            XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);

            if (extraTypes != null)
            {
                for (int i = 0; i < extraTypes.Length; i++)
                {
                    importer.IncludeType(extraTypes[i]);
                }
            }

            return(importer.ImportTypeMapping(type, root, defaultNamespace));
        }
        public XmlSerializer(Type type,
                             XmlAttributeOverrides overrides,
                             Type [] extraTypes,
                             XmlRootAttribute root,
                             string defaultNamespace)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);

            if (extraTypes != null)
            {
                foreach (Type intype in extraTypes)
                {
                    importer.IncludeType(intype);
                }
            }

            typeMapping = importer.ImportTypeMapping(type, root, defaultNamespace);
        }