dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/Basic/CompilerServices BooleanType.c


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/Basic/CompilerServices BooleanType.cs,1.1,1.2 ByteType.cs,1.1,1.2 CharArrayType.cs,1.1,1.2 CharType.cs,1.1,1.2 DateType.cs,1.1,1.2 DecimalType.cs,1.1,1.2 DoubleType.cs,1.1,1.2 IVbHost.cs,1.1,1.2 IntegerType.cs,1.1,1.2 LongType.cs,1.1,1.2 ShortType.cs,1.1,1.2 SingleType.cs,1.1,1.2 StringType.cs,1.1,1.2 Utils.cs,1.1,1.2
Date: Wed, 21 May 2003 22:24:11 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices
In directory subversions:/tmp/cvs-serv5930/Basic/CompilerServices

Modified Files:
        BooleanType.cs ByteType.cs CharArrayType.cs CharType.cs 
        DateType.cs DecimalType.cs DoubleType.cs IVbHost.cs 
        IntegerType.cs LongType.cs ShortType.cs SingleType.cs 
        StringType.cs Utils.cs 
Log Message:


Implement missing TODO's in the VB support library, primarily in the
CompilerServices namespace.


Index: BooleanType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/BooleanType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** BooleanType.cs      16 May 2003 05:35:00 -0000      1.1
--- BooleanType.cs      22 May 2003 02:24:09 -0000      1.2
***************
*** 40,56 ****
  
        // Convert an object into a boolean value.
-       [TODO]
        public static bool FromObject(Object Value)
                        {
!                               // TODO
!                               return false;
                        }
  
        // Convert a string into a boolean value.
-       [TODO]
        public static bool FromString(String Value)
                        {
!                               // TODO
!                               return false;
                        }
  
--- 40,88 ----
  
        // Convert an object into a boolean value.
        public static bool FromObject(Object Value)
                        {
!                               if(Value != null)
!                               {
!                                       IConvertible ic = (Value as 
IConvertible);
!                                       if(ic != null)
!                                       {
!                                               if(ic.GetTypeCode() != 
TypeCode.String)
!                                               {
!                                                       return 
ic.ToBoolean(null);
!                                               }
!                                               else
!                                               {
!                                                       return 
FromString(ic.ToString(null));
!                                               }
!                                       }
!                                       else
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
Value.GetType(), "System.Boolean"));
!                                       }
!                               }
!                               else
!                               {
!                                       return false;
!                               }
                        }
  
        // Convert a string into a boolean value.
        public static bool FromString(String Value)
                        {
!                               if(Value == null)
!                               {
!                                       Value = String.Empty;
!                               }
!                               try
!                               {
!                                       return Boolean.Parse(Value);
!                               }
!                               catch(FormatException)
!                               {
!                                       return (DoubleType.Parse(Value) != 0.0);
!                               }
                        }
  

Index: ByteType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/ByteType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ByteType.cs 16 May 2003 05:35:00 -0000      1.1
--- ByteType.cs 22 May 2003 02:24:09 -0000      1.2
***************
*** 40,56 ****
  
        // Convert an object into a byte value.
-       [TODO]
        public static byte FromObject(Object Value)
                        {
!                               // TODO
!                               return 0;
                        }
  
        // Convert a string into a byte value.
-       [TODO]
        public static byte FromString(String Value)
                        {
!                               // TODO
!                               return 0;
                        }
  
--- 40,95 ----
  
        // Convert an object into a byte value.
        public static byte FromObject(Object Value)
                        {
!                               if(Value != null)
!                               {
!                                       IConvertible ic = (Value as 
IConvertible);
!                                       if(ic != null)
!                                       {
!                                               if(ic.GetTypeCode() != 
TypeCode.String)
!                                               {
!                                                       return ic.ToByte(null);
!                                               }
!                                               else
!                                               {
!                                                       return 
FromString(ic.ToString(null));
!                                               }
!                                       }
!                                       else
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
Value.GetType(), "System.Byte"));
!                                       }
!                               }
!                               else
!                               {
!                                       return 0;
!                               }
                        }
  
        // Convert a string into a byte value.
        public static byte FromString(String Value)
                        {
!                               if(Value != null)
!                               {
!                                       try
!                                       {
!                                               return Convert.ToByte
!                                                       
(Math.Round(DoubleType.Parse(Value)));
!                                       }
!                                       catch(OverflowException)
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
"System.String", "System.Byte"));
!                                       }
!                               }
!                               else
!                               {
!                                       return 0;
!                               }
                        }
  

Index: CharArrayType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/CharArrayType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** CharArrayType.cs    16 May 2003 05:35:00 -0000      1.1
--- CharArrayType.cs    22 May 2003 02:24:09 -0000      1.2
***************
*** 34,50 ****
  
        // Convert an object into a char array value.
-       [TODO]
        public static char[] FromObject(Object Value)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Convert a string into a char array value.
-       [TODO]
        public static char[] FromString(String Value)
                        {
!                               // TODO
!                               return null;
                        }
  
--- 34,75 ----
  
        // Convert an object into a char array value.
        public static char[] FromObject(Object Value)
                        {
!                               if(Value != null)
!                               {
!                                       if(Value is char[])
!                                       {
!                                               return (char[])Value;
!                                       }
!                                       IConvertible ic = (Value as 
IConvertible);
!                                       if(ic != null && ic.GetTypeCode() == 
TypeCode.String)
!                                       {
!                                               return 
ic.ToString(null).ToCharArray();
!                                       }
!                                       else
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
Value.GetType(), "char[]"));
!                                       }
!                               }
!                               else
!                               {
!                                       return new char [0];
!                               }
                        }
  
        // Convert a string into a char array value.
        public static char[] FromString(String Value)
                        {
!                               if(Value != null)
!                               {
!                                       return Value.ToCharArray();
!                               }
!                               else
!                               {
!                                       return new char [0];
!                               }
                        }
  

Index: CharType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/CharType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** CharType.cs 16 May 2003 05:35:00 -0000      1.1
--- CharType.cs 22 May 2003 02:24:09 -0000      1.2
***************
*** 34,50 ****
  
        // Convert an object into a char value.
-       [TODO]
        public static char FromObject(Object Value)
                        {
!                               // TODO
!                               return '\0';
                        }
  
        // Convert a string into a char array value.
-       [TODO]
        public static char FromString(String Value)
                        {
!                               // TODO
!                               return '\0';
                        }
  
--- 34,78 ----
  
        // Convert an object into a char value.
        public static char FromObject(Object Value)
                        {
!                               if(Value != null)
!                               {
!                                       IConvertible ic = (Value as 
IConvertible);
!                                       if(ic != null)
!                                       {
!                                               if(ic.GetTypeCode() != 
TypeCode.String)
!                                               {
!                                                       return ic.ToChar(null);
!                                               }
!                                               else
!                                               {
!                                                       return 
FromString(ic.ToString(null));
!                                               }
!                                       }
!                                       else
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
Value.GetType(), "System.Char"));
!                                       }
!                               }
!                               else
!                               {
!                                       return '\0';
!                               }
                        }
  
        // Convert a string into a char array value.
        public static char FromString(String Value)
                        {
!                               if(Value != null && Value.Length != 0)
!                               {
!                                       return Value[0];
!                               }
!                               else
!                               {
!                                       return '\0';
!                               }
                        }
  

Index: DateType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/DateType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** DateType.cs 16 May 2003 05:35:00 -0000      1.1
--- DateType.cs 22 May 2003 02:24:09 -0000      1.2
***************
*** 35,43 ****
  
        // Convert an object into a date value.
-       [TODO]
        public static DateTime FromObject(Object Value)
                        {
!                               // TODO
!                               return DateTime.MinValue;
                        }
  
--- 35,57 ----
  
        // Convert an object into a date value.
        public static DateTime FromObject(Object Value)
                        {
!                               IConvertible ic = (Value as IConvertible);
!                               if(ic != null)
!                               {
!                                       if(ic.GetTypeCode() != TypeCode.String)
!                                       {
!                                               return ic.ToDateTime(null);
!                                       }
!                                       else
!                                       {
!                                               return 
FromString(ic.ToString(null));
!                                       }
!                               }
!                               throw new InvalidCastException
!                                       (String.Format
!                                               (S._("VB_InvalidCast"),
!                                                (Value != null ? 
Value.GetType().ToString() : "null"),
!                                                "System.DateTime"));
                        }
  
***************
*** 47,55 ****
                                return FromString(Value, 
CultureInfo.CurrentCulture);
                        }
-       [TODO]
        public static DateTime FromString(String Value, CultureInfo culture)
                        {
!                               // TODO
!                               return DateTime.MinValue;
                        }
  
--- 61,81 ----
                                return FromString(Value, 
CultureInfo.CurrentCulture);
                        }
        public static DateTime FromString(String Value, CultureInfo culture)
                        {
!                               try
!                               {
!                                       return 
DateTime.Parse(Utils.FixDigits(Value), culture,
!                                                                               
  DateTimeStyles.AllowWhiteSpaces |
!                                                                               
  DateTimeStyles.NoCurrentDateDefault);
!                               }
!                               catch(Exception)
!                               {
!                                       throw new InvalidCastException
!                                               (String.Format
!                                                       (S._("VB_InvalidCast"),
!                                                        (Value != null ? 
Value.GetType().ToString()
!                                                                               
        : "null"),
!                                                        "System.DateTime"));
!                               }
                        }
  

Index: DecimalType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/DecimalType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** DecimalType.cs      16 May 2003 05:35:00 -0000      1.1
--- DecimalType.cs      22 May 2003 02:24:09 -0000      1.2
***************
*** 45,54 ****
                                return FromObject(Value, null);
                        }
-       [TODO]
        public static Decimal FromObject
                                (Object Value, NumberFormatInfo NumberFormat)
                        {
!                               // TODO
!                               return 0.0m;
                        }
  
--- 45,77 ----
                                return FromObject(Value, null);
                        }
        public static Decimal FromObject
                                (Object Value, NumberFormatInfo NumberFormat)
                        {
!                               if(Value != null)
!                               {
!                                       IConvertible ic = (Value as 
IConvertible);
!                                       if(ic != null)
!                                       {
!                                               if(ic.GetTypeCode() != 
TypeCode.String)
!                                               {
!                                                       return 
ic.ToDecimal(NumberFormat);
!                                               }
!                                               else
!                                               {
!                                                       return 
FromString(ic.ToString(null), NumberFormat);
!                                               }
!                                       }
!                                       else
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
Value.GetType(), "System.Decimal"));
!                                       }
!                               }
!                               else
!                               {
!                                       return 0.0m;
!                               }
                        }
  

Index: DoubleType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/DoubleType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** DoubleType.cs       16 May 2003 05:35:00 -0000      1.1
--- DoubleType.cs       22 May 2003 02:24:09 -0000      1.2
***************
*** 45,54 ****
                                return FromObject(Value, null);
                        }
-       [TODO]
        public static double FromObject
                                (Object Value, NumberFormatInfo NumberFormat)
                        {
!                               // TODO
!                               return 0.0;
                        }
  
--- 45,77 ----
                                return FromObject(Value, null);
                        }
        public static double FromObject
                                (Object Value, NumberFormatInfo NumberFormat)
                        {
!                               if(Value != null)
!                               {
!                                       IConvertible ic = (Value as 
IConvertible);
!                                       if(ic != null)
!                                       {
!                                               if(ic.GetTypeCode() != 
TypeCode.String)
!                                               {
!                                                       return 
ic.ToDouble(NumberFormat);
!                                               }
!                                               else
!                                               {
!                                                       return 
FromString(ic.ToString(null), NumberFormat);
!                                               }
!                                       }
!                                       else
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
Value.GetType(), "System.Double"));
!                                       }
!                               }
!                               else
!                               {
!                                       return 0.0;
!                               }
                        }
  

Index: IVbHost.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/IVbHost.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** IVbHost.cs  16 May 2003 05:35:00 -0000      1.1
--- IVbHost.cs  22 May 2003 02:24:09 -0000      1.2
***************
*** 30,34 ****
  public interface IVbHost
  {
!       // Get the parent window.  Non-portable and TODO.
        // IWin32Window GetParentWindow();
  
--- 30,34 ----
  public interface IVbHost
  {
!       // Get the parent window.  Non-portable.
        // IWin32Window GetParentWindow();
  

Index: IntegerType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/IntegerType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** IntegerType.cs      16 May 2003 05:35:00 -0000      1.1
--- IntegerType.cs      22 May 2003 02:24:09 -0000      1.2
***************
*** 40,56 ****
  
        // Convert an object into an integer value.
-       [TODO]
        public static int FromObject(Object Value)
                        {
!                               // TODO
!                               return 0;
                        }
  
        // Convert a string into an integer value.
-       [TODO]
        public static int FromString(String Value)
                        {
!                               // TODO
!                               return 0;
                        }
  
--- 40,95 ----
  
        // Convert an object into an integer value.
        public static int FromObject(Object Value)
                        {
!                               if(Value != null)
!                               {
!                                       IConvertible ic = (Value as 
IConvertible);
!                                       if(ic != null)
!                                       {
!                                               if(ic.GetTypeCode() != 
TypeCode.String)
!                                               {
!                                                       return ic.ToInt32(null);
!                                               }
!                                               else
!                                               {
!                                                       return 
FromString(ic.ToString(null));
!                                               }
!                                       }
!                                       else
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
Value.GetType(), "System.ToInt32"));
!                                       }
!                               }
!                               else
!                               {
!                                       return 0;
!                               }
                        }
  
        // Convert a string into an integer value.
        public static int FromString(String Value)
                        {
!                               if(Value != null)
!                               {
!                                       try
!                                       {
!                                               return Convert.ToInt32
!                                                       
(Math.Round(DoubleType.Parse(Value)));
!                                       }
!                                       catch(OverflowException)
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
"System.String", "System.Int32"));
!                                       }
!                               }
!                               else
!                               {
!                                       return 0;
!                               }
                        }
  

Index: LongType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/LongType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** LongType.cs 16 May 2003 05:35:00 -0000      1.1
--- LongType.cs 22 May 2003 02:24:09 -0000      1.2
***************
*** 40,56 ****
  
        // Convert an object into a long value.
-       [TODO]
        public static long FromObject(Object Value)
                        {
!                               // TODO
!                               return 0;
                        }
  
        // Convert a string into a long value.
-       [TODO]
        public static long FromString(String Value)
                        {
!                               // TODO
!                               return 0;
                        }
  
--- 40,95 ----
  
        // Convert an object into a long value.
        public static long FromObject(Object Value)
                        {
!                               if(Value != null)
!                               {
!                                       IConvertible ic = (Value as 
IConvertible);
!                                       if(ic != null)
!                                       {
!                                               if(ic.GetTypeCode() != 
TypeCode.String)
!                                               {
!                                                       return ic.ToInt64(null);
!                                               }
!                                               else
!                                               {
!                                                       return 
FromString(ic.ToString(null));
!                                               }
!                                       }
!                                       else
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
Value.GetType(), "System.Int64"));
!                                       }
!                               }
!                               else
!                               {
!                                       return 0;
!                               }
                        }
  
        // Convert a string into a long value.
        public static long FromString(String Value)
                        {
!                               if(Value != null)
!                               {
!                                       try
!                                       {
!                                               return Convert.ToInt64
!                                                       
(Math.Round(DoubleType.Parse(Value)));
!                                       }
!                                       catch(OverflowException)
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
"System.String", "System.Int64"));
!                                       }
!                               }
!                               else
!                               {
!                                       return 0;
!                               }
                        }
  

Index: ShortType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/ShortType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ShortType.cs        16 May 2003 05:35:00 -0000      1.1
--- ShortType.cs        22 May 2003 02:24:09 -0000      1.2
***************
*** 40,56 ****
  
        // Convert an object into a short value.
-       [TODO]
        public static short FromObject(Object Value)
                        {
!                               // TODO
!                               return 0;
                        }
  
        // Convert a string into a short value.
-       [TODO]
        public static short FromString(String Value)
                        {
!                               // TODO
!                               return 0;
                        }
  
--- 40,95 ----
  
        // Convert an object into a short value.
        public static short FromObject(Object Value)
                        {
!                               if(Value != null)
!                               {
!                                       IConvertible ic = (Value as 
IConvertible);
!                                       if(ic != null)
!                                       {
!                                               if(ic.GetTypeCode() != 
TypeCode.String)
!                                               {
!                                                       return ic.ToInt16(null);
!                                               }
!                                               else
!                                               {
!                                                       return 
FromString(ic.ToString(null));
!                                               }
!                                       }
!                                       else
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
Value.GetType(), "System.Int16"));
!                                       }
!                               }
!                               else
!                               {
!                                       return 0;
!                               }
                        }
  
        // Convert a string into a short value.
        public static short FromString(String Value)
                        {
!                               if(Value != null)
!                               {
!                                       try
!                                       {
!                                               return Convert.ToInt16
!                                                       
(Math.Round(DoubleType.Parse(Value)));
!                                       }
!                                       catch(OverflowException)
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
"System.String", "System.Int16"));
!                                       }
!                               }
!                               else
!                               {
!                                       return 0;
!                               }
                        }
  

Index: SingleType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/SingleType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SingleType.cs       16 May 2003 05:35:00 -0000      1.1
--- SingleType.cs       22 May 2003 02:24:09 -0000      1.2
***************
*** 45,54 ****
                                return FromObject(Value, null);
                        }
-       [TODO]
        public static float FromObject
                                (Object Value, NumberFormatInfo NumberFormat)
                        {
!                               // TODO
!                               return 0.0f;
                        }
  
--- 45,77 ----
                                return FromObject(Value, null);
                        }
        public static float FromObject
                                (Object Value, NumberFormatInfo NumberFormat)
                        {
!                               if(Value != null)
!                               {
!                                       IConvertible ic = (Value as 
IConvertible);
!                                       if(ic != null)
!                                       {
!                                               if(ic.GetTypeCode() != 
TypeCode.String)
!                                               {
!                                                       return 
ic.ToSingle(NumberFormat);
!                                               }
!                                               else
!                                               {
!                                                       return 
FromString(ic.ToString(null), NumberFormat);
!                                               }
!                                       }
!                                       else
!                                       {
!                                               throw new InvalidCastException
!                                                       (String.Format
!                                                               
(S._("VB_InvalidCast"),
!                                                                
Value.GetType(), "System.Single"));
!                                       }
!                               }
!                               else
!                               {
!                                       return 0.0f;
!                               }
                        }
  

Index: StringType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/StringType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** StringType.cs       16 May 2003 05:35:00 -0000      1.1
--- StringType.cs       22 May 2003 02:24:09 -0000      1.2
***************
*** 26,29 ****
--- 26,30 ----
  using System.ComponentModel;
  using System.Globalization;
+ using System.Text;
  
  [StandardModule]
***************
*** 66,74 ****
  
        // Convert a date value into a string.
-       [TODO]
        public static String FromDate(DateTime Value)
                        {
!                               // TODO
!                               return Value.ToString();
                        }
  
--- 67,88 ----
  
        // Convert a date value into a string.
        public static String FromDate(DateTime Value)
                        {
!                               long ticks = Value.Ticks;
!                               if(ticks < TimeSpan.TicksPerDay)
!                               {
!                                       // Format as a time value.
!                                       return Value.ToString("T", null);
!                               }
!                               else if((ticks / TimeSpan.TicksPerDay) == 0)
!                               {
!                                       // Format as a date value.
!                                       return Value.ToString("d", null);
!                               }
!                               else
!                               {
!                                       // Format as a date and time value.
!                                       return Value.ToString("G", null);
!                               }
                        }
  
***************
*** 155,163 ****
  
        // Insert a string into the middle of another.
-       [TODO]
        public static void MidStmtStr(ref String sDest, int StartPosition,
                                                                  int 
MaxInsertLength, String sInsert)
                        {
!                               // TODO
                        }
  
--- 169,223 ----
  
        // Insert a string into the middle of another.
        public static void MidStmtStr(ref String sDest, int StartPosition,
                                                                  int 
MaxInsertLength, String sInsert)
                        {
!                               // Get the lengths of the two strings.
!                               int len1 = (sDest != null ? sDest.Length : 0);
!                               int len2 = (sInsert != null ? sInsert.Length : 
0);
! 
!                               // Validate the starting index (base is one, 
not zero).
!                               --StartPosition;
!                               if(StartPosition < 0 || StartPosition >= len1)
!                               {
!                                       throw new ArgumentException
!                                               (S._("VB_InvalidStringIndex"), 
"StartPosition");
!                               }
! 
!                               // Validate the replacement length.
!                               if(MaxInsertLength < 0)
!                               {
!                                       throw new ArgumentException
!                                               (S._("VB_InvalidStringLength"), 
"MaxInsertLength");
!                               }
! 
!                               // Bounds-check the string that is to be 
inserted.
!                               if(len2 > MaxInsertLength)
!                               {
!                                       len2 = MaxInsertLength;
!                               }
!                               int rest = (len1 - StartPosition);
!                               if(len2 > rest)
!                               {
!                                       len2 = rest;
!                               }
!                               if(len2 == 0)
!                               {
!                                       // No change to the incoming string.
!                                       return;
!                               }
! 
!                               // Build the final string.
!                               StringBuilder builder = new StringBuilder(len1);
!                               if(StartPosition > 0)
!                               {
!                                       builder.Append(sDest, 0, StartPosition);
!                               }
!                               builder.Append(sInsert, 0, len2);
!                               rest = StartPosition + len2;
!                               if(rest < len1)
!                               {
!                                       builder.Append(sDest, rest, len1 - 
rest);
!                               }
!                               sDest = builder.ToString();
                        }
  
***************
*** 189,211 ****
                                                           CompareMethod 
CompareOption)
                        {
                                if(CompareOption == CompareMethod.Binary)
                                {
!                                       return StrLikeBinary(Source, Pattern);
                                }
                                else
                                {
!                                       return StrLikeText(Source, Pattern);
                                }
                        }
-       [TODO]
        public static bool StrLikeBinary(String Source, String Pattern)
                        {
!                               // TODO
!                               return false;
                        }
-       [TODO]
        public static bool StrLikeText(String Source, String Pattern)
                        {
!                               // TODO
                                return false;
                        }
--- 249,705 ----
                                                           CompareMethod 
CompareOption)
                        {
+                               // Handle the empty string cases first.
+                               if(Source == null || Source.Length == 0)
+                               {
+                                       if(Pattern == null || Pattern.Length == 
0)
+                                       {
+                                               return true;
+                                       }
+                                       else
+                                       {
+                                               return false;
+                                       }
+                               }
+                               else if(Pattern == null || Pattern.Length == 0)
+                               {
+                                       return false;
+                               }
+ 
+                               // Compile the pattern into a set of matching 
rules.
+                               Rule[] rules = CompilePattern(Pattern, 
CompareOption);
+ 
+                               // Get the comparison object for the current 
culture.
+                               CompareInfo compare;
                                if(CompareOption == CompareMethod.Binary)
                                {
!                                       compare = null;
                                }
                                else
                                {
!                                       compare = 
CultureInfo.CurrentCulture.CompareInfo;
!                               }
! 
!                               // Execute the rules to match the string.
!                               int posn = 0;
!                               int len = Source.Length;
!                               int rule = 0;
!                               int backtrack = -1;
!                               bool doBacktrack = false;
!                               for(;;)
!                               {
!                                       switch(rules[rule].command)
!                                       {
!                                               case RuleCommand.MatchEnd:
!                                               {
!                                                       // Match the end of the 
string.
!                                                       if(posn >= len)
!                                                       {
!                                                               return true;
!                                                       }
!                                                       else
!                                                       {
!                                                               doBacktrack = 
true;
!                                                       }
!                                               }
!                                               break;
! 
!                                               case RuleCommand.MatchOne:
!                                               {
!                                                       // Match a single 
character of any value.
!                                                       if(posn < len)
!                                                       {
!                                                               ++posn;
!                                                               ++rule;
!                                                       }
!                                                       else
!                                                       {
!                                                               doBacktrack = 
true;
!                                                       }
!                                               }
!                                               break;
! 
!                                               case RuleCommand.MatchDigit:
!                                               {
!                                                       // Match a digit.
!                                                       if(posn < len &&
!                                                          Source[posn] >= '0' 
&& Source[posn] <= '9')
!                                                       {
!                                                               ++posn;
!                                                               ++rule;
!                                                       }
!                                                       else
!                                                       {
!                                                               doBacktrack = 
true;
!                                                       }
!                                               }
!                                               break;
! 
!                                               case RuleCommand.MatchAny:
!                                               {
!                                                       // Match zero or more 
characters.
!                                                       rules[rule].posn = posn;
!                                                       rules[rule].len = 
backtrack;
!                                                       backtrack = rule;
!                                                       ++rule;
!                                               }
!                                               break;
! 
!                                               case 
RuleCommand.MatchBinaryChar:
!                                               {
!                                                       // Match a specific 
binary character.
!                                                       if(posn < len && 
Source[posn] == rules[rule].posn)
!                                                       {
!                                                               ++posn;
!                                                               ++rule;
!                                                       }
!                                                       else
!                                                       {
!                                                               doBacktrack = 
true;
!                                                       }
!                                               }
!                                               break;
! 
!                                               case RuleCommand.MatchTextChar:
!                                               {
!                                                       // Match a specific 
text character.
!                                                       if(posn < len &&
!                                                          
EqualTextChar(Source, posn,
!                                                                               
         Pattern, rules[rule].posn,
!                                                                               
         compare))
!                                                       {
!                                                               ++posn;
!                                                               ++rule;
!                                                       }
!                                                       else
!                                                       {
!                                                               doBacktrack = 
true;
!                                                       }
!                                               }
!                                               break;
! 
!                                               case RuleCommand.MatchBinarySet:
!                                               {
!                                                       // Match any character 
in a given binary set.
!                                                       if(posn < len &&
!                                                          
CharInBinarySet(Pattern, rules[rule].posn,
!                                                                               
       rules[rule].len, Source[posn]))
!                                                       {
!                                                               ++posn;
!                                                               ++rule;
!                                                       }
!                                                       else
!                                                       {
!                                                               doBacktrack = 
true;
!                                                       }
!                                               }
!                                               break;
! 
!                                               case RuleCommand.MatchTextSet:
!                                               {
!                                                       // Match any character 
in a given text set.
!                                                       if(posn < len &&
!                                                          
CharInTextSet(Pattern, rules[rule].posn,
!                                                                               
     rules[rule].len, Source, posn,
!                                                                               
     compare))
!                                                       {
!                                                               ++posn;
!                                                               ++rule;
!                                                       }
!                                                       else
!                                                       {
!                                                               doBacktrack = 
true;
!                                                       }
!                                               }
!                                               break;
! 
!                                               case 
RuleCommand.MatchBinaryInvSet:
!                                               {
!                                                       // Match any character 
not in a given binary set.
!                                                       if(posn < len &&
!                                                          
!CharInBinarySet(Pattern, rules[rule].posn,
!                                                                               
        rules[rule].len, Source[posn]))
!                                                       {
!                                                               ++posn;
!                                                               ++rule;
!                                                       }
!                                                       else
!                                                       {
!                                                               doBacktrack = 
true;
!                                                       }
!                                               }
!                                               break;
! 
!                                               case 
RuleCommand.MatchTextInvSet:
!                                               {
!                                                       // Match any character 
not in a given text set.
!                                                       if(posn < len &&
!                                                          
!CharInTextSet(Pattern, rules[rule].posn,
!                                                                               
      rules[rule].len, Source, posn,
!                                                                               
          compare))
!                                                       {
!                                                               ++posn;
!                                                               ++rule;
!                                                       }
!                                                       else
!                                                       {
!                                                               doBacktrack = 
true;
!                                                       }
!                                               }
!                                               break;
!                                       }
!                                       if(doBacktrack)
!                                       {
!                                               if(backtrack != -1)
!                                               {
!                                                       posn = 
++(rules[backtrack].posn);
!                                                       rule = backtrack + 1;
!                                                       while(posn >= len)
!                                                       {
!                                                               backtrack = 
rules[backtrack].len;
!                                                               if(backtrack != 
-1)
!                                                               {
!                                                                       posn = 
++(rules[backtrack].posn);
!                                                                       rule = 
backtrack + 1;
!                                                               }
!                                                               else
!                                                               {
!                                                                       return 
false;
!                                                               }
!                                                       }
!                                               }
!                                               else
!                                               {
!                                                       return false;
!                                               }
!                                               doBacktrack = false;
!                                       }
                                }
                        }
        public static bool StrLikeBinary(String Source, String Pattern)
                        {
!                               return StrLike(Source, Pattern, 
CompareMethod.Binary);
                        }
        public static bool StrLikeText(String Source, String Pattern)
                        {
!                               return StrLike(Source, Pattern, 
CompareMethod.Text);
!                       }
! 
!       // Available rule commands.
!       private enum RuleCommand
!       {
!               MatchEnd,
!               MatchOne,
!               MatchDigit,
!               MatchAny,
!               MatchBinaryChar,
!               MatchTextChar,
!               MatchBinarySet,
!               MatchTextSet,
!               MatchBinaryInvSet,
!               MatchTextInvSet
! 
!       }; // enum RuleCommand
! 
!       // Information about a "like" matching rule.
!       private struct Rule
!       {
!               public RuleCommand command;
!               public int posn;
!               public int len;
! 
!       }; // struct Rule
! 
!       // Bail out for an invalid pattern.
!       private static void InvalidPattern()
!                       {
!                               throw new 
ArgumentException(S._("VB_InvalidPattern"));
!                       }
! 
!       // Compile a "like" pattern into a set of matching rules.
!       private static Rule[] CompilePattern(String pattern,
!                                                                               
 CompareMethod method)
!                       {
!                               Rule[] rules = new Rule [pattern.Length + 1];
!                               int posn, len, start;
!                               int rule = 0;
!                               char ch;
!                               len = pattern.Length;
!                               posn = 0;
!                               while(posn < len)
!                               {
!                                       ch = pattern[posn++];
!                                       if(ch == '?')
!                                       {
!                                               rules[rule].command = 
RuleCommand.MatchOne;
!                                       }
!                                       else if(ch == '#')
!                                       {
!                                               rules[rule].command = 
RuleCommand.MatchDigit;
!                                       }
!                                       else if(ch == '*')
!                                       {
!                                               rules[rule].command = 
RuleCommand.MatchAny;
!                                       }
!                                       else if(ch == '[')
!                                       {
!                                               if(posn >= len)
!                                               {
!                                                       InvalidPattern();
!                                               }
!                                               ch = pattern[posn++];
!                                               if(ch == '!')
!                                               {
!                                                       if(method == 
CompareMethod.Binary)
!                                                       {
!                                                               
rules[rule].command =
!                                                                       
RuleCommand.MatchBinaryInvSet;
!                                                       }
!                                                       else
!                                                       {
!                                                               
rules[rule].command =
!                                                                       
RuleCommand.MatchTextInvSet;
!                                                       }
!                                                       if(posn >= len)
!                                                       {
!                                                               
InvalidPattern();
!                                                       }
!                                                       ch = pattern[posn++];
!                                               }
!                                               else if(method == 
CompareMethod.Binary)
!                                               {
!                                                       rules[rule].command = 
RuleCommand.MatchBinarySet;
!                                               }
!                                               else
!                                               {
!                                                       rules[rule].command = 
RuleCommand.MatchTextSet;
!                                               }
!                                               start = posn - 1;
!                                               if(ch == ']')
!                                               {
!                                                       // Ignore empty "[]" 
sequences.
!                                                       continue;
!                                               }
!                                               while(posn < len && 
pattern[posn] != ']')
!                                               {
!                                                       ++posn;
!                                               }
!                                               if(posn >= len)
!                                               {
!                                                       InvalidPattern();
!                                               }
!                                               rules[rule].posn = start;
!                                               rules[rule].len = posn - start;
!                                               ++posn;
!                                       }
!                                       else if(method == CompareMethod.Binary)
!                                       {
!                                               rules[rule].command = 
RuleCommand.MatchBinaryChar;
!                                               rules[rule].posn = ch;
!                                       }
!                                       else
!                                       {
!                                               rules[rule].command = 
RuleCommand.MatchTextChar;
!                                               rules[rule].posn = posn - 1;
!                                       }
!                                       ++rule;
!                               }
!                               rules[rule].command = RuleCommand.MatchEnd;
!                               return rules;
!                       }
! 
!       // Determine if two characters are equal, using a text compare.
!       private static bool EqualTextChar(String str1, int posn1,
!                                                                         
String str2, int posn2,
!                                                                         
CompareInfo compare)
!                       {
!                               if(str1[posn1] == str2[posn2])
!                               {
!                                       // Short cut for the common case.
!                                       return true;
!                               }
!                               return (compare.Compare(str1, posn1, 1, str2, 
posn2, 1,
!                                                                               
CompareOptions.IgnoreCase |
!                                                                               
CompareOptions.IgnoreNonSpace |
!                                                                               
CompareOptions.IgnoreKanaType |
!                                                                               
CompareOptions.IgnoreWidth) == 0);
!                       }
! 
!       // Determine if a character appears in a binary set.
!       private static bool CharInBinarySet(String pattern, int offset,
!                                                                       int 
length, char ch)
!                       {
!                               char match;
!                               while(length > 0)
!                               {
!                                       match = pattern[offset++];
!                                       --length;
!                                       if(length > 1 && pattern[offset] == '-')
!                                       {
!                                               // Match against a character 
range.
!                                               if(ch >= match && ch <= 
pattern[offset + 1])
!                                               {
!                                                       return true;
!                                               }
!                                               offset += 2;
!                                               length -= 2;
!                                       }
!                                       else
!                                       {
!                                               // Match against a single 
character.
!                                               if(match == ch)
!                                               {
!                                                       return true;
!                                               }
!                                       }
!                               }
!                               return false;
!                       }
! 
!       // Determine if a character appears in a text set.
!       private static bool CharInTextSet(String pattern, int offset,
!                                                                     int 
length, String source, int posn,
!                                                                         
CompareInfo compare)
!                       {
!                               char match;
!                               while(length > 0)
!                               {
!                                       match = pattern[offset];
!                                       if(length > 2 && pattern[offset + 1] == 
'-')
!                                       {
!                                               // Match against a character 
range.
!                                               if(compare.Compare(source, 
posn, 1,
!                                                                               
   pattern, offset, 1,
!                                                                               
   CompareOptions.IgnoreCase |
!                                                                               
   CompareOptions.IgnoreNonSpace |
!                                                                               
   CompareOptions.IgnoreKanaType |
!                                                                               
   CompareOptions.IgnoreWidth) >= 0 &&
!                                                  compare.Compare(source, 
posn, 1,
!                                                                               
   pattern, offset + 2, 1,
!                                                                               
   CompareOptions.IgnoreCase |
!                                                                               
   CompareOptions.IgnoreNonSpace |
!                                                                               
   CompareOptions.IgnoreKanaType |
!                                                                               
   CompareOptions.IgnoreWidth) <= 0)
!                                               {
!                                                       return true;
!                                               }
!                                               offset += 2;
!                                               length -= 2;
!                                       }
!                                       else
!                                       {
!                                               // Match against a single 
character.
!                                               if(compare.Compare(source, 
posn, 1,
!                                                                               
   pattern, offset, 1,
!                                                                               
   CompareOptions.IgnoreCase |
!                                                                               
   CompareOptions.IgnoreNonSpace |
!                                                                               
   CompareOptions.IgnoreKanaType |
!                                                                               
   CompareOptions.IgnoreWidth) == 0)
!                                               {
!                                                       return true;
!                                               }
!                                       }
!                                       ++offset;
!                                       --length;
!                               }
                                return false;
                        }

Index: Utils.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Basic/CompilerServices/Utils.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Utils.cs    16 May 2003 05:35:00 -0000      1.1
--- Utils.cs    22 May 2003 02:24:09 -0000      1.2
***************
*** 27,30 ****
--- 27,32 ----
  using System.Reflection;
  using System.Globalization;
+ using System.Threading;
+ using System.Text;
  
  [StandardModule]
***************
*** 36,67 ****
  
        // Copy the contents of an array.
-       [TODO]
        public static Array CopyArray(Array arySrc, Array aryDest)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Convert a method name into a string, using VB-style syntax.
-       [TODO]
        public static String MethodToString(MethodBase Method)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Set the culture information to use.
-       [TODO]
        public static Object SetCultureInfo(CultureInfo Culture)
                        {
!                               // TODO
!                               return null;
                        }
  
!       // Throw an exception by HRESULT.
!       [TODO]
        public static void ThrowException(int hr)
                        {
!                               // TODO
                        }
  
--- 38,350 ----
  
        // Copy the contents of an array.
        public static Array CopyArray(Array arySrc, Array aryDest)
                        {
!                               if(arySrc != null)
!                               {
!                                       // Check that the arrays have the same 
rank and dimensions.
!                                       int rank = arySrc.Rank;
!                                       if(rank != aryDest.Rank)
!                                       {
!                                               ThrowException
!                                                       (new 
InvalidCastException
!                                                               
(S._("VB_MismatchedRanks")));
!                                       }
!                                       for(int dim = 0; dim < rank; ++dim)
!                                       {
!                                               if(arySrc.GetUpperBound(dim) !=
!                                                  aryDest.GetUpperBound(dim))
!                                               {
!                                                       ThrowException
!                                                               (new 
ArrayTypeMismatchException
!                                                                       
(S._("VB_MismatchedDimensions")));
!                                               }
!                                       }
!                                       Array.Copy(arySrc, aryDest, 
arySrc.Length);
!                               }
!                               return aryDest;
!                       }
! 
!       // Append the VB form of a type name to a string builder.
!       internal static void AppendType(StringBuilder builder, Type type)
!                       {
!                               if(type == typeof(System.Byte))
!                               {
!                                       builder.Append("Byte");
!                               }
!                               else if(type == typeof(System.Int16))
!                               {
!                                       builder.Append("Short");
!                               }
!                               else if(type == typeof(System.Int32))
!                               {
!                                       builder.Append("Integer");
!                               }
!                               else if(type == typeof(System.Int64))
!                               {
!                                       builder.Append("Long");
!                               }
!                               else if(type == typeof(System.Single))
!                               {
!                                       builder.Append("Single");
!                               }
!                               else if(type == typeof(System.Double))
!                               {
!                                       builder.Append("Double");
!                               }
!                               else if(type == typeof(System.Boolean))
!                               {
!                                       builder.Append("Boolean");
!                               }
!                               else if(type == typeof(System.Char))
!                               {
!                                       builder.Append("Char");
!                               }
!                               else if(type == typeof(System.String))
!                               {
!                                       builder.Append("String");
!                               }
!                               else if(type == typeof(System.DateTime))
!                               {
!                                       builder.Append("Date");
!                               }
!                               else if(type == typeof(System.Decimal))
!                               {
!                                       builder.Append("Decimal");
!                               }
!                               else if(type == typeof(System.Object))
!                               {
!                                       builder.Append("Object");
!                               }
!                               else if(type.IsArray)
!                               {
!                                       Type elemType = type.GetElementType();
!                                       while(elemType.IsArray)
!                                       {
!                                               elemType = 
elemType.GetElementType();
!                                       }
!                                       AppendType(builder, elemType);
!                                       int rank;
!                                       while(type != elemType)
!                                       {
!                                               builder.Append('(');
!                                               int rank = type.GetArrayRank();
!                                               while(rank > 1)
!                                               {
!                                                       builder.Append(',');
!                                                       --rank;
!                                               }
!                                               builder.Append(')');
!                                               type = type.GetElementType();
!                                       }
!                               }
!                               else
!                               {
!                                       builder.Append(type.FullName);
!                               }
                        }
  
        // Convert a method name into a string, using VB-style syntax.
        public static String MethodToString(MethodBase Method)
                        {
!                               bool isCtor;
!                               Type returnType;
! 
!                               // Determine if the method is a constructor and 
get
!                               // the return type if it isn't.
!                               if(Method is ConstructorInfo)
!                               {
!                                       isCtor = true;
!                                       returnType = typeof(Void);
!                               }
!                               else
!                               {
!                                       isCtor = false;
!                                       returnType = 
((MethodInfo)Method).ReturnType;
!                               }
! 
!                               // Create a string builder and output the 
access level.
!                               StringBuilder builder = new StringBuilder();
!                               if(Method.IsVirtual)
!                               {
!                                       if(Method.DeclaringType.IsInterface)
!                                       {
!                                               builder.Append("Overrides ");
!                                       }
!                               }
!                               switch(Method.Attributes & 
MethodAttributes.MemberAccessMask)
!                               {
!                                       case MethodAttributes.Private:
!                                               builder.Append("Private "); 
break;
! 
!                                       case MethodAttributes.Assembly:
!                                               builder.Append("Friend "); 
break;
! 
!                                       case MethodAttributes.Family:
!                                               builder.Append("Protected "); 
break;
! 
!                                       case MethodAttributes.FamORAssem:
!                                               builder.Append("Protected 
Friend "); break;
! 
!                                       case MethodAttributes.Public:
!                                               builder.Append("Public "); 
break;
!                               }
! 
!                               // Output the method kind and its name.
!                               if(isCtor)
!                               {
!                                       builder.Append("Sub New ");
!                               }
!                               else if(returnType == typeof(Void))
!                               {
!                                       builder.Append("Sub ");
!                               }
!                               else
!                               {
!                                       builder.Append("Function ");
!                               }
!                               builder.Append(Method.Name);
! 
!                               // Output the method parameters.
!                               ParameterInfo[] parameters = 
Method.GetParameters();
!                               int index;
!                               Type type;
!                               String name;
!                               Object value;
!                               builder.Append(" (");
!                               for(index = 0; index < parameters.Length; 
++index)
!                               {
!                                       if(index > 0)
!                                       {
!                                               builder.Append(", ");
!                                       }
!                                       type = parameters[index].ParameterType;
!                                       if(parameters[index].IsOptional)
!                                       {
!                                               builder.Append("Optional ");
!                                       }
!                                       if(type.IsByRef)
!                                       {
!                                               builder.Append("ByRef ");
!                                       }
!                                       else
!                                       {
!                                               builder.Append("ByVal ");
!                                       }
!                                       if(type.IsArray && 
parameters[index].IsDefined
!                                                       
(typeof(ParamArrayAttribute), false))
!                                       {
!                                               builder.Append("ParamArray ");
!                                       }
!                                       name = parameters[index].Name;
!                                       if(name != null)
!                                       {
!                                               builder.Append(name);
!                                       }
!                                       else
!                                       {
!                                               
builder.Append(String.Format("_p{0}", index));
!                                       }
!                                       builder.Append(" As ");
!                                       AppendType(builder, returnType);
!                                       if(parameters[index].IsOptional)
!                                       {
!                                               builder.Append(" = ");
!                                               value = 
parameters[index].DefaultValue;
!                                               if(value != null)
!                                               {
!                                                       if(value is String)
!                                                       {
!                                                               
builder.Append('"');
!                                                               
builder.Append(value);
!                                                               
builder.Append('"');
!                                                       }
!                                                       else
!                                                       {
!                                                               
builder.Append(value.ToString());
!                                                       }
!                                               }
!                                               else
!                                               {
!                                                       
builder.Append("Nothing");
!                                               }
!                                       }
!                               }
!                               builder.Append(")");
! 
!                               // Output the return type for functions.
!                               if(returnType != typeof(Void))
!                               {
!                                       builder.Append(" As ");
!                                       AppendType(builder, returnType);
!                               }
! 
!                               // Return the final string to the caller.
!                               return builder.ToString();
                        }
  
        // Set the culture information to use.
        public static Object SetCultureInfo(CultureInfo Culture)
                        {
!                               CultureInfo prev = CultureInfo.CurrentCulture;
!                               Thread.CurrentThread.CurrentCulture = Culture;
!                               return prev;
                        }
  
!       // Throw an exception by number.
        public static void ThrowException(int hr)
                        {
!                               Exception exception =
!                                       ErrObject.CreateExceptionFromNumber(hr, 
null);
!                               SetErrorNumber(hr);
!                               throw exception;
!                       }
! 
!       // Throw a particular exception, after setting the error number.
!       internal static void ThrowException(Exception exception)
!                       {
!                               
SetErrorNumber(ErrObject.GetNumberForException(exception));
!                               throw exception;
!                       }
! 
!       // Set a particular error number in the program's error object.
!       private static void SetErrorNumber(int number)
!                       {
!                               ErrObject error = Information.Err();
!                               error.Clear();
!                               error.Number = number;
!                       }
! 
!       // Full width digit characters.
!       private static char[] fullWidthDigits =
!                       {'\uFF10', '\uFF11', '\uFF12', '\uFF13', '\uFF14',
!                        '\uFF15', '\uFF16', '\uFF17', '\uFF18', '\uFF19'};
! 
!       // Convert full-width digit characters into half-width digits.
!       // This is useful in CJK locales where it is common for users to
!       // expect that full-width forms of digits can be used interchangeably
!       // with half-width forms.
!       internal static String FixDigits(String str)
!                       {
!                               if(str == null)
!                               {
!                                       return null;
!                               }
!                               if(str.IndexOfAny(fullWidthDigits) == -1)
!                               {
!                                       return str;
!                               }
!                               StringBuilder builder = new 
StringBuilder(str.Length);
!                               foreach(char ch in str)
!                               {
!                                       if(ch >= '\uFF10' && ch <= '\uFF19')
!                                       {
!                                               builder.Append((char)(ch - 
(0xFF10 + 0x0030)));
!                                       }
!                                       else
!                                       {
!                                               builder.Append(ch);
!                                       }
!                               }
!                               return builder.ToString();
                        }
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]