Moved chain building and validation from Mono.Security to System
[mono.git] / mcs / class / System.XML / System.Xml.Serialization / SerializationSource.cs
index 552924fbf5a6d8423fabd35ce6f36cee08927ff8..9df5c844067ff0899f522907b87c774013014a56 100644 (file)
@@ -34,30 +34,29 @@ using System.Text;
 
 namespace System.Xml.Serialization 
 {
-       internal class SerializationSource 
+#if !NET_2_1 || MONOTOUCH
+       internal abstract class SerializationSource 
        {
-               ArrayList includedTypes;
+               Type[] includedTypes;
                string namspace;
                bool canBeGenerated = true;
                
-               public SerializationSource (string namspace, ArrayList includedTypes)
+               public SerializationSource (string namspace, Type[] includedTypes)
                {
                        this.namspace = namspace;
                        this.includedTypes = includedTypes;
                }
                
-               public override bool Equals (object o)
+               protected bool BaseEquals (SerializationSource other)
                {
-                       SerializationSource other = o as SerializationSource;
-                       if (other == null) return false;
                        if (namspace != other.namspace) return false;
                        if (canBeGenerated != other.canBeGenerated) return false;
                        
                        if (includedTypes == null)
                                return other.includedTypes == null;
                        
-                       if (includedTypes.Count != other.includedTypes.Count) return false;
-                       for (int n=0; n<includedTypes.Count; n++)
+                       if (other.includedTypes == null || includedTypes.Length != other.includedTypes.Length) return false;
+                       for (int n=0; n<includedTypes.Length; n++)
                                if (!includedTypes[n].Equals (other.includedTypes[n])) return false;
 
                        return true;
@@ -76,7 +75,7 @@ namespace System.Xml.Serialization
                Type type;
                string rootHash;
                
-               public XmlTypeSerializationSource (Type type, XmlRootAttribute root, XmlAttributeOverrides attributeOverrides, string namspace, ArrayList includedTypes)
+               public XmlTypeSerializationSource (Type type, XmlRootAttribute root, XmlAttributeOverrides attributeOverrides, string namspace, Type[] includedTypes)
                : base (namspace, includedTypes)
                {
                        if (attributeOverrides != null) {
@@ -103,7 +102,7 @@ namespace System.Xml.Serialization
                        if (rootHash != other.rootHash) return false;
                        if (attributeOverridesHash != other.attributeOverridesHash) return false;
                        
-                       return base.Equals (o);
+                       return base.BaseEquals (other);
                }
                
                public override int GetHashCode ()
@@ -117,7 +116,7 @@ namespace System.Xml.Serialization
                string attributeOverridesHash;
                Type type;
                
-               public SoapTypeSerializationSource (Type type, SoapAttributeOverrides attributeOverrides, string namspace, ArrayList includedTypes)
+               public SoapTypeSerializationSource (Type type, SoapAttributeOverrides attributeOverrides, string namspace, Type[] includedTypes)
                : base (namspace, includedTypes)
                {
                        if (attributeOverrides != null) {
@@ -136,7 +135,7 @@ namespace System.Xml.Serialization
                        if (!type.Equals(other.type)) return false;
                        if (attributeOverridesHash != other.attributeOverridesHash) return false;
                        
-                       return base.Equals (o);
+                       return base.BaseEquals (other);
                }
                
                public override int GetHashCode ()
@@ -154,7 +153,7 @@ namespace System.Xml.Serialization
                bool literalFormat;
                
                public MembersSerializationSource (string elementName, bool hasWrapperElement, XmlReflectionMember [] members, bool writeAccessors, 
-                                                                                  bool literalFormat, string namspace, ArrayList includedTypes)
+                                                                                  bool literalFormat, string namspace, Type[] includedTypes)
                : base (namspace, includedTypes)
                {
                        this.elementName = elementName;
@@ -180,7 +179,7 @@ namespace System.Xml.Serialization
                        if (hasWrapperElement != other.hasWrapperElement) return false;
                        if (membersHash != other.membersHash) return false;
                        
-                       return base.Equals (o);
+                       return base.BaseEquals (other);
                }
                
                public override int GetHashCode ()
@@ -188,49 +187,7 @@ namespace System.Xml.Serialization
                        return membersHash.GetHashCode ();
                }
        }
+#endif
        
-       internal class KeyHelper
-       {
-               public static void AddField (StringBuilder sb, int n, string val)
-               {
-                       AddField (sb, n, val, null);
-               }
-               
-               public static void AddField (StringBuilder sb, int n, string val, string def)
-               {
-                       if (val != def) {
-                               sb.Append (n.ToString());
-                               sb.Append (val.Length.ToString(CultureInfo.InvariantCulture));
-                               sb.Append (val);
-                       }
-               }
-               
-               public static void AddField (StringBuilder sb, int n, bool val)
-               {
-                       AddField (sb, n, val, false);
-               }
-               
-               public static void AddField (StringBuilder sb, int n, bool val, bool def)
-               {
-                       if (val != def)
-                               sb.Append (n.ToString());
-               }
-               
-               public static void AddField (StringBuilder sb, int n, int val, int def)
-               {
-                       if (val != def) {
-                               sb.Append (n.ToString());
-                               sb.Append (val.ToString(CultureInfo.InvariantCulture));
-                       }
-               }
-               
-               public static void AddField (StringBuilder sb, int n, Type val)
-               {
-                       if (val != null) {
-                               sb.Append (n.ToString(CultureInfo.InvariantCulture));
-                               sb.Append (val.ToString());
-                       }
-               }
-       }
 }