Complete. Includes code from both Mono and Mainsoft.
authorDennis Hayes <dennis@mono-cvs.ximian.com>
Mon, 5 Apr 2004 07:10:24 +0000 (07:10 -0000)
committerDennis Hayes <dennis@mono-cvs.ximian.com>
Mon, 5 Apr 2004 07:10:24 +0000 (07:10 -0000)
* BooleanType.cs
* CharArrayType.cs
* CharType.cs
* IncompleteInitialization.cs
* LongType.cs
* OptionCompareAttribute.cs
* OptionTextAttribute.cs
* ShortType.cs
* DateType.cs

Close. Unconverted java code from Mainsoft in comments included inthe code.
* IntegerType.cs
* ByteType.cs
* DecmialType.cs
* SingleType.cs
* DoubleType.cs

Work in progress
* ExceptionUtils.cs

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

16 files changed:
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/BooleanType.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/ByteType.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/ChangeLog
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/CharArrayType.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/CharType.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/DateType.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/DecimalType.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/DoubleType.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/ExceptionUtils.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/IncompleteInitialization.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/IntegerType.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/LongType.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/OptionCompareAttribute.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/OptionTextAttribute.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/ShortType.cs
mcs/class/Microsoft.VisualBasic/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/SingleType.cs

index 41e28fcaf3e64b8e49e634470383c0ef4bc53e14..909e4f9b393b3fdcfa0bdfa6dadce16b5790b83a 100644 (file)
@@ -1,12 +1,12 @@
 //
 // BooleanType.cs
 //
-//     Author:
-//     Chris J Breisch (cjbreisch@altavista.net) 
-//     Dennis Hayes    (dennish@raytek.com)
+//      Author:
+//      Chris J Breisch (cjbreisch@altavista.net) 
+//      Dennis Hayes        (dennish@raytek.com)
 //
-//     (C) 2002 Chris J Breisch
-//     (C) 2004 Novell
+//      (C) 2002 Chris J Breisch
+//      (C) 2004 Novell
 //
  /*
   * Copyright (c) 2002-2003 Mainsoft Corporation.
 using System;
 using System.Globalization;
 
-namespace Microsoft.VisualBasic.CompilerServices {
+namespace Microsoft.VisualBasic.CompilerServices
+{
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
        [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
        sealed public class BooleanType {
                /**
-                * The method converts given object to boolean by the following logic:
-                * 1. If input object is null - return null
-                * 2. If input object is String - run FromString method
-                * 3. Otherwise run .NET default conversion - Convert.ToBoolean
-                * @param value - The object that going to be converted
-                * @return boolean The boolean value that converted from the source object
-                */
-               public static System.Boolean FromObject (System.Object Value) {
-                       if ((object)Value == null) return false;
-                       if (Value is string)return FromString((string)Value);
-                       return System.Convert.ToBoolean(Value);
+                                * The method converts given object to boolean by the following logic:
+                                * 1. If input object is null - return null
+                                * 2. If input object is String - run FromString method
+                                * 3. Otherwise run .NET default conversion - Convert.ToBoolean
+                                * @param value - The object that going to be converted
+                                * @return boolean The boolean value that converted from the source object
+                                */
+               public static System.Boolean FromObject (object Value) {
+                       if (Value == null)
+                               return false;
+
+                       if (Value is string)
+                               return FromString((string)Value);
+
+                       //This throws the correct execption, Mainsoft java code has to catch and rethrow to map java to .net
+                       return Convert.ToBoolean(Value);
                }
+
                /**
-                * The method try to convert given string to boolean in a following way:
-                * 1. If input value is True or False string - return corresponding value
-                * 2. If input string represents number: return true if this number is not 
-                *    equals to zero, otherwise return false;
-                * @exception InvalidCastException - in case if number translation failed 
-                *  due to NumberFormatException.
-                * @exception All other thrown exceptions from ClrDobule.Parse 
-                * @param str - The string that converted to boolean
-                * @return boolean The value that extracted from the input string. 
-                */
-               public static System.Boolean FromString (System.String Value) {
+                                * The method try to convert given string to boolean in a following way:
+                                * 1. If input value is True or False string - return corresponding value
+                                * 2. If input string represents number: return true if this number is not 
+                                *    equals to zero, otherwise return false;
+                                * @exception InvalidCastException - in case if number translation failed 
+                                *  due to NumberFormatException.
+                                * @exception All other thrown exceptions from ClrDobule.Parse 
+                                * @param str - The string that converted to boolean
+                                * @return boolean The value that extracted from the input string. 
+                                */
+               public static Boolean FromString (string Value) {
+                       if(Value == null)
+                               return false;
+
                        if (string.Compare(Value, bool.TrueString, true) == 0)
                                return true;
-                        
                        if (string.Compare(Value, bool.FalseString, true) == 0)
                                return false;
                         
@@ -75,7 +84,6 @@ namespace Microsoft.VisualBasic.CompilerServices {
                                string.Format (
                                "Cast from string \"{0}\" to type 'Boolean' is not valid.",
                                Value));
-               }       
+               }        
        }
 }
-
index d3686570a2a3e919a7b47913c6253c23069f6976..6cd64e2bd846aa8e72516a66d52d681efa831bbd 100644 (file)
@@ -1,84 +1,98 @@
-//
-// ByteType.cs
-//
-//     Author:
-//     Chris J Breisch (cjbreisch@altavista.net) 
-//     Francesco Delfino (pluto@tipic.com)
-//     Dennis Hayes (dennish@raytek.com)
-//
-//     (C) copyright 2002 Chris J Breisch
-//     2002 Tipic, Inc (http://www.tipic.com)
-//     2004 Novell
-//
- /*
-  * Copyright (c) 2002-2003 Mainsoft Corporation.
-  *
-  * Permission is hereby granted, free of charge, to any person obtaining a
-  * copy of this software and associated documentation files (the "Software"),
-  * to deal in the Software without restriction, including without limitation
-  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-  * and/or sell copies of the Software, and to permit persons to whom the
-  * Software is furnished to do so, subject to the following conditions:
-  * 
-  * The above copyright notice and this permission notice shall be included in
-  * all copies or substantial portions of the Software.
-  * 
-  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-  * DEALINGS IN THE SOFTWARE.
-  */
+    //
+    // ByteType.cs
+    //
+    // Author:
+    // Chris J Breisch (cjbreisch@altavista.net) 
+    // Francesco Delfino (pluto@tipic.com)
+    // Dennis Hayes (dennish@raytek.com)
+    //
+    // (C) copyright 2002 Chris J Breisch
+    // 2002 Tipic, Inc (http://www.tipic.com)
+    // 2004 Novell
+    //
+     /*
+      * Copyright (c) 2002-2003 Mainsoft Corporation.
+      *
+      * Permission is hereby granted, free of charge, to any person obtaining a
+      * copy of this software and associated documentation files (the "Software"),
+      * to deal in the Software without restriction, including without limitation
+      * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+      * and/or sell copies of the Software, and to permit persons to whom the
+      * Software is furnished to do so, subject to the following conditions:
+      * 
+      * The above copyright notice and this permission notice shall be included in
+      * all copies or substantial portions of the Software.
+      * 
+      * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+      * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+      * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+      * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+      * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+      * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+      * DEALINGS IN THE SOFTWARE.
+      */
+    /**
+     * Class that converts objects to Byte value.
+     */
 using System;
-/**
- * Class that converts objects to Byte value.
- */
-namespace Microsoft.VisualBasic.CompilerServices {
+namespace Microsoft.VisualBasic.CompilerServices 
+{
        [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
        sealed public class ByteType {
-
-    /**
-     * The method converts given object to byte by the following logic:
-     * 1. If input object is null - return 0
-     * 2. If input object is String - run FromString method
-     * 3. Otherwise run .NET default conversion - Convert.ToByte
-     * @param value - The object that going to be converted
-     * @return byte The byte value that converted from the source object
-     * @see system.Convert#ToByte
-     */
-               public static System.Byte FromObject (System.Object Value) { 
+    
+               /**
+                * The method converts given object to byte by the following logic:
+                * 1. If input object is null - return 0
+                * 2. If input object is String - run FromString method
+                * 3. Otherwise run .NET default conversion - Convert.ToByte
+                * @param value - The object that going to be converted
+                * @return byte The byte value that converted from the source object
+                * @see system.Convert#ToByte
+                */
+               public static System.Byte FromObject (object Value) { 
                        if ((object)Value==null)
                                return 0;
+
                        if      (Value is string)
                                return FromString((string) Value);
-                       if      (Value is int)
-                               return ((System.Byte)Value);
-                        
-                       return System.Convert.ToByte(Value);
-               }
 
+                       return Convert.ToByte(Value);//Throws correct execption. Execption not converted from .java code.
+               }
+    
                // Methods
                /**
-                * The method try to convert given string to byte in a following way:
-                * 1. If input string is null return 0.
-                * 2. If input string represents number: return value of this number, 
-                * @exception InvalidCastException - in case if number translation failed 
-                * @param str - The string that converted to int
-                * @return int The value that extracted from the input string.
-                * @see Microsoft.VisualBasic.VBUtils#isNumber
-                */ 
-               public static System.Byte FromString (System.String Value) {
+                        * The method try to convert given string to byte in a following way:
+                        * 1. If input string is null return 0.
+                        * 2. If input string represents number: return value of this number, 
+                        * @exception InvalidCastException - in case if number translation failed 
+                        * @param str - The string that converted to int
+                        * @return int The value that extracted from the input string.
+                        * @see Microsoft.VisualBasic.VBUtils#isNumber
+                        */ 
+               public static System.Byte FromString (string Value) {
                        if(Value == null)return 0;
-
-                       double[] lRes = new double[1];
-                       
-                       return System.Byte.Parse(Value);
-                       //TODO:
-
-                       // converet the following, then remove the above line
+    
+                       int Base = 10;
+                       int start = 0;
+                       if(Value.Substring(0,1) == "&"){
+                               //is diff base
+                               if(Value.Substring(1,1).ToUpper() == "H")
+                                       Base = 16;
+                               else if(Value.Substring(1,1).ToUpper() == "B")
+                                       Base = 8;
+                               else {
+                                       // I think we should just let convert take care of the execption.
+                                       // Should we throw a special execption instead?
+                                       // I think the Mainsoft java code below just converts execptions from java to C#
+                               }
+                               start = 2;
+                       }
+                       return Convert.ToByte(Value.Substring(start,Value.Length - start), Base);
+  
+                       // Mainsoft java implmentation.
+                       // isNumber checks for leading &H or &O
+                       // leave for documentation.
                        //
                        //            if (VBUtils.isNumber(str, lRes))
                        //            {
@@ -95,8 +109,6 @@ namespace Microsoft.VisualBasic.CompilerServices {
                        //                Utils.GetResourceString("InvalidCast_FromStringTo", 
                        //                    str, "Byte"), e);
                        //        }
-                       // return 0;
                }
-
        };
 }
index 99414c43276193611563ea50b7b51adf05bde444..698287a2c1c7cc9223aa2aca9750aab049927ce5 100644 (file)
@@ -1,27 +1,49 @@
-2004-03-31  Rafael Teixeira <rafaelteixeirabr@hotmail.com>
-       * BooleanType.cs, ByteType.cs, CharArrayType.cs, CharType.cs, DateType.cs, IntegerType.cs, LongType.cs, ShortType.cs:
-               Translated Mainsoft code by Dennis Hayes with additional revisions by me - formatting still a problem
-               Testing: No regressions, One advance
-
-2004-02-20  Rafael Teixeira <rafaelteixeirabr@hotmail.com>
-       * Utils.cs: 
-               Spacing corrections
-
-2004-03-27  Duncan Mak  <duncan@ximian.com>
-       * Utils.cs (GetResourceString): Added stub for easing the port
-       from the Mainsoft Java implementation.
-
-2004-03-10     Joerg Rosenkranz <JoergR@voelcker.com>
-       * BooleanType.cs:
-               Corrected implementation of method FromString. 
-               This fixes bug #55414.
-
-2004-02-20  Rafael Teixeira <rafaelteixeirabr@hotmail.com>
-       * OptionCompareAttribute.cs:
-               Corrected constructor of attribute (bug #52570)
-       * OptionTextAttribute.cs, StandardModuleAttribute.cs:
-               Cosmetic changes
-
-2004-01-22  Rafael Teixeira <rafaelteixeirabr@hotmail.com>
-       * Utils.cs:
-               First Try Implementation for CopyArray(): NET_1_1-aware
+2004-04-04     Dennis Hayes <dennish@raytek.com>\r
+       Complete. Includes code from both Mono and Mainsoft.\r
+       * BooleanType.cs\r
+       * CharArrayType.cs\r
+       * CharType.cs\r
+       * IncompleteInitialization.cs\r
+       * LongType.cs\r
+       * OptionCompareAttribute.cs\r
+       * OptionTextAttribute.cs\r
+       * ShortType.cs\r
+       * DateType.cs\r
+\r
+       Close. Unconverted java code from Mainsoft in comments included in the code.\r
+       * IntegerType.cs\r
+       * ByteType.cs\r
+       * DecmialType.cs\r
+       * SingleType.cs\r
+       * DoubleType.cs\r
+\r
+       Work in progress\r
+       * ExceptionUtils.cs\r
+\r
+2004-03-31  Rafael Teixeira <rafaelteixeirabr@hotmail.com>\r
+       * BooleanType.cs, ByteType.cs, CharArrayType.cs, CharType.cs, DateType.cs, IntegerType.cs, LongType.cs, ShortType.cs:\r
+               Translated Mainsoft code by Dennis Hayes with additional revisions by me - formatting still a problem\r
+               Testing: No regressions, One advance\r
+\r
+2004-02-20  Rafael Teixeira <rafaelteixeirabr@hotmail.com>\r
+       * Utils.cs: \r
+               Spacing corrections\r
+\r
+2004-03-27  Duncan Mak  <duncan@ximian.com>\r
+       * Utils.cs (GetResourceString): Added stub for easing the port\r
+       from the Mainsoft Java implementation.\r
+\r
+2004-03-10     Joerg Rosenkranz <JoergR@voelcker.com>\r
+       * BooleanType.cs:\r
+               Corrected implementation of method FromString. \r
+               This fixes bug #55414.\r
+\r
+2004-02-20  Rafael Teixeira <rafaelteixeirabr@hotmail.com>\r
+       * OptionCompareAttribute.cs:\r
+               Corrected constructor of attribute (bug #52570)\r
+       * OptionTextAttribute.cs, StandardModuleAttribute.cs:\r
+               Cosmetic changes\r
+\r
+2004-01-22  Rafael Teixeira <rafaelteixeirabr@hotmail.com>\r
+       * Utils.cs:\r
+               First Try Implementation for CopyArray(): NET_1_1-aware\r
index 516a50873f249c0d16b9d21d1ccf4ee57ce793ff..69c3b871b06cf9270edd7831a6e15acb8b76355b 100644 (file)
@@ -1,12 +1,12 @@
 //
 // CharArrayType.cs
 //
-//     Author:
-//     Chris J Breisch (cjbreisch@altavista.net) 
-//     Dennis Hayes (dennish@raytek.com)
+//      Author:
+//      Chris J Breisch (cjbreisch@altavista.net) 
+//      Dennis Hayes (dennish@raytek.com)
 //
-//     (C) 2002 Chris J Breisch
-//     (c) 2004 Novell
+//      (C) 2002 Chris J Breisch
+//      (c) 2004 Novell
 //
  /*
   * Copyright (c) 2002-2003 Mainsoft Corporation.
   */
 using System;
 
-namespace Microsoft.VisualBasic.CompilerServices {
+namespace Microsoft.VisualBasic.CompilerServices
+{
        [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
        sealed public class CharArrayType {
                /**
-                * The method converts given object to char[] by the following logic:
-                * 1. If input object is null - return empty char array
-                * 2. If input object is char array - return this object
-                * 3. If input object is String - return char array representing this String
-                * @param value - The object that going to be converted
-                * @return char[] The char array that converted from the source object
-                * @exception InvalidCastException - in case if value is not String or char[].
-                */
-               public static char[] FromObject(Object Value) {
+                                * The method converts given object to char[] by the following logic:
+                                * 1. If input object is null - return empty char array
+                                * 2. If input object is char array - return this object
+                                * 3. If input object is String - return char array representing this String
+                                * @param value - The object that going to be converted
+                                * @return char[] The char array that converted from the source object
+                                * @exception InvalidCastException - in case if value is not String or char[].
+                                */
+               public static char[] FromObject(object Value) {
                        if (Value == null)
                                return new char[]{};
+
                        if (Value is char[])
                                return (char[])Value;
+
                        if (Value is string) 
-                               return FromString((String)Value);// could be replaced with Value.ToCharArray();, but spec says make the call.
+                               return FromString((string)Value);// could be replaced with Value.ToCharArray();, but spec says make the call.
+
                        throw new InvalidCastException("InvalidCast_From " + Value.GetType().Name + " To char");
                }
 
                /**
-                * The method converts given string to byte of chars:
-                * @param str - The string that converted to char array
-                * @return char[] The value that extracted from the input string.
-                */
+               * The method converts given string to byte of chars:
+               * @param str - The string that converted to char array
+               * @return char[] The value that extracted from the input string.
+               */
                public static char[] FromString(string Value) {
                        if (Value == null)return new char[]{};
                        return Value.ToCharArray();
                }
        }
 }
+
+
index f548ef4ed3a047fcea41feb47511d827d7d700fb..a31c3338bb31feb3b1e5b884ac8d7f4ea3b96133 100644 (file)
@@ -31,7 +31,8 @@
 
 using System;
 
-namespace Microsoft.VisualBasic.CompilerServices {
+namespace Microsoft.VisualBasic.CompilerServices
+{
        [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
        sealed public class CharType {
@@ -44,11 +45,13 @@ namespace Microsoft.VisualBasic.CompilerServices {
                   * @return char The char value that converted from the source object
                   * @see system.Convert#ToChar
                   */
-               public static char FromObject(Object Value) {
+               public static char FromObject(object Value) {
                        if (Value == null)
                                return '\0';
+
                        if (Value is string)
                                return FromString((string)Value);
+
                        //Mainsoft code creates a new execption, but that is just to convert from java execption to .net execption
                        return Convert.ToChar(Value);
                }
@@ -60,7 +63,9 @@ namespace Microsoft.VisualBasic.CompilerServices {
                   * @return char The value that extracted from the input string.
                   */
                public static char FromString(string Value) {
-                       if (Value == null || Value.Length == 0)return '\0';
+                       if (Value == null || Value.Length == 0)
+                               return '\0';
+
                        return Value.ToCharArray()[0];
                }
        }
index b6ff96f6227934c785cc3ea6985350a52028ed9b..1057fa4796c51f32a12dcdbd4a956732e6483e3b 100644 (file)
   * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   * DEALINGS IN THE SOFTWARE.
   */
-
-using System;
-using System.Globalization;
-
 /**
  * Class that converts objects to DateTime object
  */
+using System;
 namespace Microsoft.VisualBasic.CompilerServices {
        [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
@@ -55,13 +52,13 @@ namespace Microsoft.VisualBasic.CompilerServices {
                  * @return DateTime The DateTime value that converted from the source object
                  * @see system.Convert#ToDateTime
                  */
-               public static System.DateTime FromObject (System.Object Value) { 
-                       if ((object)Value == null)
-                               return new DateTime();  //Mainsoft code was wrong, struct are value types and can't be null
-                       if (Value is string) 
-                               return FromString((string)Value);
-                       if(Value is DateTime)
-                               return (DateTime)Value;
+               public static DateTime FromObject (object Value) { 
+                       //if (Value == null)return null;//per Mainsoft code.
+                       if (Value == null)return DateTime.MinValue; //Can't return null for datetime type
+
+                       if (Value is string) return FromString((string)Value);
+
+                       if(Value is DateTime)return (DateTime)Value;
                        throw new InvalidCastException("InvalidCast_From " + Value.GetType().Name + " ToDate");
                }
 
@@ -70,7 +67,7 @@ namespace Microsoft.VisualBasic.CompilerServices {
                 * @param value The value to convert.
                 * @return DateTime The value that extracted from the input string.
                 */
-               public static System.DateTime FromString (System.String Value) {
+               public static System.DateTime FromString (string Value) {
                        return FromString(Value, System.Globalization.CultureInfo.CurrentCulture);
                }
 
@@ -82,11 +79,15 @@ namespace Microsoft.VisualBasic.CompilerServices {
                 * @param value - The string that converted to DateTime
                 * @return DateTime The value that extracted from the input string.
                 */
-               public static System.DateTime FromString (System.String Value, System.Globalization.CultureInfo culture) { 
+               public static System.DateTime FromString (string Value, System.Globalization.CultureInfo culture) { 
                        string val = Value;
-                       if (Value != null && Value.Length > 2 && Value.StartsWith("#") && Value.EndsWith("#"))
-                           val = Value.Substring(1, Value.Length - 2);
-                       return DateTime.Parse(val, culture, DateTimeStyles.AllowWhiteSpaces | DateTimeStyles.NoCurrentDateDefault);
+                       if (Value != null
+                           && Value.Length > 2
+                           && Value.StartsWith("#")
+                           && Value.EndsWith("#"))
+                           val = Value.Substring(1, Value.Length - 1);
+                       // 15 = DateTymeStyles.AllowWhiteSpaces || DateTymeStyles.NoCurrentDateDefault
+                       return DateTime.Parse(val, culture,(System.Globalization.DateTimeStyles)15);
                }
        };
 }
index 670f406f42bd524160f0950bc89e3672efca5206..a167c705006293cafde9a869338a268645b12414 100644 (file)
 //
 // DecimalType.cs
 //
-// Author:
-//   Chris J Breisch (cjbreisch@altavista.net) 
+//     Author:
+//     Chris J Breisch (cjbreisch@altavista.net) 
+//     Dennis Hayes (dennish@raytek.com)
 //
-// (C) 2002 Chris J Breisch
+//     (C) copyright 2002 Chris J Breisch
+//     (C) copyright 2004 Novell
 //
-
+ /*
+  * Copyright (c) 2002-2003 Mainsoft Corporation.
+  *
+  * Permission is hereby granted, free of charge, to any person obtaining a
+  * copy of this software and associated documentation files (the "Software"),
+  * to deal in the Software without restriction, including without limitation
+  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  * and/or sell copies of the Software, and to permit persons to whom the
+  * Software is furnished to do so, subject to the following conditions:
+  * 
+  * The above copyright notice and this permission notice shall be included in
+  * all copies or substantial portions of the Software.
+  * 
+  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  * DEALINGS IN THE SOFTWARE.
+  */
 using System;
+using System.Globalization;
 
-namespace Microsoft.VisualBasic.CompilerServices \r
-{
+namespace Microsoft.VisualBasic.CompilerServices {
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
        [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
        sealed public class DecimalType {
-               // Declarations
-               // Constructors
-               // Properties
                // Methods
-               [MonoTODO]
-               public static System.Decimal FromBoolean (System.Boolean Value) { throw new NotImplementedException (); }
-               public static System.Decimal FromString (System.String Value) { return System.Decimal.Parse(Value); }
-               [MonoTODO]
-               public static System.Decimal FromString (System.String Value, System.Globalization.NumberFormatInfo NumberFormat) { throw new NotImplementedException (); }
-               [MonoTODO]
-               public static System.Decimal FromObject (System.Object Value) { throw new NotImplementedException (); }
-               [MonoTODO]
-               public static System.Decimal FromObject (System.Object Value, System.Globalization.NumberFormatInfo NumberFormat) { throw new NotImplementedException (); }
-               [MonoTODO]
-               public static System.Decimal Parse (System.String Value, System.Globalization.NumberFormatInfo NumberFormat) { throw new NotImplementedException (); }
-               // Events
+               /**
+                * This method converts given boolean to Decimal. true is converted to -1
+                * and false to 0. 
+                * @param value The boolean that going to be converted
+                * @return Decimal The Decimal value that converted from the boolean
+                */
+               public static System.Decimal FromBoolean (System.Boolean Value) {
+                       if (Value)return Decimal.MinusOne;
+                       return Decimal.Zero;
+               }
+
+               public static System.Decimal FromString (System.String Value) {
+                       return FromString(Value, null);
+               }
+
+               public static System.Decimal FromObject (System.Object Value) {
+                       return DecimalType.FromObject(Value, null);
+               }
+               /**
+                * The method try to convert given string to Decimal in a following way:
+                * 1. If input string is null return 0.
+                * 2. If input string represents number: return value of this number, 
+                * @exception OverflowException - if number is out of Decimal range
+                * @exception InvalidCastException - in case if number translation failed 
+                *  due to NumberFormatException.
+                * @exception All other thrown exceptions from Decimal.Parse 
+                * @param str - The string that converted to Decimal
+                * @return Decimal The value that extracted from the input string.
+                * @see Microsoft.VisualBasic.VBUtils#isNumber
+                */
+               public static Decimal FromString(String Value, NumberFormatInfo numberFormat) {
+                       if (Value == null)return Decimal.Zero;
+                       
+                       //TODO: remove this line
+                       return Parse(Value, numberFormat);
+
+                       //TODO convert this to C# and uncomment
+                       //try {
+                       //      double d;
+                       //      long[] lRes = new long[1];
+                       //      Boolean b = StringType.IsHexOrOctValue(str, lRes);
+                       //      if (b == true)return new Decimal(lRes[0]);
+                       //      return Parse(str, numberFormat);
+                       //}
+                       //catch (OverflowException exp) {
+                       //      throw (RuntimeException)ExceptionUtils.VbMakeException(6);
+                       //}
+                       //catch (FormatException exp) {
+                       //      throw new InvalidCastException(
+                       //              Utils.GetResourceString("InvalidCast_FromStringTo", 
+                       //              str, "Decimal"));
+                       //}
+               }
+               /**
+                * The method converts given object to decimal by the following logic:
+                * 1. If input object is null - return 0
+                * 2. If input object is String - run FromString method
+                * 3. Otherwise run .NET default conversion - Convert.ToDecimal
+                * @param value - The object that going to be converted
+                * @return Decimal The Decimal value that converted from the source object
+                * @see system.Convert#ToDecimal
+                */
+               public static System.Decimal FromObject (System.Object Value, System.Globalization.NumberFormatInfo NumberFormat) {
+                       if (Value == null)return Decimal.Zero;
+
+                       if (Value is string)return FromString((string) Value, NumberFormat);
+                       
+                       return Convert.ToDecimal(Value);
+               }
+
+               /**
+                * This method try to parse this string first of all by allowing that the 
+                * string will contain currency symbol. if an error is thrown the a parse
+                * without a currenct is tried.
+                * @param value the string that should be parse to Decimal
+                * @param numberFormat the relevant NumberFormat.  
+                * @return Decimal the Decimal value of the string.
+                */
+               public static System.Decimal Parse (System.String Value, System.Globalization.NumberFormatInfo NumberFormat) {
+                       return Decimal.Parse(Value, NumberStyles.Any, NumberFormat);
+               }
        };
 }
+
index 1d0e2b99fa3bd65b7c14ba7a9a9c3990cbe5952c..23a31ead529ebdd87b445a63e49a6a01733a2409 100644 (file)
-//
-// DoubleType.cs
-//
-// Author:
-//   Chris J Breisch (cjbreisch@altavista.net) 
-//
-// (C) 2002 Chris J Breisch
-//
-
-using System;
-
-namespace Microsoft.VisualBasic.CompilerServices \r
-{
-       [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
-       [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
-       sealed public class DoubleType {
-               // Declarations
-               // Constructors
-               // Properties
-               // Methods
-               public static System.Double FromString (System.String Value) { return System.Double.Parse(Value); }
-               [MonoTODO]
-               public static System.Double FromString (System.String Value, System.Globalization.NumberFormatInfo NumberFormat) { throw new NotImplementedException (); }
-               [MonoTODO]
-               public static System.Double FromObject (System.Object Value) { throw new NotImplementedException (); }
-               [MonoTODO]
-               public static System.Double FromObject (System.Object Value, System.Globalization.NumberFormatInfo NumberFormat) { throw new NotImplementedException (); }
-               public static System.Double Parse (System.String Value) { return System.Double.Parse(Value); }
-               [MonoTODO]
-               public static System.Double Parse (System.String Value, System.Globalization.NumberFormatInfo NumberFormat) { throw new NotImplementedException (); }
-               // Events
-       };
-}
+//\r
+// DoubleType.cs\r
+ /*\r
+  * Copyright (c) 2002-2003 Mainsoft Corporation.\r
+  *\r
+  * Permission is hereby granted, free of charge, to any person obtaining a\r
+  * copy of this software and associated documentation files (the "Software"),\r
+  * to deal in the Software without restriction, including without limitation\r
+  * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+  * and/or sell copies of the Software, and to permit persons to whom the\r
+  * Software is furnished to do so, subject to the following conditions:\r
+  * \r
+  * The above copyright notice and this permission notice shall be included in\r
+  * all copies or substantial portions of the Software.\r
+  * \r
+  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r
+  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\r
+  * DEALINGS IN THE SOFTWARE.\r
+  */\r
+/**\r
+ * Class that converts objects to double value.\r
+ */\r
+using System;\r
+using System.Globalization;\r
+\r
+namespace Microsoft.VisualBasic.CompilerServices\r
+{\r
+       [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] \r
+       [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] \r
+       sealed public class DoubleType {\r
+               /**\r
+                * Converts given string to double\r
+                * @param value string to convert\r
+                * @return double double representation of given string\r
+                */\r
+               public static double FromString(string Value) {\r
+                       return FromString(Value, null);\r
+               }\r
+    \r
+               /**\r
+                * The method try to convert given string to double in a following way:\r
+                * 1. If input string is null return 0.\r
+                * 2. If input string represents number: return value of this number, \r
+                * @exception InvalidCastException - in case if number translation failed \r
+                * @param str - The string that converted to double\r
+                * @return doubleThe value that extracted from the input string.\r
+                * @see Microsoft.VisualBasic.VBUtils#isNumber\r
+                */\r
+               public static double FromString(string Value, NumberFormatInfo numberFormat) {\r
+                       if (Value == null)\r
+                               return 0.0;\r
+\r
+                       //try {\r
+                       //      double[] lRes = new double[1];\r
+                       //if (VBUtils.isNumber(Value, lRes))\r
+                       //      return lRes[0];\r
+                       //}\r
+                       ////catch (java.lang.Exception e) {\r
+                       //      throw new InvalidCastException(\r
+                       //              Utils.GetResourceString("InvalidCast_FromStringTo", \r
+                       //              Value, "Double"), e);\r
+                       //}\r
+                       return 0.0;\r
+               }\r
+\r
+               /**\r
+                * Converts given object to double.\r
+                * @param value value to convert to\r
+                * @return double value converted from given object\r
+                */\r
+               public static double FromObject(object Value) {\r
+                       return FromObject(Value, null);\r
+               }\r
+    \r
+               /**\r
+                * The method converts given object to double by the following logic:\r
+                * 1. If input object is null - return 0\r
+                * 2. If input object is String - run FromString method\r
+                * 3. Otherwise run .NET default conversion - Convert.ToDouble\r
+                * @param value - The object that going to be converted\r
+                * @return double The double value that converted from the source object\r
+                * @see system.Convert#ToDouble\r
+                */\r
+               public static double FromObject(object Value, NumberFormatInfo numberFormat) {\r
+                       if (Value == null)\r
+                               return 0.0;\r
+\r
+                       if (Value is string)\r
+                               return FromString((string) Value, numberFormat);\r
+\r
+                       //try {\r
+                       return Convert.ToDouble(Value, numberFormat);\r
+                       //}\r
+                       //catch(java.lang.Exception e) {\r
+                       //      throw new InvalidCastException(\r
+                       //              Utils.GetResourceString("InvalidCast_FromTo", \r
+                       //              Utils.VBFriendlyName(Value), "Double"));\r
+                       //}\r
+               }\r
+\r
+\r
+               /**\r
+                * Parse given string to double value\r
+                * @param value string to parse\r
+                * @return double resulted value \r
+                */\r
+               public static double Parse(string Value) {\r
+                       return Parse(Value, null);\r
+               }\r
+\r
+               //not needed acccording to spec?\r
+               //public static boolean TryParse(string value, ClrDouble result) {\r
+               //      return ClrDouble.TryParse(Value, NumberStyles.Any, null, result);\r
+               //}\r
+               // the above is below with ClrDouble replaced with double what is a ClrDouble\r
+               //public static bool TryParse(string Value, double result) {\r
+               //      return double.TryParse(Value, NumberStyles.Any, null, result);\r
+               //}\r
+\r
+               /**\r
+                * This method try to parse given string using all available styles, if an \r
+                * error is thrown then it parses without a currency style.\r
+                * @param value string to parse\r
+                * @param numberFormat NumberFormatInfo to use\r
+                * @return double the resulted value\r
+                */\r
+               public static double Parse(string Value, NumberFormatInfo numberFormat) {\r
+                       double d;\r
+\r
+                       try {\r
+                               //                      d = ClrDouble.Parse(Value, NumberStyles.Any, numberFormat);\r
+                               d = double.Parse(Value, NumberStyles.Any, numberFormat);\r
+                       }\r
+                       catch (Exception e) {\r
+                               //                      d = ClrDouble.Parse(Value, 255, numberFormat);\r
+                               d = double.Parse(Value, (NumberStyles)255, numberFormat);\r
+                       }\r
+                       return d;\r
+               }\r
+       }\r
+}\r
index 03442b7382f43917197f48d077daa43edd5a8eea..1d8c39fe96b9dff290eb3f64b4d1f2a41fabec3d 100644 (file)
-//\r
-// ExceptionUtils.cs\r
-//\r
-// Author:\r
-//   Chris J Breisch (cjbreisch@altavista.net)\r
-//\r
-// (C) 2002 Chris J Breisch\r
-//\r
-namespace Microsoft.VisualBasic.CompilerServices {\r
-       [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] \r
-       [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] \r
-       [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Auto)] \r
-       sealed public class ExceptionUtils {\r
-               // Declarations\r
-               // Constructors\r
-               // Properties\r
-               // Methods\r
-               // Events\r
-       };\r
-}\r
+ /*
+  * Copyright (c) 2002-2003 Mainsoft Corporation.
+  *
+  * Permission is hereby granted, free of charge, to any person obtaining a
+  * copy of this software and associated documentation files (the "Software"),
+  * to deal in the Software without restriction, including without limitation
+  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  * and/or sell copies of the Software, and to permit persons to whom the
+  * Software is furnished to do so, subject to the following conditions:
+  * 
+  * The above copyright notice and this permission notice shall be included in
+  * all copies or substantial portions of the Software.
+  * 
+  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  * DEALINGS IN THE SOFTWARE.
+  */
+/**
+ * This class allows to map VB6 exception number to the .NET exception.
+ */
+using System;
+namespace Microsoft.VisualBasic.CompilerServices {
+       [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
+       [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
+       [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Auto)] 
+       sealed public class ExceptionUtils {
+
+               public const int E_NOTIMPL = -2147467263;
+               public const int E_NOINTERFACE = -2147467262;
+               public const int E_ABORT = -2147467260;
+               public const int DISP_E_UNKNOWNINTERFACE = -2147352575;
+               public const int DISP_E_MEMBERNOTFOUND = -2147352573;
+               public const int DISP_E_PARAMNOTFOUND = -2147352572;
+               public const int DISP_E_TYPEMISMATCH = -2147352571;
+               public const int DISP_E_UNKNOWNNAME = -2147352570;
+               public const int DISP_E_NONAMEDARGS = -2147352569;
+               public const int DISP_E_BADVARTYPE = -2147352568;
+               public const int DISP_E_OVERFLOW = -2147352566;
+               public const int DISP_E_BADINDEX = -2147352565;
+               public const int DISP_E_UNKNOWNLCID = -2147352564;
+               public const int DISP_E_ARRAYISLOCKED = -2147352563;
+               public const int DISP_E_BADPARAMCOUNT = -2147352562;
+               public const int DISP_E_PARAMNOTOPTIONAL = -2147352561;
+               public const int DISP_E_NOTACOLLECTION = -2147352559;
+               public const int DISP_E_DIVBYZERO = -2147352558;
+               public const int TYPE_E_BUFFERTOOSMALL = -2147319786;
+               public const int TYPE_E_INVDATAREAD = -2147319784;
+               public const int TYPE_E_UNSUPFORMAT = -2147319783;
+               public const int TYPE_E_REGISTRYACCESS = -2147319780;
+               public const int TYPE_E_LIBNOTREGISTERED = -2147319779;
+               public const int TYPE_E_UNDEFINEDTYPE = -2147319769;
+               public const int TYPE_E_QUALIFIEDNAMEDISALLOWED = -2147319768;
+               public const int TYPE_E_INVALIDSTATE = -2147319767;
+               public const int TYPE_E_WRONGTYPEKIND = -2147319766;
+               public const int TYPE_E_ELEMENTNOTFOUND = -2147319765;
+               public const int TYPE_E_AMBIGUOUSNAME = -2147319764;
+               public const int TYPE_E_NAMECONFLICT = -2147319763;
+               public const int TYPE_E_UNKNOWNLCID = -2147319762;
+               public const int TYPE_E_DLLFUNCTIONNOTFOUND = -2147319761;
+               public const int TYPE_E_BADMODULEKIND = -2147317571;
+               public const int TYPE_E_SIZETOOBIG = -2147317563;
+               public const int TYPE_E_TYPEMISMATCH = -2147316576;
+               public const int TYPE_E_OUTOFBOUNDS = -2147316575;
+               public const int TYPE_E_IOERROR = -2147316574;
+               public const int TYPE_E_CANTCREATETMPFILE = -2147316573;
+               public const int TYPE_E_CANTLOADLIBRARY = -2147312566;
+               public const int TYPE_E_INCONSISTENTPROPFUNCS = -2147312509;
+               public const int TYPE_E_CIRCULARTYPE = -2147312508;
+               public const int STG_E_INVALIDFUNCTION = -2147287039;
+               public const int STG_E_FILENOTFOUND = -2147287038;
+               public const int STG_E_PATHNOTFOUND = -2147287037;
+               public const int STG_E_TOOMANYOPENFILES = -2147287036;
+               public const int STG_E_ACCESSDENIED = -2147287035;
+               public const int STG_E_INVALIDHANDLE = -2147287034;
+               public const int STG_E_INSUFFICIENTMEMORY = -2147287032;
+               public const int STG_E_NOMOREFILES = -2147287022;
+               public const int STG_E_DISKISWRITEPROTECTED = -2147287021;
+               public const int STG_E_SEEKERROR = -2147287015;
+               public const int STG_E_WRITEFAULT = -2147287011;
+               public const int STG_E_READFAULT = -2147287010;
+               public const int STG_E_SHAREVIOLATION = -2147287008;
+               public const int STG_E_LOCKVIOLATION = -2147287007;
+               public const int STG_E_FILEALREADYEXISTS = -2147286960;
+               public const int STG_E_MEDIUMFULL = -2147286928;
+               public const int STG_E_INVALIDHEADER = -2147286789;
+               public const int STG_E_INVALIDNAME = -2147286788;
+               public const int STG_E_UNKNOWN = -2147286787;
+               public const int STG_E_UNIMPLEMENTEDFUNCTION = -2147286786;
+               public const int STG_E_INUSE = -2147286784;
+               public const int STG_E_NOTCURRENT = -2147286783;
+               public const int STG_E_REVERTED = -2147286782;
+               public const int STG_E_CANTSAVE = -2147286781;
+               public const int STG_E_OLDFORMAT = -2147286780;
+               public const int STG_E_OLDDLL = -2147286779;
+               public const int STG_E_SHAREREQUIRED = -2147286778;
+               public const int STG_E_NOTFILEBASEDSTORAGE = -2147286777;
+               public const int STG_E_EXTANTMARSHALLINGS = -2147286776;
+               public const int CLASS_E_NOTLICENSED = -2147221230;
+               public const int REGDB_E_CLASSNOTREG = -2147221164;
+               public const int MK_E_UNAVAILABLE = -2147221021;
+               public const int MK_E_INVALIDEXTENSION = -2147221018;
+               public const int MK_E_CANTOPENFILE = -2147221014;
+               public const int CO_E_CLASSSTRING = -2147221005;
+               public const int CO_E_APPNOTFOUND = -2147221003;
+               public const int CO_E_APPDIDNTREG = -2147220994;
+               public const int E_ACCESSDENIED = -2147024891;
+               public const int E_OUTOFMEMORY = -2147024882;
+               public const int E_INVALIDARG = -2147024809;
+               public const int CO_E_SERVER_EXEC_FAILURE = -2146959355;
+
+               //TODO: uncomment and convert
+               //    private static HashMap _dotNetToVBMap = new HashMap();
+               //    
+               //    private static HashMap _vbToDotNetClassMap = new HashMap();
+               //    
+               //    static
+               //    { 
+               //        //initializing the hash map that maps vb exception number to .NET exception
+               //        //classes
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.ReturnWOGoSub),InvalidOperationException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.ResumeWOErr),InvalidOperationException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.CantUseNull),InvalidOperationException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.DoesntImplementICollection),InvalidOperationException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.IllegalFuncCall),ArgumentException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.NamedArgsNotSupported),ArgumentException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.NamedParamNotFound),ArgumentException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.ParameterNotOptional),ArgumentException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.OLENoPropOrMethod),MissingMemberException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.Overflow),OverflowException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.OutOfMemory),OutOfMemoryException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.OutOfStrSpace),OutOfMemoryException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.OutOfBounds),IndexOutOfRangeException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.DivByZero),DivideByZeroException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.TypeMismatch),InvalidCastException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.OutOfStack),StackOverflowException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.DLLLoadErr),TypeLoadException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.FileNotFound),FileNotFoundException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.EndOfFile),EndOfStreamException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.BadFileNameOrNumber),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.BadFileMode),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.IOError),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.FileAlreadyExists),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.FileAlreadyOpen),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.BadRecordLen),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.DiskFull),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.BadRecordNum),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.TooManyFiles),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.DevUnavailable),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.PermissionDenied),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.DiskNotReady),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.DifferentDrive),IOException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.PathFileAccess),IOException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.PathNotFound),FileNotFoundException.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.OLEFileNotFound),FileNotFoundException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.ObjNotSet),NullReferenceException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.PropertyNotFound),MissingFieldException.class);
+               //        
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.CantCreateObject),system.Exception.class);
+               //        _vbToDotNetClassMap.put(new Integer(vbErrors.ServerNotFound),system.Exception.class);
+               //        
+               //        //initializing the hash map that maps .NET exception number to VB exception
+               //         //number      
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.E_NOTIMPL),new Integer(vbErrors.NotYetImplemented));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.E_NOINTERFACE),new Integer(vbErrors.OLENotSupported));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.E_ABORT),new Integer(vbErrors.Abort));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_UNKNOWNINTERFACE),new Integer(vbErrors.OLENoPropOrMethod));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_MEMBERNOTFOUND),new Integer(vbErrors.OLENoPropOrMethod));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_PARAMNOTFOUND),new Integer(vbErrors.NamedParamNotFound));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_TYPEMISMATCH),new Integer(vbErrors.TypeMismatch));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_UNKNOWNNAME),new Integer(vbErrors.OLENoPropOrMethod));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_NONAMEDARGS),new Integer(vbErrors.NamedArgsNotSupported));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_BADVARTYPE),new Integer(vbErrors.InvalidTypeLibVariable));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_OVERFLOW),new Integer(vbErrors.Overflow));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_BADINDEX),new Integer(vbErrors.OutOfBounds));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_UNKNOWNLCID),new Integer(vbErrors.LocaleSettingNotSupported));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_ARRAYISLOCKED),new Integer(vbErrors.ArrayLocked));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_BADPARAMCOUNT),new Integer(vbErrors.FuncArityMismatch));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_NOTACOLLECTION),new Integer(vbErrors.NotEnum));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.DISP_E_DIVBYZERO),new Integer(vbErrors.DivByZero));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_BUFFERTOOSMALL),new Integer(vbErrors.BufferTooSmall));
+               //        _dotNetToVBMap.put(new Integer(-2147319785),new Integer(vbErrors.IdentNotMember));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_INVDATAREAD),new Integer(vbErrors.InvDataRead));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_UNSUPFORMAT),new Integer(vbErrors.UnsupFormat));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_REGISTRYACCESS),new Integer(vbErrors.RegistryAccess));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_LIBNOTREGISTERED),new Integer(vbErrors.LibNotRegistered));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_UNDEFINEDTYPE),new Integer(vbErrors.UndefinedType));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_QUALIFIEDNAMEDISALLOWED),new Integer(vbErrors.QualifiedNameDisallowed));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_INVALIDSTATE),new Integer(vbErrors.InvalidState));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_WRONGTYPEKIND),new Integer(vbErrors.WrongTypeKind));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_ELEMENTNOTFOUND),new Integer(vbErrors.ElementNotFound));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_AMBIGUOUSNAME),new Integer(vbErrors.AmbiguousName));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_NAMECONFLICT),new Integer(vbErrors.ModNameConflict));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_UNKNOWNLCID),new Integer(vbErrors.UnknownLcid));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_DLLFUNCTIONNOTFOUND),new Integer(vbErrors.InvalidDllFunctionName));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_BADMODULEKIND),new Integer(vbErrors.BadModuleKind));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_SIZETOOBIG),new Integer(vbErrors.SizeTooBig));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_TYPEMISMATCH),new Integer(vbErrors.TypeMismatch));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_OUTOFBOUNDS),new Integer(vbErrors.OutOfBounds));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_IOERROR),new Integer(vbErrors.TypeMismatch));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_CANTCREATETMPFILE),new Integer(vbErrors.CantCreateTmpFile));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_CANTLOADLIBRARY),new Integer(vbErrors.DLLLoadErr));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_INCONSISTENTPROPFUNCS),new Integer(vbErrors.InconsistentPropFuncs));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.TYPE_E_CIRCULARTYPE),new Integer(vbErrors.CircularType));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_INVALIDFUNCTION),new Integer(vbErrors.BadFunctionId));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_FILENOTFOUND),new Integer(vbErrors.FileNotFound));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_PATHNOTFOUND),new Integer(vbErrors.PathNotFound));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_TOOMANYOPENFILES),new Integer(vbErrors.TooManyFiles));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_ACCESSDENIED),new Integer(vbErrors.PermissionDenied));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_INVALIDHANDLE),new Integer(vbErrors.ReadFault));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_INSUFFICIENTMEMORY),new Integer(vbErrors.OutOfMemory));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_NOMOREFILES),new Integer(vbErrors.TooManyFiles));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_DISKISWRITEPROTECTED),new Integer(vbErrors.PermissionDenied));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_SEEKERROR),new Integer(vbErrors.SeekErr));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_WRITEFAULT),new Integer(vbErrors.ReadFault));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_READFAULT),new Integer(vbErrors.ReadFault));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_SHAREVIOLATION),new Integer(vbErrors.PathFileAccess));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_LOCKVIOLATION),new Integer(vbErrors.PermissionDenied));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_FILEALREADYEXISTS),new Integer(vbErrors.PathFileAccess));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_MEDIUMFULL),new Integer(vbErrors.DiskFull));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_INVALIDHEADER),new Integer(vbErrors.InvDataRead));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_INVALIDNAME),new Integer(vbErrors.FileNotFound));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_UNKNOWN),new Integer(vbErrors.InvDataRead));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_UNIMPLEMENTEDFUNCTION),new Integer(vbErrors.NotYetImplemented));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_INUSE),new Integer(vbErrors.PermissionDenied));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_NOTCURRENT),new Integer(vbErrors.PermissionDenied));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_REVERTED),new Integer(vbErrors.WriteFault));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_CANTSAVE),new Integer(vbErrors.IOError));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_OLDFORMAT),new Integer(vbErrors.UnsupFormat));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_OLDDLL),new Integer(vbErrors.UnsupFormat));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_SHAREREQUIRED),new Integer(32789));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_NOTFILEBASEDSTORAGE),new Integer(vbErrors.UnsupFormat));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.STG_E_EXTANTMARSHALLINGS),new Integer(vbErrors.UnsupFormat));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.CLASS_E_NOTLICENSED),new Integer(vbErrors.CantCreateObject));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.REGDB_E_CLASSNOTREG),new Integer(vbErrors.CantCreateObject));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.MK_E_UNAVAILABLE),new Integer(vbErrors.CantCreateObject));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.MK_E_INVALIDEXTENSION),new Integer(vbErrors.OLEFileNotFound));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.MK_E_CANTOPENFILE),new Integer(vbErrors.OLEFileNotFound));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.CO_E_CLASSSTRING),new Integer(vbErrors.CantCreateObject));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.CO_E_APPNOTFOUND),new Integer(vbErrors.CantCreateObject));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.CO_E_APPDIDNTREG),new Integer(vbErrors.CantCreateObject));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.E_ACCESSDENIED),new Integer(vbErrors.PermissionDenied));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.E_OUTOFMEMORY),new Integer(vbErrors.OutOfMemory));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.E_INVALIDARG),new Integer(vbErrors.IllegalFuncCall));
+               //        _dotNetToVBMap.put(new Integer(-2147023174),new Integer(vbErrors.ServerNotFound));
+               //        _dotNetToVBMap.put(new Integer(ExceptionUtils.CO_E_SERVER_EXEC_FAILURE),new Integer(vbErrors.CantCreateObject));
+               //
+               //        //new .NET values 
+               //        _dotNetToVBMap.put(new Integer(-2146233080),new Integer(vbErrors.OutOfBounds));//IndexOutOfRangeException
+               //        _dotNetToVBMap.put(new Integer(-2146233065),new Integer(vbErrors.OutOfBounds));//RankException
+               //        _dotNetToVBMap.put(new Integer(-2147467261),new Integer(vbErrors.ObjNotSet));//NullPointerException
+               //        _dotNetToVBMap.put(new Integer(-2146233066),new Integer(vbErrors.Overflow));//OverflowException
+               //        _dotNetToVBMap.put(new Integer(-2146233048),new Integer(vbErrors.Overflow));//NotFiniteNumberException
+               //        _dotNetToVBMap.put(new Integer(-2146233067),new Integer(vbErrors.TypeMismatch));//NotSupportedException
+               //        _dotNetToVBMap.put(new Integer(-2146233070),new Integer(vbErrors.OLENoPropOrMethod));//MissingMemberException
+               //        _dotNetToVBMap.put(new Integer(-2146233053),new Integer(vbErrors.InvalidDllFunctionName));//EntryPointNotFoundException
+               //        _dotNetToVBMap.put(new Integer(-2146233054),new Integer(vbErrors.CantCreateObject));//TypeLoadException
+               //        _dotNetToVBMap.put(new Integer(-2146233033),new Integer(vbErrors.TypeMismatch));//FormatException
+               //        _dotNetToVBMap.put(new Integer(-2147024893),new Integer(vbErrors.PathNotFound));//DirectoryNotFoundException
+               //        _dotNetToVBMap.put(new Integer(-2146232800),new Integer(vbErrors.IOError));//IOException
+               //        _dotNetToVBMap.put(new Integer(-2147024894),new Integer(vbErrors.FileNotFound));//FileNotFoundException     
+               //    }
+    
+    
+               public static int getVBFromDotNet(int number) {
+                       return (int)-2147467263;
+                       //return (int)_dotNetToVBMap.get(number);//uncomment and convert
+               }
+    
+               public static int fromDotNetToVB(int number) {
+               
+                       if (number > 0)
+                               return 0;
+
+                       if ((number & 536805376) == 655360)
+                               return number & 65535;
+
+                       //TODO:  uncomment and convert
+                       //Integer vbNum =  (Integer)_dotNetToVBMap.get(new Integer(number)); //Mainsoft code  
+
+                       // if (vbNum != null)
+                       //     return vbNum.intValue();
+                       // else
+                       return number;
+
+               }
+
+               //TODO:convert
+               /**
+                        * This method returns relevant .NET exception according to given number, 
+                        * with given description as message.
+                        * @param number
+                        * @param description
+                        * @param VBDefinedError
+                        * @return java.lang.Exception
+                        */
+               //TODO: is it correct to replace Mainsoft's ClrBoolean with bool?
+               //public static Exception BuildException(int number, String description, ClrBoolean VBDefinedError) {
+               public static Exception BuildException(int number, string description, bool VBDefinedError) {
+                       if (number != 0) {
+                               //TODO:convert
+                               //VBDefinedError.setValue(ClrBoolean.True);
+                               //Class exceptionClass = (Class)_vbToDotNetClassMap.get(new Integer(number));
+                               //if (exceptionClass != null)
+                               //{
+                               //    try
+                               //    {
+                               //        Constructor ctor = exceptionClass.getConstructor(new Class[] {string.class});
+                               //        return (Exception)ctor.newInstance(new object[]{description});                    
+                               //    }
+                               //    catch (Exception e)
+                               //    {
+                               //        //Here should be Tracing !!!
+                               //        System.out.println("Failed to initiate exception in ExceptionUtils.BuildException with number =" + number);
+                               //        e.printStackTrace();
+                               //    }
+                               //}
+               
+                               //VBDefinedError.setValue(ClrBoolean.False);
+                               return new Exception(description);
+                       }
+                       return null;
+               }
+
+               /**
+                * This method builds description string from resource file, replace given parameter
+                * in the description string and throws .NET exception according to the given number
+                * @param hr number of VB exception
+                * @param param1 parameter of message string
+                */
+               
+               public static void ThrowException1(int hr, string param1) {
+                       string str = "";
+                       //TODO: delete or convert???
+
+                       //                      if (hr > 0 && hr <= 65535)
+                       //                      
+                       //                              //str = VBUtils.GetResourceString(hr, param1);
+                       //
+                       //                              throw VbMakeExceptionEx(hr, str);
+               }
+
+               /**
+                * This method retrives exception message from the resource file and returns
+                * .NET exception that relevent to given number.
+                * @param hr
+                * @return java.lang.Exception
+                */
+               public static Exception VbMakeException(int hr) {
+
+                       string str = "";
+
+                       //TODO:convert
+                       //if (hr > 0 && hr <= 65535) {
+                       //      str = VBUtils.GetResourceString(hr);
+                       //      if (str == null)
+                       //              str  = VBUtils.GetResourceString(95);
+                       //}    
+                       str = "VB error #95 ";
+                       return VbMakeExceptionEx(hr, str);
+               }
+
+               public static Exception VbMakeException(Exception ex, int hr) {
+                       //TODO: convert
+                       //Information.Err().SetUnmappedError(hr);
+                       return ex;
+               }
+
+               /**
+                * This method returns .NET exception that relevant for the given number.
+                * @param Number
+                * @param sMsg
+                * @return java.lang.Exception
+                */
+               //TODO: convert
+               public static Exception VbMakeExceptionEx(int number, string msg) {
+                       //ClrBoolean bool = new ClrBoolean();
+                       bool Bool = false; //new ClrBoolean();
+                       Exception exp;
+               
+                       exp = ExceptionUtils.BuildException(number, msg, Bool);
+                               //TODO: convert
+                               // if (bool.getValue() == ClrBoolean.True)
+                               //     Information.Err().SetUnmappedError(number);
+                               return exp;
+               }
+
+       }
+}
index e22ac728bc172c42834e2c69ed4ebd46792aece0..1fe8c022e699b9c2d87fcdc5b5ab297963ea7042 100644 (file)
@@ -1,19 +1,15 @@
-//\r
-// IncompleteInitialization.cs\r
-//\r
-// Author:\r
-//   Chris J Breisch (cjbreisch@altavista.net)\r
-//\r
-// (C) 2002 Chris J Breisch\r
-//\r
-namespace Microsoft.VisualBasic.CompilerServices {\r
-       [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] \r
-       [MonoTODO]\r
-       sealed public class IncompleteInitialization : System.Exception, System.Runtime.Serialization.ISerializable {\r
-               // Declarations\r
-               // Constructors\r
-               // Properties\r
-               // Methods\r
-               // Events\r
-       };\r
-}\r
+//
+// IncompleteInitialization.cs
+//
+// Author:
+//   Chris J Breisch (cjbreisch@altavista.net)
+//
+// (C) 2002 Chris J Breisch
+//
+namespace Microsoft.VisualBasic.CompilerServices
+{
+       [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
+       sealed public class IncompleteInitialization : System.Exception, System.Runtime.Serialization.ISerializable {
+       };
+}
+
index 6c31a5ccfbd7636c53aa71ffc30f66e24c7697e4..553e183f7a1c545b96a19d5117d0a1921f9262eb 100644 (file)
@@ -33,7 +33,8 @@
   */
 using System;
 
-namespace Microsoft.VisualBasic.CompilerServices {
+namespace Microsoft.VisualBasic.CompilerServices
+{
        [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
        sealed public class IntegerType {
@@ -47,11 +48,11 @@ namespace Microsoft.VisualBasic.CompilerServices {
                 * @return int The value that extracted from the input string.
                 * @see Microsoft.VisualBasic.VBUtils#isNumber
                 */ 
-               public static System.Int32 FromString (System.String Value) {
+               public static System.Int32 FromString (string Value) {
                        if(Value == null)return 0;
+
                        double[] lRes = new double[1];
-                       
-                       return System.Int32.Parse(Value);
+                       return Int32.Parse(Value);
                        //TODO:
                        // converet the following, then remove the above line
                        //
@@ -63,12 +64,14 @@ namespace Microsoft.VisualBasic.CompilerServices {
                        //                      Environment.GetResourceString("Overflow_Int32"));
                        //      return (int) val;
                        //}
-                       return 0;
+                       //return 0;
                }
 
-               public static System.Int32 FromObject (System.Object Value) { 
+               public static System.Int32 FromObject (object Value) { 
                        if ((object)Value==null)return 0;
+
                        if(Value is string)return FromString((string) Value);
+
                        if(Value is int)return ((int)Value);
                         
                        return System.Convert.ToInt32(Value);
index 0fdc5a4b32038c00d3d8088a2ead8eca870cc5cf..6fb7c0241348d5d22a6ca9d04ceabdbcff516d11 100644 (file)
@@ -32,7 +32,8 @@
 
 using System;
 
-namespace Microsoft.VisualBasic.CompilerServices {
+namespace Microsoft.VisualBasic.CompilerServices
+{
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
        [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
        sealed public class LongType {
@@ -46,9 +47,11 @@ namespace Microsoft.VisualBasic.CompilerServices {
                 * @return long The long value that converted from the source object
                 * @see system.Convert#ToInt64
                 */
-               public static long FromObject(Object Value) {
+               public static long FromObject(object Value) {
                        if (Value == null)return 0;
-                       if (Value is string)return FromString((String) Value);
+
+                       if (Value is string)return FromString((string) Value);
+
                        return Convert.ToInt64(Value);
                }
                /**
@@ -60,8 +63,9 @@ namespace Microsoft.VisualBasic.CompilerServices {
                 * @return long The value that extracted from the input string.
                 * @see Microsoft.VisualBasic.VBUtils#isNumber
                 */
-               public static long FromString(String Value) {
+               public static long FromString(string Value) {
                        if (Value == null)return 0;
+
                        return long.Parse(Value); 
                }
 
index 48043cef515defcc19103f1a0f5e0f25fa9d35c7..365164227d5b0de723d37b6c79bbcd7924296904 100644 (file)
@@ -1,23 +1,23 @@
-//\r
-// OptionCompareAttribute.cs\r
-//\r
-// Author:\r
-//   Chris J Breisch (cjbreisch@altavista.net)\r
-//   Martin Adoue (martin@cwanet.com)\r
-//\r
-// (C) 2002 Ximian Inc.\r
 //
-\r
-using System;\r
-using System.ComponentModel;\r
-using System.Runtime.InteropServices;\r
-\r
-namespace Microsoft.VisualBasic.CompilerServices {\r
-       [EditorBrowsable(EditorBrowsableState.Never)] \r
-       [AttributeUsage(AttributeTargets.Parameter)] \r
-       [StructLayout(LayoutKind.Auto)] \r
-       [MonoTODO("What should it do?")]\r
-       sealed public class OptionCompareAttribute : Attribute {\r
-       };\r
-\r
-}\r
+// OptionCompareAttribute.cs
+//
+// Author:
+//   Chris J Breisch (cjbreisch@altavista.net)
+//   Martin Adoue (martin@cwanet.com)
+//
+// (C) 2002 Ximian Inc.
+//
+
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+//complete as per Mainsoft code
+namespace Microsoft.VisualBasic.CompilerServices {
+       [EditorBrowsable(EditorBrowsableState.Never)] 
+       [AttributeUsage(AttributeTargets.Parameter)] 
+       [StructLayout(LayoutKind.Auto)] 
+       sealed public class OptionCompareAttribute : Attribute {
+       };
+
+}
+
index 0a3e24b8e255fdf3af8997d6cac094db5cdd0231..beb5f4f960c9836722443f134d74fef8dda13138 100644 (file)
@@ -1,18 +1,20 @@
-//\r
-// OptionTextAttribute.cs\r
-//\r
-// Author:\r
-//   Chris J Breisch (cjbreisch@altavista.net)\r
-//\r
-// (C) 2002 Chris J Breisch\r
-//\r
-using System;\r
-using System.ComponentModel;\r
-\r
-namespace Microsoft.VisualBasic.CompilerServices {\r
-       [AttributeUsage(AttributeTargets.Class)] \r
-       [EditorBrowsable(EditorBrowsableState.Never)] \r
-       [MonoTODO("What should it do?")]\r
-       sealed public class OptionTextAttribute : Attribute {\r
-       };\r
-}\r
+//
+// OptionTextAttribute.cs
+//
+// Author:
+//   Chris J Breisch (cjbreisch@altavista.net)
+//
+// (C) 2002 Chris J Breisch
+//
+using System;
+using System.ComponentModel;
+
+//complete. matches Mainsoft code.
+namespace Microsoft.VisualBasic.CompilerServices
+{
+       [AttributeUsage(AttributeTargets.Class)] 
+       [EditorBrowsable(EditorBrowsableState.Never)] 
+       sealed public class OptionTextAttribute : Attribute {
+       };
+}
+
index 36c5f6ed53429dad1f80677f9c9e223963528649..0f1754144c1d37a65bc7d3d4d5f4762ae4a5217a 100644 (file)
@@ -32,7 +32,8 @@
 
 using System;
 
-namespace Microsoft.VisualBasic.CompilerServices {
+namespace Microsoft.VisualBasic.CompilerServices
+{
        [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
        sealed public class ShortType {
@@ -46,9 +47,11 @@ namespace Microsoft.VisualBasic.CompilerServices {
                 * @return long The long value that converted from the source object
                 * @see system.Convert#ToInt64
                 */
-               public static short FromObject(Object Value) {
+               public static short FromObject(object Value) {
                        if (Value == null)return 0;
-                       if (Value is string)return FromString((String) Value);
+
+                       if (Value is string)return FromString((string) Value);
+
                        return Convert.ToInt16(Value);
                }
                /**
@@ -60,8 +63,9 @@ namespace Microsoft.VisualBasic.CompilerServices {
                 * @return long The value that extracted from the input string.
                 * @see Microsoft.VisualBasic.VBUtils#isNumber
                 */
-               public static short FromString(String Value) {
+               public static short FromString(string Value) {
                        if (Value == null)return 0;
+
                        return short.Parse(Value); 
                }
 
index 134db71e4d41c5bebf8150285289cffb50d9f439..81ec1788b0ad7d7357475f0ae7aeb0f7ba2a8c65 100644 (file)
 //
 // SingleType.cs
 //
-// Author:
-//   Chris J Breisch (cjbreisch@altavista.net) 
+//     Author:
+//     Chris J Breisch (cjbreisch@altavista.net) 
+//     Dennis Hayes (dennish@raytek.com)
 //
-// (C) 2002 Chris J Breisch
+//     (C) copyright 2002 Chris J Breisch
+//     (C) copyright 2004 Novell
 //
-
+/*
+  * Copyright (c) 2002-2003 Mainsoft Corporation.
+  *
+  * Permission is hereby granted, free of charge, to any person obtaining a
+  * copy of this software and associated documentation files (the "Software"),
+  * to deal in the Software without restriction, including without limitation
+  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  * and/or sell copies of the Software, and to permit persons to whom the
+  * Software is furnished to do so, subject to the following conditions:
+  * 
+  * The above copyright notice and this permission notice shall be included in
+  * all copies or substantial portions of the Software.
+  * 
+  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  * DEALINGS IN THE SOFTWARE.
+  */
+  /**
+   * Class that converts objects to single value.
+   */
 using System;
+using System.Globalization;
 
-namespace Microsoft.VisualBasic.CompilerServices \r
-{
+namespace Microsoft.VisualBasic.CompilerServices {
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] 
        [Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute] 
        sealed public class SingleType {
-               // Declarations
-               // Constructors
-               // Properties
-               // Methods
-               public static System.Single FromString (System.String Value) { return System.Single.Parse(Value); }
-               [MonoTODO]
-               public static System.Single FromString (System.String Value, System.Globalization.NumberFormatInfo NumberFormat) { throw new NotImplementedException (); }
-               [MonoTODO]
-               public static System.Single FromObject (System.Object Value) { throw new NotImplementedException (); }
-               [MonoTODO]
-               public static System.Single FromObject (System.Object Value, System.Globalization.NumberFormatInfo NumberFormat) { throw new NotImplementedException (); }
-               // Events
-       };
+
+               /**
+                * Converts given string to float
+                * @param value string to convert
+                * @return float float representation of given string
+                */
+               public static float FromString(string Value) {
+                       return FromString(Value, null);
+               }
+    
+               /**
+                * The method try to convert given string to float in a following way:
+                * 1. If input string is null return 0.
+                * 2. If input string represents number: return value of this number, 
+                * @exception InvalidCastException - in case if number translation failed 
+                * @param str - The string that converted to float
+                * @return float The value that extracted from the input string.
+                * @see Microsoft.VisualBasic.VBUtils#isNumber
+                */
+               public static float FromString(string Value, NumberFormatInfo numberFormat) {
+                       if (Value == null)
+                               return 0.0f;
+
+                       return Convert.ToSingle(Value,numberFormat);
+
+                       //This gets base correct, but this conversion does not allow base, so I 
+                       // think the java base check is unneeded
+                       //int Base = 10;
+                       //int start = 0;
+                       //if(Value.Substring(0,1) == "&"){
+                       //      //is diff base
+                       //      if(Value.Substring(1,1).ToUpper() == "H")
+                       //              Base = 16;
+                       //      else if(Value.Substring(1,1).ToUpper() == "B")
+                       //              Base = 8;
+                       //      else {
+                       //              // I think we should just let convert take care of the execption.
+                       //              // Should we throw a special execption instead?
+                       //              // I think the Mainsoft java code below just converts execptions from java to C#
+                       //      }
+                       //      start = 2;
+                       //}
+
+                       //return Convert.ToSingle(Value.Substring(start,Value.Length - start), Base);
+
+                       // This is the java code for the above line. I think .net throws the correct execpition.
+                       // verify correct implmentation and execptions and remove
+                       //
+                       //try
+                       //{
+                       //    double[] lRes = new double[1];
+                       //    if (VBUtils.isNumber(Value, lRes))
+                       //        return (float)lRes[0];
+                       //}
+                       //catch (java.lang.Exception e)
+                       //{
+                       //    throw new InvalidCastException(
+                       //        Utils.GetResourceString("InvalidCast_FromStringTo", 
+                       //           value, "Single"), e);
+                       //}
+                       //return 0.0f;
+               }
+    
+               /**
+                * Converts given object to float.
+                * @param float value to convert to
+                * @return float value converted from given object
+                */
+               public static float FromObject(object Value) {
+                       return FromObject(Value, null);
+               }
+
+               /**
+                * The method converts given object to float by the following logic:
+                * 1. If input object is null - return 0
+                * 2. If input object is String - run FromString method
+                * 3. Otherwise run .NET default conversion - Convert.ToSingle
+                * @param value - The object that going to be converted
+                * @return float The float value that converted from the source object
+                * @see system.Convert#ToSingle
+                */
+               public static float FromObject(object Value, NumberFormatInfo numberFormat) {
+                       if (Value == null)
+                               return 0.0f;
+
+                       if (Value is string)
+                               return FromString((string) Value, numberFormat);
+
+                       return Convert.ToSingle(Value, numberFormat);
+                       // This is the java code for the above line. I think .net throws the correct execpition.
+                       //verify correct execptions and remove
+                       // try
+                       // {
+                       //     return Convert.ToSingle(Value, numberFormat);
+                       // }
+                       // catch(java.lang.Exception e)
+                       // {
+                       //     throw new InvalidCastException(
+                       //         Utils.GetResourceString("InvalidCast_FromTo", 
+                       //             Utils.VBFriendlyName(value), "Single"));
+                       // }
+               }
+
+       }
 }