Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        XmlSerializationReader CreateReader(XmlMapping typeMapping)
        {
            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");
                }
            }

            return(new XmlSerializationReaderInterpreter(typeMapping));
        }
Esempio n. 3
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);
        }
 public XmlSerializationWriterInterpreter(XmlMapping typeMap)
 {
     _typeMap = typeMap;
     _format  = typeMap.Format;
 }
Esempio n. 5
0
 void CheckGeneratedTypes(XmlMapping typeMapping)
 {
     throw new NotImplementedException();
 }
Esempio n. 6
0
 internal XmlSerializer(XmlMapping mapping, SerializerData data)
 {
     typeMapping    = mapping;
     serializerData = data;
 }
Esempio n. 7
0
 public XmlSerializer(XmlTypeMapping xmlTypeMapping)
 {
     typeMapping = xmlTypeMapping;
 }