Sfoglia il codice sorgente

2002-07-24 Tim Coleman <[email protected]>
* CodeIdentifier.cs:
* IXmlSerializable.cs:
* XmlSerializationCollectionFixupCallback.cs:
* XmlSerializationFixupCallback.cs:
* XmlSerializationReadCallback.cs:
* XmlSerializationReader.cs:
* XmlSerializationWriteCallback.cs:
Add new classes.
* XmlSchemas.cs
* CodeIdentifiers.cs:
Implement some of these classes
* XmlCodeExporter.cs:
Fix return type of a function

svn path=/trunk/mcs/; revision=6157

Tim Coleman 23 anni fa
parent
commit
52a614cc31

+ 15 - 0
mcs/class/System.XML/System.Xml.Serialization/ChangeLog

@@ -1,3 +1,18 @@
+2002-07-24  Tim Coleman <[email protected]>
+	* CodeIdentifier.cs:
+	* IXmlSerializable.cs:
+	* XmlSerializationCollectionFixupCallback.cs:
+	* XmlSerializationFixupCallback.cs:
+	* XmlSerializationReadCallback.cs:
+	* XmlSerializationReader.cs:
+	* XmlSerializationWriteCallback.cs:
+		Add new classes.
+	* XmlSchemas.cs
+	* CodeIdentifiers.cs:
+		Implement some of these classes
+	* XmlCodeExporter.cs:
+		Fix return type of a function
+
 2002-07-24  Tim Coleman <[email protected]>
 	* SoapReflectionImporter.cs:
 		New class added to build

+ 50 - 0
mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs

@@ -0,0 +1,50 @@
+//
+// System.Xml.Serialization.CodeIdentifier.cs
+//
+// Author: 
+//    Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+
+namespace System.Xml.Serialization {
+	public class CodeIdentifier {
+
+		public CodeIdentifier ()
+		{
+		}
+
+		public static string MakeCamel (string identifier)
+		{
+			string validIdentifier = MakeValid (identifier);
+			return (Char.ToLower (validIdentifier[0]) + validIdentifier.Substring (1));
+		}
+
+		public static string MakePascal (string identifier)
+		{
+			string validIdentifier = MakeValid (identifier);
+			return (Char.ToUpper (validIdentifier[0]) + validIdentifier.Substring (1));
+		}
+
+		public static string MakeValid (string identifier)
+		{
+			if (identifier == null)
+				throw new NullReferenceException ();
+			if (identifier.Length == 0)
+				return identifier;
+
+			string output;
+
+			if (Char.IsNumber (identifier[0]))
+				output = "Item";
+
+			foreach (char c in identifier) 
+				if (Char.IsLetterOrDigit (c) || c == '_')
+					output += c;
+
+			return output;
+		}
+	}
+}

+ 25 - 17
mcs/class/System.XML/System.Xml.Serialization/CodeIdentifiers.cs

@@ -7,12 +7,16 @@
 // Copyright (C) Tim Coleman, 2002
 //
 
+using System;
+using System.Collections;
+
 namespace System.Xml.Serialization {
 	public class CodeIdentifiers {
 
 		#region Fields
 
 		bool useCamelCasing;
+		static Hashtable table = new Hashtable ();
 
 		#endregion
 
@@ -35,61 +39,65 @@ namespace System.Xml.Serialization {
 
 		#region Methods
 
-		[MonoTODO]
 		public void Add (string identifier, object value)
 		{
-			throw new NotImplementedException ();
+			table.Add (identifier, value);
 		}
 
-		[MonoTODO]
+		[MonoTODO ("What does this do?")]
 		public void AddReserved (string identifier)
 		{
 			throw new NotImplementedException ();
 		}
 
-		[MonoTODO]
 		public void AddUnique (string identifier, object value)
 		{
-			throw new NotImplementedException ();
+			Add (MakeUnique (identifier), value);
 		}
 
-		[MonoTODO]
 		public void Clear ()
 		{
-			throw new NotImplementedException ();
+			table.Clear ();
 		}
 
-		[MonoTODO]
 		public bool IsInUse (string identifier)
 		{
-			throw new NotImplementedException ();
+			return (table.ContainsKey (identifier));
 		}
 
-		[MonoTODO]
 		public string MakeRightCase (string identifier)
 		{
-			throw new NotImplementedException ();
+			if (UseCamelCasing)
+				return CodeIdentifier.MakeCamel (identifier);
+			else
+				return CodeIdentifier.MakePascal (identifier);
 		}
 
-		[MonoTODO]
 		public string MakeUnique (string identifier)
 		{
-			throw new NotImplementedException ();
+			string uniqueIdentifier = identifier;
+			int i = 1;
+
+			while (IsInUse (uniqueIdentifier)) {
+				uniqueIdentifier = String.Format ("{0}{1}", identifier, i.ToString ());
+				i += 1;
+			}
+
+			return uniqueIdentifier;
 		}
 
-		[MonoTODO]
 		public void Remove (string identifier)
 		{
-			throw new NotImplementedException ();
+			table.Remove (identifier);
 		}
 
-		[MonoTODO]
+		[MonoTODO ("What does this do?")]
 		public void RemoveReserved (string identifier)
 		{
 			throw new NotImplementedException ();
 		}
 
-		[MonoTODO]
+		[MonoTODO ("Need to determine how to do the conversion.")]
 		public object ToArray (Type type)
 		{
 			throw new NotImplementedException ();

+ 19 - 0
mcs/class/System.XML/System.Xml.Serialization/IXmlSerializable.cs

@@ -0,0 +1,19 @@
+//
+// System.Xml.Serialization.IXmlSerializable.cs
+//
+// Author: 
+//    Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.Xml.Schema;
+
+namespace System.Xml.Serialization {
+	public interface IXmlSerializable {
+
+		XmlSchema GetSchema ();
+		void ReadXml (XmlReader reader);
+		void WriteXml (XmlWriter writer);
+	}
+}

+ 1 - 1
mcs/class/System.XML/System.Xml.Serialization/XmlCodeExporter.cs

@@ -71,7 +71,7 @@ namespace System.Xml.Serialization {
 		}
 
 		[MonoTODO]
-		public XmlQualifiedName ExportTypeMapping (XmlTypeMapping xmlTypeMapping)
+		public void ExportTypeMapping (XmlTypeMapping xmlTypeMapping)
 		{
 			throw new NotImplementedException ();
 		}

+ 7 - 12
mcs/class/System.XML/System.Xml.Serialization/XmlSchemas.cs

@@ -15,7 +15,7 @@ namespace System.Xml.Serialization {
 
 		#region Fields
 
-		Hashtable table;
+		static Hashtable table = new Hashtable ();
 
 		#endregion
 
@@ -23,7 +23,6 @@ namespace System.Xml.Serialization {
 
 		public XmlSchemas ()
 		{
-			table = new Hashtable ();
 		}
 
 		#endregion // Constructors
@@ -37,7 +36,7 @@ namespace System.Xml.Serialization {
 
 				return (XmlSchema) List [index]; 
 			}
-			set { throw new NotImplementedException (); }
+			set { List [index] = value; }
 		}
 
 		public XmlSchema this [string ns] {
@@ -86,28 +85,24 @@ namespace System.Xml.Serialization {
 			throw new NotImplementedException ();
 		}
 
-		[MonoTODO]
 		protected override void OnClear ()
 		{
-			throw new NotImplementedException ();
+			table.Clear ();
 		}
 
-		[MonoTODO]
 		protected override void OnInsert (int index, object value)
-		{
-			throw new NotImplementedException ();
+		{	
+			table [((XmlSchema) value).TargetNamespace] = value;
 		}
 
-		[MonoTODO]
 		protected override void OnRemove (int index, object value)
 		{
-			throw new NotImplementedException ();
+			table.Remove (value);
 		}
 
-		[MonoTODO]
 		protected override void OnSet (int index, object oldValue, object newValue)
 		{
-			throw new NotImplementedException ();
+			table [((XmlSchema) oldValue).TargetNamespace] = newValue;
 		}
 	
 		public void Remove (XmlSchema schema)

+ 17 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationCollectionFixupCallback.cs

@@ -0,0 +1,17 @@
+//
+// System.Xml.Serialization.XmlSerializationCollectionFixupCallback.cs: 
+//
+// Author:
+//   Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+
+namespace System.Xml.Serialization {
+	
+	[Serializable]
+	public delegate void XmlSerializationCollectionFixupCallback (object collection, object collectionItems);
+}
+

+ 17 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationFixupCallback.cs

@@ -0,0 +1,17 @@
+//
+// System.Xml.Serialization.XmlSerializationFixupCallback.cs: 
+//
+// Author:
+//   Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+
+namespace System.Xml.Serialization {
+	
+	[Serializable]
+	public delegate void XmlSerializationFixupCallback (object fixup);
+}
+

+ 17 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReadCallback.cs

@@ -0,0 +1,17 @@
+//
+// System.Xml.Serialization.XmlSerializationReadCallback.cs: 
+//
+// Author:
+//   Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+
+namespace System.Xml.Serialization {
+	
+	[Serializable]
+	public delegate object XmlSerializationReadCallback ();
+}
+

+ 454 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs

@@ -0,0 +1,454 @@
+//
+// System.Xml.Serialization.XmlSerializationReader.cs
+//
+// Author:
+//   Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+using System.Collections;
+using System.Xml;
+
+namespace System.Xml.Serialization {
+	public abstract class XmlSerializationReader {
+
+		#region Fields
+
+		XmlDocument document;
+		XmlReader reader;
+
+		#endregion
+
+		[MonoTODO]
+		protected XmlSerializationReader ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		protected XmlDocument Document {
+			get { return document; }
+		}
+
+		protected XmlReader Reader {
+			get { return reader; }
+		}
+
+		#region Methods
+
+		[MonoTODO ("Implement")]
+		protected void AddFixup (XmlSerializationReader.CollectionFixup fixup)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected void AddFixup (XmlSerializationReader.Fixup fixup)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected void AddReadCallback (string name, string ns, Type type, XmlSerializationReadCallback read)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected void AddTarget (string id, object o)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected Exception CreateAbstractTypeException (string name, string ns)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected Exception CreateInvalidCastException (string name, object value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected Exception CreateReadOnlyCollectionException (string name)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected Exception CreateUnknownConstantException (string value, Type enumType)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected Exception CreateUnknownNodeException ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected Exception CreateUnknownTypeException (XmlQualifiedName type)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected Array EnsureArrayIndex (Array a, int index, Type elementType)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected void FixupArrayRefs (object fixup)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected int GetArrayLength (string name, string ns)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected bool GetNullAttr ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected object GetTarget (string id)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected XmlQualifiedName GetXsiType ()
+		{
+			throw new NotImplementedException ();
+		}
+
+
+		protected abstract void InitCallbacks ();
+		protected abstract void InitIDs ();
+
+		[MonoTODO ("Implement")]
+		protected bool IsXmlnsAttribute (string name)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected void ParseWsdlArrayType (XmlAttribute attr)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected XmlQualifiedName ReadElementQualifiedName ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected void ReadEndElement ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected bool ReadNull ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected XmlQualifiedName ReadNullableQualifiedName ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected string ReadNullableString ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected bool ReadReference (out string fixupReference)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected object ReadReferencedElement ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected object ReadReferencedElement (string name, string ns)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected void ReadReferencedElements ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected object ReadReferencingElement (out string fixupReference)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected object ReadReferencingElement (string name, string ns, out string fixupReference)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected object ReadReferencingElement (string name, string ns, bool elementCanBeType, out string fixupReference)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected IXmlSerializable ReadSerializable (IXmlSerializable serializable)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected string ReadString (string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected object ReadTypedPrimitive (XmlQualifiedName type)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected XmlNode ReadXmlNode (bool wrapped)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected void Referenced (object o)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected Array ShrinkArray (Array a, int length, Type elementType, bool isNullable)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected byte[] ToByteArrayBase64 (bool isNull)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected static byte[] ToByteArrayBase64 (string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected byte[] ToByteArrayHex (bool isNull)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected static byte[] ToByteArrayHex (string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected static char ToChar (string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected static DateTime ToDate (string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected static DateTime ToDateTime (string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected static long ToEnum (string value, Hashtable h, string typeName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected static DateTime ToTime (string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected static string ToXmlName (string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected static string ToXmlNCName (string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected static string ToXmlNmToken (string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected static string ToXmlNmTokens (string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected XmlQualifiedName ToXmlQualifiedName (string value)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected void UnknownAttribute (object o, XmlAttribute attr)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected void UnknownElement (object o, XmlElement elem)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected void UnknownNode (object o)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO ("Implement")]
+		protected void UnreferencedObject (string id, object o)
+		{
+			throw new NotImplementedException ();
+		}
+
+		#endregion // Methods
+
+		protected class CollectionFixup {
+			
+			#region Fields
+
+			XmlSerializationCollectionFixupCallback callback;
+			object collection;
+			object collectionItems;
+
+			#endregion // Fields
+
+			#region Constructors
+
+			[MonoTODO]
+			public CollectionFixup (object collection, XmlSerializationCollectionFixupCallback callback, object collectionItems)
+			{
+				this.callback = callback;
+				this.collection = collection;
+				this.collectionItems = collectionItems;
+			}
+
+			#endregion // Constructors
+
+			#region Properties
+
+			public XmlSerializationCollectionFixupCallback Callback { 
+				get { return callback; }
+			}
+
+			public object Collection {
+				get { return collection; }
+			}
+
+			public object CollectionItems {
+				get { return collectionItems; }
+			}
+
+			#endregion // Properties
+		}
+
+		protected class Fixup {
+
+			#region Fields
+
+			object source;
+			string[] ids;
+			XmlSerializationFixupCallback callback;
+
+			#endregion // Fields
+
+			#region Constructors
+
+			[MonoTODO]
+			public Fixup (object o, XmlSerializationFixupCallback callback, int count) 
+			{
+				this.callback = callback;
+			}
+
+			[MonoTODO]
+			public Fixup (object o, XmlSerializationFixupCallback callback, string[] ids)
+			{
+				this.callback = callback;
+			}
+
+			#endregion // Constructors
+
+			#region Properties
+
+			public XmlSerializationFixupCallback Callback {
+				get { return callback; }
+			}
+
+			public string[] Ids {
+				get { return ids; }
+			}
+
+			public object Source {
+				get { return source; }
+				set { source = value; }
+			}
+
+			#endregion // Properties
+		}
+	}
+}
+

+ 17 - 0
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriteCallback.cs

@@ -0,0 +1,17 @@
+//
+// System.Xml.Serialization.XmlSerializationWriteCallback.cs: 
+//
+// Author:
+//   Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+
+namespace System.Xml.Serialization {
+	
+	[Serializable]
+	public delegate object XmlSerializationWriteCallback (object o);
+}
+