Inheritance: SerializationSource
        /// <summary>Returns a derivation of the <see cref="T:System.Xml.Serialization.XmlSerializer" /> class that can serialize objects of the specified type into XML document instances, and vice versa. Each object to be serialized can itself contain instances of classes, which this overload can override 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>
        /// <returns>A derivation of the <see cref="T:System.Xml.Serialization.XmlSerializer" />.</returns>
        /// <param name="type">The <see cref="T:System.Type" /> to serialize.</param>
        /// <param name="overrides">An <see cref="T:System.Xml.Serialization.XmlAttributeOverrides" /> that contains fields that override the default serialization behavior.</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 represents the XML root element.</param>
        /// <param name="defaultNamespace">The default namespace of all XML elements in the XML document. </param>
        public XmlSerializer CreateSerializer(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, string defaultNamespace)
        {
            XmlTypeSerializationSource key = new XmlTypeSerializationSource(type, root, overrides, defaultNamespace, extraTypes);
            Hashtable     obj = XmlSerializerFactory.serializersBySource;
            XmlSerializer result;

            lock (obj)
            {
                XmlSerializer xmlSerializer = (XmlSerializer)XmlSerializerFactory.serializersBySource[key];
                if (xmlSerializer == null)
                {
                    xmlSerializer = new XmlSerializer(type, overrides, extraTypes, root, defaultNamespace);
                    XmlSerializerFactory.serializersBySource[xmlSerializer.Mapping.Source] = xmlSerializer;
                }
                result = xmlSerializer;
            }
            return(result);
        }
Example #2
0
        public XmlSerializer CreateSerializer(Type type,
                                              XmlAttributeOverrides overrides,
                                              Type[] extraTypes,
                                              XmlRootAttribute root,
                                              string defaultNamespace)
        {
            XmlTypeSerializationSource source = new XmlTypeSerializationSource(type, root, overrides, defaultNamespace, extraTypes);

            lock (serializersBySource)
            {
                XmlSerializer ser = (XmlSerializer)serializersBySource [source];
                if (ser == null)
                {
                    ser = new XmlSerializer(type, overrides, extraTypes, root, defaultNamespace);
                    serializersBySource [ser.Mapping.Source] = ser;
                }
                return(ser);
            }
        }
        public override bool Equals(object o)
        {
            XmlTypeSerializationSource other = o as XmlTypeSerializationSource;

            if (other == null)
            {
                return(false);
            }

            if (!type.Equals(other.type))
            {
                return(false);
            }
            if (rootHash != other.rootHash)
            {
                return(false);
            }
            if (attributeOverridesHash != other.attributeOverridesHash)
            {
                return(false);
            }

            return(base.BaseEquals(other));
        }
        public override bool Equals(object o)
        {
            XmlTypeSerializationSource xmlTypeSerializationSource = o as XmlTypeSerializationSource;

            return(xmlTypeSerializationSource != null && this.type.Equals(xmlTypeSerializationSource.type) && !(this.rootHash != xmlTypeSerializationSource.rootHash) && !(this.attributeOverridesHash != xmlTypeSerializationSource.attributeOverridesHash) && base.BaseEquals(xmlTypeSerializationSource));
        }
		public XmlSerializer CreateSerializer (Type type, 
			XmlAttributeOverrides overrides, 
			Type[] extraTypes, 
			XmlRootAttribute root, 
			string defaultNamespace)
		{
			XmlTypeSerializationSource source = new XmlTypeSerializationSource (type, root, overrides, defaultNamespace, extraTypes);
			lock (serializersBySource) 
			{
				XmlSerializer ser = (XmlSerializer) serializersBySource [source];
				if (ser == null) {
					ser = new XmlSerializer (type, overrides, extraTypes, root, defaultNamespace);
					serializersBySource [ser.Mapping.Source] = ser;
				}
				return ser;
			}
		}