2004-03-10 Joerg Rosenkranz <JoergR@voelcker.com>
[mono.git] / mcs / class / Microsoft.VisualBasic / Microsoft.VisualBasic / Information.cs
index 165fbad52e0d856ec4668258ea7091f39f9c6608..fa638fa3f8899ad243dafe08bf281008b26e2ff0 100644 (file)
@@ -3,8 +3,12 @@
 //
 // 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;
@@ -18,7 +22,9 @@ namespace Microsoft.VisualBasic
                // Properties
                // Methods
                [MonoTODO]
-               public static Microsoft.VisualBasic.ErrObject Err () { throw new NotImplementedException (); }
+               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 (); }
@@ -28,14 +34,36 @@ namespace Microsoft.VisualBasic
                public static System.Boolean IsDate (System.Object Expression) { throw new NotImplementedException (); }
                [MonoTODO]
                public static System.Boolean IsDBNull (System.Object Expression) { throw new NotImplementedException (); }
-               [MonoTODO]
-               public static System.Boolean IsNothing (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 (); }
-               [MonoTODO]
-               public static System.Boolean IsNumeric (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]