public override bool Equals(object obj)
            {
                XmlSerializerMappingKey other = obj as XmlSerializerMappingKey;

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

                if (this.Mapping.Key != other.Mapping.Key)
                {
                    return(false);
                }

                if (this.Mapping.ElementName != other.Mapping.ElementName)
                {
                    return(false);
                }

                if (this.Mapping.Namespace != other.Mapping.Namespace)
                {
                    return(false);
                }

                if (this.Mapping.IsSoap != other.Mapping.IsSoap)
                {
                    return(false);
                }

                return(true);
            }
Exemple #2
0
        private static XmlSerializer[] GetSerializersFromCache(XmlMapping[] mappings, Type type)
        {
            XmlSerializer[] serializers = new XmlSerializer[mappings.Length];

            Hashtable typedMappingTable = null;

            lock (s_xmlSerializerTable)
            {
                typedMappingTable = s_xmlSerializerTable[type] as Hashtable;
                if (typedMappingTable == null)
                {
                    typedMappingTable          = new Hashtable();
                    s_xmlSerializerTable[type] = typedMappingTable;
                }
            }

            lock (typedMappingTable)
            {
                Hashtable pendingKeys = new Hashtable();
                for (int i = 0; i < mappings.Length; i++)
                {
                    XmlSerializerMappingKey mappingKey = new XmlSerializerMappingKey(mappings[i]);
                    serializers[i] = typedMappingTable[mappingKey] as XmlSerializer;
                    if (serializers[i] == null)
                    {
                        pendingKeys.Add(mappingKey, i);
                    }
                }

                if (pendingKeys.Count > 0)
                {
                    XmlMapping[] pendingMappings = new XmlMapping[pendingKeys.Count];
                    int          index           = 0;
                    foreach (XmlSerializerMappingKey mappingKey in pendingKeys.Keys)
                    {
                        pendingMappings[index++] = mappingKey.Mapping;
                    }

                    TempAssembly tempAssembly            = new TempAssembly(pendingMappings, new Type[] { type }, null, null);
                    XmlSerializerImplementation contract = tempAssembly.Contract;

                    foreach (XmlSerializerMappingKey mappingKey in pendingKeys.Keys)
                    {
                        index = (int)pendingKeys[mappingKey];
                        serializers[index] = (XmlSerializer)contract.TypedSerializers[mappingKey.Mapping.Key];
                        serializers[index].SetTempAssembly(tempAssembly, mappingKey.Mapping);

                        typedMappingTable[mappingKey] = serializers[index];
                    }
                }
            }

            return(serializers);
        }
        private static XmlSerializer[] GetSerializersFromCache(XmlMapping[] mappings, Type type)
        {
            XmlSerializer[] serializers = new XmlSerializer[mappings.Length];

            Dictionary <XmlSerializerMappingKey, XmlSerializer> typedMappingTable = null;

            lock (s_xmlSerializerTable)
            {
                if (!s_xmlSerializerTable.TryGetValue(type, out typedMappingTable))
                {
                    typedMappingTable          = new Dictionary <XmlSerializerMappingKey, XmlSerializer>();
                    s_xmlSerializerTable[type] = typedMappingTable;
                }
            }

            lock (typedMappingTable)
            {
                var pendingKeys = new Dictionary <XmlSerializerMappingKey, int>();
                for (int i = 0; i < mappings.Length; i++)
                {
                    XmlSerializerMappingKey mappingKey = new XmlSerializerMappingKey(mappings[i]);
                    if (!typedMappingTable.TryGetValue(mappingKey, out serializers[i]))
                    {
                        pendingKeys.Add(mappingKey, i);
                    }
                }

                if (pendingKeys.Count > 0)
                {
                    XmlMapping[] pendingMappings = new XmlMapping[pendingKeys.Count];
                    int          index           = 0;
                    foreach (XmlSerializerMappingKey mappingKey in pendingKeys.Keys)
                    {
                        pendingMappings[index++] = mappingKey.Mapping;
                    }

                    TempAssembly tempAssembly            = new TempAssembly(pendingMappings, new Type[] { type }, null, null);
                    XmlSerializerImplementation contract = tempAssembly.Contract;

                    foreach (XmlSerializerMappingKey mappingKey in pendingKeys.Keys)
                    {
                        index = pendingKeys[mappingKey];
                        serializers[index] = (XmlSerializer)contract.TypedSerializers[mappingKey.Mapping.Key];
                        serializers[index].SetTempAssembly(tempAssembly, mappingKey.Mapping);

                        typedMappingTable[mappingKey] = serializers[index];
                    }
                }
            }

            return(serializers);
        }
        private static XmlSerializer[] GetSerializersFromCache(XmlMapping[] mappings, Type type)
        {
            XmlSerializer[] serializerArray = new XmlSerializer[mappings.Length];
            Hashtable       hashtable       = null;

            lock (xmlSerializerTable)
            {
                hashtable = xmlSerializerTable[type] as Hashtable;
                if (hashtable == null)
                {
                    hashtable = new Hashtable();
                    xmlSerializerTable[type] = hashtable;
                }
            }
            lock (hashtable)
            {
                Hashtable hashtable2 = new Hashtable();
                for (int i = 0; i < mappings.Length; i++)
                {
                    XmlSerializerMappingKey key = new XmlSerializerMappingKey(mappings[i]);
                    serializerArray[i] = hashtable[key] as XmlSerializer;
                    if (serializerArray[i] == null)
                    {
                        hashtable2.Add(key, i);
                    }
                }
                if (hashtable2.Count <= 0)
                {
                    return(serializerArray);
                }
                XmlMapping[] xmlMappings = new XmlMapping[hashtable2.Count];
                int          index       = 0;
                foreach (XmlSerializerMappingKey key2 in hashtable2.Keys)
                {
                    xmlMappings[index++] = key2.Mapping;
                }
                TempAssembly tempAssembly            = new TempAssembly(xmlMappings, new Type[] { type }, null, null, null);
                XmlSerializerImplementation contract = tempAssembly.Contract;
                foreach (XmlSerializerMappingKey key3 in hashtable2.Keys)
                {
                    index = (int)hashtable2[key3];
                    serializerArray[index] = (XmlSerializer)contract.TypedSerializers[key3.Mapping.Key];
                    serializerArray[index].SetTempAssembly(tempAssembly, key3.Mapping);
                    hashtable[key3] = serializerArray[index];
                }
            }
            return(serializerArray);
        }
        private static XmlSerializer[] GetSerializersFromCache(XmlMapping[] mappings, Type type)
        {
            XmlSerializer[] serializers = new XmlSerializer[mappings.Length];

            Dictionary<XmlSerializerMappingKey, XmlSerializer> typedMappingTable = null;
            lock (s_xmlSerializerTable)
            {
                if (!s_xmlSerializerTable.TryGetValue(type, out typedMappingTable))
                {
                    typedMappingTable = new Dictionary<XmlSerializerMappingKey, XmlSerializer>();
                    s_xmlSerializerTable[type] = typedMappingTable;
                }
            }

            lock (typedMappingTable)
            {
                var pendingKeys = new Dictionary<XmlSerializerMappingKey, int>();
                for (int i = 0; i < mappings.Length; i++)
                {
                    XmlSerializerMappingKey mappingKey = new XmlSerializerMappingKey(mappings[i]);
                    if (!typedMappingTable.TryGetValue(mappingKey, out serializers[i]))
                    {
                        pendingKeys.Add(mappingKey, i);
                    }
                }

                if (pendingKeys.Count > 0)
                {
                    XmlMapping[] pendingMappings = new XmlMapping[pendingKeys.Count];
                    int index = 0;
                    foreach (XmlSerializerMappingKey mappingKey in pendingKeys.Keys)
                    {
                        pendingMappings[index++] = mappingKey.Mapping;
                    }

                    TempAssembly tempAssembly = new TempAssembly(pendingMappings, new Type[] { type }, null, null, null);
                    XmlSerializerImplementation contract = tempAssembly.Contract;

                    foreach (XmlSerializerMappingKey mappingKey in pendingKeys.Keys)
                    {
                        index = pendingKeys[mappingKey];
                        serializers[index] = (XmlSerializer)contract.TypedSerializers[mappingKey.Mapping.Key];
                        serializers[index].SetTempAssembly(tempAssembly, mappingKey.Mapping);

                        typedMappingTable[mappingKey] = serializers[index];
                    }
                }
            }

            return serializers;
        }
Exemple #6
0
        private static XmlSerializer[] GetSerializersFromCache(XmlMapping[] mappings, Type type)
        {
            XmlSerializer[] serializers = new XmlSerializer[mappings.Length];

            InternalHashtable typedMappingTable = null;
            lock (s_xmlSerializerTable)
            {
                typedMappingTable = s_xmlSerializerTable[type] as InternalHashtable;
                if (typedMappingTable == null)
                {
                    typedMappingTable = new InternalHashtable();
                    s_xmlSerializerTable[type] = typedMappingTable;
                }
            }

            lock (typedMappingTable)
            {
                InternalHashtable pendingKeys = new InternalHashtable();
                for (int i = 0; i < mappings.Length; i++)
                {
                    XmlSerializerMappingKey mappingKey = new XmlSerializerMappingKey(mappings[i]);
                    serializers[i] = typedMappingTable[mappingKey] as XmlSerializer;
                    if (serializers[i] == null)
                    {
                        pendingKeys.Add(mappingKey, i);
                    }
                }

                if (pendingKeys.Count > 0)
                {
                    XmlMapping[] pendingMappings = new XmlMapping[pendingKeys.Count];
                    int index = 0;
                    foreach (XmlSerializerMappingKey mappingKey in pendingKeys.Keys)
                    {
                        pendingMappings[index++] = mappingKey.Mapping;
                    }

                    TempAssembly tempAssembly = new TempAssembly(pendingMappings, new Type[] { type }, null, null, null);
                    XmlSerializerImplementation contract = tempAssembly.Contract;

                    foreach (XmlSerializerMappingKey mappingKey in pendingKeys.Keys)
                    {
                        index = (int)pendingKeys[mappingKey];
                        serializers[index] = (XmlSerializer)contract.TypedSerializers[mappingKey.Mapping.Key];
                        serializers[index].SetTempAssembly(tempAssembly, mappingKey.Mapping);

                        typedMappingTable[mappingKey] = serializers[index];
                    }
                }
            }

            return serializers;
        }
 private static XmlSerializer[] GetSerializersFromCache(XmlMapping[] mappings, Type type)
 {
     XmlSerializer[] serializerArray = new XmlSerializer[mappings.Length];
     Hashtable hashtable = null;
     lock (xmlSerializerTable)
     {
         hashtable = xmlSerializerTable[type] as Hashtable;
         if (hashtable == null)
         {
             hashtable = new Hashtable();
             xmlSerializerTable[type] = hashtable;
         }
     }
     lock (hashtable)
     {
         Hashtable hashtable2 = new Hashtable();
         for (int i = 0; i < mappings.Length; i++)
         {
             XmlSerializerMappingKey key = new XmlSerializerMappingKey(mappings[i]);
             serializerArray[i] = hashtable[key] as XmlSerializer;
             if (serializerArray[i] == null)
             {
                 hashtable2.Add(key, i);
             }
         }
         if (hashtable2.Count <= 0)
         {
             return serializerArray;
         }
         XmlMapping[] xmlMappings = new XmlMapping[hashtable2.Count];
         int index = 0;
         foreach (XmlSerializerMappingKey key2 in hashtable2.Keys)
         {
             xmlMappings[index++] = key2.Mapping;
         }
         TempAssembly tempAssembly = new TempAssembly(xmlMappings, new Type[] { type }, null, null, null);
         XmlSerializerImplementation contract = tempAssembly.Contract;
         foreach (XmlSerializerMappingKey key3 in hashtable2.Keys)
         {
             index = (int) hashtable2[key3];
             serializerArray[index] = (XmlSerializer) contract.TypedSerializers[key3.Mapping.Key];
             serializerArray[index].SetTempAssembly(tempAssembly, key3.Mapping);
             hashtable[key3] = serializerArray[index];
         }
     }
     return serializerArray;
 }