IncludeType() public method

public IncludeType ( Type type ) : void
type System.Type
return void
Esempio n. 1
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 !NET_NATIVE
            _tempAssembly = GenerateTempAssembly(_mapping, type, defaultNamespace, location);
#endif
        }
Esempio n. 2
0
        /// <include file='doc\XmlSerializer.uex' path='docs/doc[@for="XmlSerializer.XmlSerializer7"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        internal XmlSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location, Evidence evidence)
        {
#if NET_NATIVE
            throw new PlatformNotSupportedException();
#else
            if (type == null)
            {
                throw new ArgumentNullException(nameof(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 || evidence != null)
            {
                DemandForUserLocationOrEvidence();
            }
            _tempAssembly = GenerateTempAssembly(_mapping, type, defaultNamespace, location, evidence);
#endif
        }
Esempio n. 3
0
 /// <include file='doc\XmlSerializer.uex' path='docs/doc[@for="XmlSerializer.XmlSerializer"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public XmlSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace) {
     XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);
     for (int i = 0; i < extraTypes.Length; i++)
         importer.IncludeType(extraTypes[i]);
     tempAssembly = GenerateTempAssembly(importer.ImportTypeMapping(type, root));
     this.events.sender = this;
 }
Esempio n. 4
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);
		}
Esempio n. 5
0
        /// <include file='doc\XmlSerializer.uex' path='docs/doc[@for="XmlSerializer.XmlSerializer"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace)
        {
            XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);

            for (int i = 0; i < extraTypes.Length; i++)
            {
                importer.IncludeType(extraTypes[i]);
            }
            tempAssembly       = GenerateTempAssembly(importer.ImportTypeMapping(type, root));
            this.events.sender = this;
        }
Esempio n. 6
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, string location, Evidence evidence)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);

            for (int i = 0; i < extraTypes.Length; i++)
            {
                importer.IncludeType(extraTypes[i]);
            }
            this.mapping = importer.ImportTypeMapping(type, root, defaultNamespace);
            tempAssembly = GenerateTempAssembly(this.mapping, type, defaultNamespace, location, evidence);
        }
        public XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location, Evidence evidence)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);

            for (int i = 0; i < extraTypes.Length; i++)
            {
                importer.IncludeType(extraTypes[i]);
            }
            XmlTypeMapping xmlMapping = importer.ImportTypeMapping(type, root, defaultNamespace);

            return((XmlSerializer)XmlSerializer.GenerateTempAssembly(xmlMapping, type, defaultNamespace, location, evidence).Contract.TypedSerializers[xmlMapping.Key]);
        }
        /// <summary>Initializes a new instance of the <see cref="T:System.Xml.Serialization.XmlSerializer" /> class that can serialize objects of type <see cref="T:System.Object" /> into XML document instances, and deserialize XML document instances into objects of type <see cref="T:System.Object" />. Each object to be serialized can itself contain instances of classes, which this overload overrides with other classes. This overload also specifies the default namespace for all the XML elements and the class to use as the XML root element.</summary>
        /// <param name="type">The type of the object that this <see cref="T:System.Xml.Serialization.XmlSerializer" /> can serialize. </param>
        /// <param name="overrides">An <see cref="T:System.Xml.Serialization.XmlAttributeOverrides" /> that extends or overrides the behavior of the class specified in the <paramref name="type" /> parameter. </param>
        /// <param name="extraTypes">A <see cref="T:System.Type" /> array of additional object types to serialize. </param>
        /// <param name="root">An <see cref="T:System.Xml.Serialization.XmlRootAttribute" /> that defines the XML root element properties. </param>
        /// <param name="defaultNamespace">The default namespace of all XML elements in the XML document. </param>
        public XmlSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            XmlReflectionImporter xmlReflectionImporter = new XmlReflectionImporter(overrides, defaultNamespace);

            if (extraTypes != null)
            {
                foreach (Type type2 in extraTypes)
                {
                    xmlReflectionImporter.IncludeType(type2);
                }
            }
            this.typeMapping = xmlReflectionImporter.ImportTypeMapping(type, root, defaultNamespace);
        }
Esempio n. 10
0
        public XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (location != null)
            {
                DemandForUserLocationOrEvidence();
            }

            XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);

            for (int i = 0; i < extraTypes.Length; i++)
            {
                importer.IncludeType(extraTypes[i]);
            }
            XmlTypeMapping mapping      = importer.ImportTypeMapping(type, root, defaultNamespace);
            TempAssembly   tempAssembly = XmlSerializer.GenerateTempAssembly(mapping, type, defaultNamespace, location);

            return((XmlSerializer)tempAssembly.Contract.TypedSerializers[mapping.Key]);
        }
Esempio n. 11
0
        private void Init(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, object location, object evidence)
        {
            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 !NET_NATIVE
            _tempAssembly = GenerateTempAssembly(_mapping, type, defaultNamespace);
#endif
        }
Esempio n. 12
0
		[Test] // bug #76049
		public void TestIncludeType ()
		{
			XmlReflectionImporter imp = new XmlReflectionImporter ();
			XmlTypeMapping map = imp.ImportTypeMapping (typeof (object));
			imp.IncludeType (typeof (TestSpace));
			XmlSerializer ser = new XmlSerializer (map);
			ser.Serialize (new StringWriter (), new TestSpace ());
		}
 public XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location, Evidence evidence)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);
     for (int i = 0; i < extraTypes.Length; i++)
     {
         importer.IncludeType(extraTypes[i]);
     }
     XmlTypeMapping xmlMapping = importer.ImportTypeMapping(type, root, defaultNamespace);
     return (XmlSerializer) XmlSerializer.GenerateTempAssembly(xmlMapping, type, defaultNamespace, location, evidence).Contract.TypedSerializers[xmlMapping.Key];
 }
Esempio n. 14
0
        private void Init(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, object location, object evidence)
        {
            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 !NET_NATIVE
            _tempAssembly = GenerateTempAssembly(_mapping, type, defaultNamespace);
#endif
        }
Esempio n. 15
0
		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);
		}
Esempio n. 16
0
        internal XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location, Evidence evidence)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (location != null || evidence != null)
            {
                DemandForUserLocationOrEvidence();
            }

            XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);
            for (int i = 0; i < extraTypes.Length; i++)
                importer.IncludeType(extraTypes[i]);
            XmlTypeMapping mapping = importer.ImportTypeMapping(type, root, defaultNamespace);
            TempAssembly tempAssembly = XmlSerializer.GenerateTempAssembly(mapping, type, defaultNamespace, location, evidence);
            return (XmlSerializer)tempAssembly.Contract.TypedSerializers[mapping.Key];
        }
 public XmlSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location, Evidence evidence)
 {
     this.events = new XmlDeserializationEvents();
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);
     if (extraTypes != null)
     {
         for (int i = 0; i < extraTypes.Length; i++)
         {
             importer.IncludeType(extraTypes[i]);
         }
     }
     this.mapping = importer.ImportTypeMapping(type, root, defaultNamespace);
     if (location != null)
     {
         this.DemandForUserLocation();
     }
     this.tempAssembly = GenerateTempAssembly(this.mapping, type, defaultNamespace, location, evidence);
 }
Esempio n. 18
0
        /// <include file='doc\XmlSerializer.uex' path='docs/doc[@for="XmlSerializer.XmlSerializer7"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        internal XmlSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, object location, object evidence)
        {
#if NET_NATIVE
            throw new PlatformNotSupportedException();
#else
            if (type == null)
                throw new ArgumentNullException("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);
            _tempAssembly = GenerateTempAssembly(_mapping, type, defaultNamespace);
#endif
        }
Esempio n. 19
0
		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];
		}
        /// <include file='doc\XmlSerializer.uex' path='docs/doc[@for="XmlSerializer.XmlSerializer7"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        internal XmlSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location, Evidence evidence)
        {
            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 || evidence != null)
            {
                DemandForUserLocationOrEvidence();
            }

#if !NET_NATIVE
            _tempAssembly = GenerateTempAssembly(_mapping, type, defaultNamespace, location, evidence);
#endif
        }
 public XmlSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace, string location, Evidence evidence) {
     if (type == null)
         throw new ArgumentNullException("type");
     XmlReflectionImporter importer = new XmlReflectionImporter(overrides, defaultNamespace);
     for (int i = 0; i < extraTypes.Length; i++)
         importer.IncludeType(extraTypes[i]);
     this.mapping = importer.ImportTypeMapping(type, root, defaultNamespace);
     tempAssembly = GenerateTempAssembly(this.mapping, type, defaultNamespace, location, evidence);
 }