Added Mono namespace block
authorDuncan Mak <duncan@mono-cvs.ximian.com>
Sun, 3 Feb 2002 14:32:27 +0000 (14:32 -0000)
committerDuncan Mak <duncan@mono-cvs.ximian.com>
Sun, 3 Feb 2002 14:32:27 +0000 (14:32 -0000)
svn path=/trunk/mcs/; revision=2233

mcs/tools/ChangeLog
mcs/tools/serialize.cs

index d490f3cd2d759d2745af66151edbf5a8aa342216..51724baf3167a6ac1506eaa11a4a70e788b0fde6 100644 (file)
@@ -1,3 +1,7 @@
+2002-02-03  Duncan Mak  <duncan@ximian.com>\r
+\r
+       * serialize.cs: Added namespace block.\r
+\r
 2002-2-1  Duncan Mak  <duncan@localhost.localdomain>\r
 \r
        * serialize.cs: Added a new tool for serializing objects. It\r
index 95632573bf48321e31a8448c76fa1a47b8dd3630..169af5187063a70a6d411587dc4115290ddc4e01 100755 (executable)
@@ -1,4 +1,4 @@
-a//
+//
 // Serialize.cs
 //
 // This program creates a SerializationInfo and requests an object
@@ -20,120 +20,120 @@ using System.Runtime.Serialization;
 using System.Runtime.Serialization.Formatters.Soap;
 using System.IO;
 
-class Driver {
-        static object StaticCreateObject ()
-        {
-                //
-                // Change the object type here.
-                //
-                return null;
-        }
-
-       static object LiveCreateObject (Type obj, Type[] types, string[] values)
-       {
-               if (types.Length != values.Length)
-                       throw new ArgumentException ();
-
-               object[] a = new object [types.Length];
-               
-               for (int i = 0; i < a.Length; i++)
-                       a [i] = Convert.ChangeType (values [i], types [i]);
+namespace Mono.Serialize {
+       class Driver {
+               static object StaticCreateObject ()
+               {
+                       //
+                       // Change the object type here.
+                       //
+                       return null;
+               }
 
-               return Activator.CreateInstance (obj, a);
-       }
+               static object LiveCreateObject (Type obj, Type[] types, string[] values)
+               {
+                       if (types.Length != values.Length)
+                               throw new ArgumentException ();
+                       
+                       object[] a = new object [types.Length];
+                       
+                       for (int i = 0; i < a.Length; i++)
+                               a [i] = Convert.ChangeType (values [i], types [i]);
+                       
+                       return Activator.CreateInstance (obj, a);
+               }
         
-        static void Main (string[] args)
-        {
-               object x = null;
-               string strTypes = null;
-               string argValues = null;
-               
-               if (args.Length == 1) {
-                       Type t = Type.GetType (args[0]);
-                       Console.WriteLine ("\nPlease enter the arguments to the constructor for type {0}", t.ToString());
-                       strTypes = Console.ReadLine ();
-                       Console.WriteLine ("\nPlease enter the values");
-                       argValues = Console.ReadLine ();
-                       Type[] types = ToTypeArray (strTypes.Split (','));
-                       string[] param = argValues.Split (',');
+               static void Main (string[] args)
+               {
+                       object x = null;
+                       string strTypes = null;
+                       string argValues = null;
+                       
+                       if (args.Length == 1) {
+                               Type t = Type.GetType (args[0]);
+                               Console.WriteLine ("\nPlease enter the arguments to the constructor for type {0}", t.ToString());
+                               strTypes = Console.ReadLine ();
+                               Console.WriteLine ("\nPlease enter the values");
+                               argValues = Console.ReadLine ();
+                               Type[] types = ToTypeArray (strTypes.Split (','));
+                               string[] param = argValues.Split (',');
+                               
+                               x = LiveCreateObject (t, types, param);
+                       } else {
+                               x = StaticCreateObject ();
+                       }
+                       
+                       string fileName = x.GetType().FullName + ".xml";
+                       Stream output = new FileStream (fileName, FileMode.Create,
+                                                       FileAccess.Write, FileShare.None);
+                       IFormatter formatter = new SoapFormatter ();
                        
-                       x = LiveCreateObject (t, types, param);
-               } else {
-                       x = StaticCreateObject ();
+                       formatter.Serialize ((Stream) output, x);
+                       output.Close ();
                }
-
-               string fileName = x.GetType().FullName + ".xml";
-               Stream output = new FileStream (fileName, FileMode.Create,
-FileAccess.Write, FileShare.None);
-                IFormatter formatter = new SoapFormatter ();
-
-                formatter.Serialize ((Stream) output, x);
-                output.Close ();
-        }
-
-       public static Type[] ToTypeArray (string[] strTypes)
-       {
-               Type[] t = new Type [strTypes.Length];
                
-               for (int i = 0; i < strTypes.Length; i++)
-                       t [i] = StringToType (strTypes [i]);
-               return t;
-       }
-
-       public static Type StringToType (string s)
-       {
-               switch (s)
+               public static Type[] ToTypeArray (string[] strTypes)
                {
-               case "bool":
-                       return Type.GetType ("System.Boolean");
-                       break;
-               case "byte":
-                       return Type.GetType ("System.Byte");
-                       break;
-               case "sbyte":
-                       return Type.GetType ("System.SByte");
-                       break;
-               case "char":
-                       return Type.GetType ("System.Char");
-                       break;
-               case "decimal":
-                       return Type.GetType ("System.Decimal");
-                       break;
-               case "double":
-                       return Type.GetType ("System.Double");
-                       break;
-               case "float":
-                       return Type.GetType ("System.Float");
-                       break;
-               case "int":
-                       return Type.GetType ("System.Int32");
-                       break;
-               case "uint":
-                       return Type.GetType ("System.UInt32");
-                       break;
-               case "long":
-                       return Type.GetType ("System.Int64");
-                       break;
-               case "ulong":
-                       return Type.GetType ("System.UInt64");
-                       break;
-               case "object":
-                       return Type.GetType ("System.Object");
-                       break;
-               case "short":
-                       return Type.GetType ("System.Int16");
-                       break;
-               case "ushort":
-                       return Type.GetType ("System.UInt16");
-                       break;
-               case "string":
-                       return Type.GetType ("System.String");
-                       break;
-               default:
-                       return Type.GetType (s);
-                       break;
+                       Type[] t = new Type [strTypes.Length];
+                       
+                       for (int i = 0; i < strTypes.Length; i++)
+                               t [i] = StringToType (strTypes [i]);
+                       return t;
+               }
                
+               public static Type StringToType (string s)
+               {
+                       switch (s)
+                       {
+                       case "bool":
+                               return Type.GetType ("System.Boolean");
+                               break;
+                       case "byte":
+                               return Type.GetType ("System.Byte");
+                               break;
+                       case "sbyte":
+                               return Type.GetType ("System.SByte");
+                               break;
+                       case "char":
+                               return Type.GetType ("System.Char");
+                               break;
+                       case "decimal":
+                               return Type.GetType ("System.Decimal");
+                               break;
+                       case "double":
+                               return Type.GetType ("System.Double");
+                               break;
+                       case "float":
+                               return Type.GetType ("System.Float");
+                               break;
+                       case "int":
+                               return Type.GetType ("System.Int32");
+                               break;
+                       case "uint":
+                               return Type.GetType ("System.UInt32");
+                               break;
+                       case "long":
+                               return Type.GetType ("System.Int64");
+                               break;
+                       case "ulong":
+                               return Type.GetType ("System.UInt64");
+                               break;
+                       case "object":
+                               return Type.GetType ("System.Object");
+                               break;
+                       case "short":
+                               return Type.GetType ("System.Int16");
+                               break;
+                       case "ushort":
+                               return Type.GetType ("System.UInt16");
+                               break;
+                       case "string":
+                               return Type.GetType ("System.String");
+                               break;
+                       default:
+                               return Type.GetType (s);
+                               break;
+                       }
                }
        }
 }
-