2004-03-10 Joerg Rosenkranz <JoergR@voelcker.com>
[mono.git] / mcs / class / Microsoft.VisualBasic / Microsoft.VisualBasic / Information.cs
index 1d34f63452c21cc47412e8ef21e7adac267cccc7..fa638fa3f8899ad243dafe08bf281008b26e2ff0 100644 (file)
@@ -1,37 +1,85 @@
-//\r
-// Information.cs\r
-//\r
-// Author:\r
-//   Chris J Breisch (cjbreisch@altavista.net)\r
-//\r
-// (C) 2002 Chris J Breisch\r
-//\r
-namespace Microsoft.VisualBasic {\r
-       [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] \r
-       [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Auto)] \r
-       sealed public class Information {\r
-               // Declarations\r
-               // Constructors\r
-               // Properties\r
-               // Methods\r
-               public static Microsoft.VisualBasic.ErrObject Err () { return null;}\r
-               [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] \r
-               public static System.Int32 Erl () { return 0;}\r
-               public static System.Boolean IsArray (System.Object VarName) { return false;}\r
-               public static System.Boolean IsDate (System.Object Expression) { return false;}\r
-               public static System.Boolean IsDBNull (System.Object Expression) { return false;}\r
-               public static System.Boolean IsNothing (System.Object Expression) { return false;}\r
-               public static System.Boolean IsError (System.Object Expression) { return false;}\r
-               public static System.Boolean IsReference (System.Object Expression) { return false;}\r
-               public static System.Boolean IsNumeric (System.Object Expression) { return false;}\r
-               public static System.Int32 LBound (System.Array Array, [System.Runtime.InteropServices.Optional] [System.ComponentModel.DefaultValue(1)] System.Int32 Rank) { return 0;}\r
-               public static System.Int32 UBound (System.Array Array, [System.Runtime.InteropServices.Optional] [System.ComponentModel.DefaultValue(1)] System.Int32 Rank) { return 0;}\r
-               public static System.String TypeName (System.Object VarName) { return "";}\r
-               public static System.String SystemTypeName (System.String VbName) { return "";}\r
-               public static System.String VbTypeName (System.String UrtName) { return "";}\r
-               public static System.Int32 QBColor (System.Int32 Color) { return 0;}\r
-               public static System.Int32 RGB (System.Int32 Red, System.Int32 Green, System.Int32 Blue) { return 0;}\r
-               public static Microsoft.VisualBasic.VariantType VarType (System.Object VarName) { return 0;}\r
-               // Events\r
-       };\r
-}\r
+//
+// Information.cs
+//
+// Author:
+//   Chris J Breisch (cjbreisch@altavista.net) 
+//   Francesco Delfino (pluto@tipic.com)
+//   Rafael Teixeira (rafaelteixeirabr@hotmail.com)
+//
+// (C) 2002 Chris J Breisch
+//     2003 Tipic, Inc. (http://www.tipic.com)
+//     2004 Rafael Teixeira
+//
+
+using System;
+
+namespace Microsoft.VisualBasic \r
+{
+       [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
+       sealed public class Information {
+               // Declarations
+               // Constructors
+               // Properties
+               // Methods
+               [MonoTODO]
+               public static Microsoft.VisualBasic.ErrObject Err () { 
+                       return Microsoft.VisualBasic.CompilerServices.ProjectData.Err;
+               }
+               [MonoTODO]
+               [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
+               public static System.Int32 Erl () { throw new NotImplementedException (); }
+               [MonoTODO]
+               public static System.Boolean IsArray (System.Object VarName) { throw new NotImplementedException (); }
+               [MonoTODO]
+               public static System.Boolean IsDate (System.Object Expression) { throw new NotImplementedException (); }
+               [MonoTODO]
+               public static System.Boolean IsDBNull (System.Object Expression) { throw new NotImplementedException (); }
+
+               public static System.Boolean IsNothing (System.Object Expression) { 
+                       return (Expression == null);
+               }
+
+               [MonoTODO]
+               public static System.Boolean IsError (System.Object Expression) { throw new NotImplementedException (); }
+               [MonoTODO]
+               public static System.Boolean IsReference (System.Object Expression) { throw new NotImplementedException (); }
+
+               public static System.Boolean IsNumeric (System.Object Expression) 
+               { 
+                       if (Expression == null || Expression is DateTime)
+                               return false;
+
+                       if (Expression is Int16 || Expression is Int32 || Expression is Int64 || Expression is Decimal ||
+                               Expression is Single || Expression is Double)
+                               return true;
+
+                       try {
+                               if (Expression is string)
+                                       Double.Parse(Expression as string);
+                               else
+                                       Double.Parse(Expression.ToString());
+                               return true;
+                       } catch {} // just dismiss errors but return false
+
+                       return false;
+               }
+
+               [MonoTODO]
+               public static System.Int32 LBound (System.Array Array, [System.Runtime.InteropServices.Optional] [System.ComponentModel.DefaultValue(1)] System.Int32 Rank) { throw new NotImplementedException (); }
+               [MonoTODO]
+               public static System.Int32 UBound (System.Array Array, [System.Runtime.InteropServices.Optional] [System.ComponentModel.DefaultValue(1)] System.Int32 Rank) { throw new NotImplementedException (); }
+               [MonoTODO]
+               public static System.String TypeName (System.Object VarName) { throw new NotImplementedException (); }
+               [MonoTODO]
+               public static System.String SystemTypeName (System.String VbName) { throw new NotImplementedException (); }
+               [MonoTODO]
+               public static System.String VbTypeName (System.String UrtName) { throw new NotImplementedException (); }
+               [MonoTODO]
+               public static System.Int32 QBColor (System.Int32 Color) { throw new NotImplementedException (); }
+               [MonoTODO]
+               public static System.Int32 RGB (System.Int32 Red, System.Int32 Green, System.Int32 Blue) { throw new NotImplementedException (); }
+               [MonoTODO]
+               public static Microsoft.VisualBasic.VariantType VarType (System.Object VarName) { throw new NotImplementedException (); }
+               // Events
+       };
+}