XmlSerializationReader CreateReader(XmlMapping typeMapping)
        {
#if !NET_2_1
            XmlSerializationReader reader;

            lock (this) {
                if (serializerData != null)
                {
                    lock (serializerData) {
                        reader = serializerData.CreateReader();
                    }
                    if (reader != null)
                    {
                        return(reader);
                    }
                }
            }

            if (!typeMapping.Source.CanBeGenerated || generationThreshold == -1)
            {
                return(new XmlSerializationReaderInterpreter(typeMapping));
            }

            CheckGeneratedTypes(typeMapping);

            lock (this) {
                lock (serializerData) {
                    reader = serializerData.CreateReader();
                }
                if (reader != null)
                {
                    return(reader);
                }
                if (!generatorFallback)
                {
                    throw new InvalidOperationException("Error while generating serializer");
                }
            }
#endif
            return(new XmlSerializationReaderInterpreter(typeMapping));
        }
        void CheckGeneratedTypes(XmlMapping typeMapping)
        {
            lock (this)
            {
                if (serializerData == null)
                {
                    lock (serializerTypes)
                    {
                        serializerData = (SerializerData)serializerTypes [typeMapping.Source];
                        if (serializerData == null)
                        {
                            serializerData = new SerializerData();
                            serializerTypes [typeMapping.Source] = serializerData;
                        }
                    }
                }
            }

            bool generate = false;

            lock (serializerData)
            {
                generate = (++serializerData.UsageCount == generationThreshold);
            }

            if (generate)
            {
                if (serializerData.Batch != null)
                {
                    GenerateSerializersAsync(serializerData.Batch);
                }
                else
                {
                    GenerationBatch batch = new GenerationBatch();
                    batch.Maps  = new XmlMapping[] { typeMapping };
                    batch.Datas = new SerializerData[] { serializerData };
                    GenerateSerializersAsync(batch);
                }
            }
        }
        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);
        }
 public XmlSerializationWriterInterpreter(XmlMapping typeMap)
 {
     _typeMap = typeMap;
     _format  = typeMap.Format;
 }
 void CheckGeneratedTypes(XmlMapping typeMapping)
 {
     throw new NotImplementedException();
 }
 internal XmlSerializer(XmlMapping mapping, SerializerData data)
 {
     typeMapping    = mapping;
     serializerData = data;
 }
 public XmlSerializer(XmlTypeMapping xmlTypeMapping)
 {
     typeMapping = xmlTypeMapping;
 }