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

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

[Dotgnu-pnet-commits] CVS: pnetlib/System/ComponentModel BooleanConverte


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System/ComponentModel BooleanConverter.cs, NONE, 1.1 ByteConverter.cs, NONE, 1.1 DecimalConverter.cs, NONE, 1.1 DoubleConverter.cs, NONE, 1.1 Int16Converter.cs, NONE, 1.1 Int64Converter.cs, NONE, 1.1 RunInstallerAttribute.cs, NONE, 1.1 SByteConverter.cs, NONE, 1.1 SingleConverter.cs, NONE, 1.1 UInt16Converter.cs, NONE, 1.1 UInt32Converter.cs, NONE, 1.1 UInt64Converter.cs, NONE, 1.1 BaseNumberConverter.cs, 1.4, 1.5 Int32Converter.cs, 1.3, 1.4 StringConverter.cs, 1.3, 1.4
Date: Thu, 07 Aug 2003 02:34:32 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/System/ComponentModel
In directory subversions:/tmp/cvs-serv18267/System/ComponentModel

Modified Files:
        BaseNumberConverter.cs Int32Converter.cs StringConverter.cs 
Added Files:
        BooleanConverter.cs ByteConverter.cs DecimalConverter.cs 
        DoubleConverter.cs Int16Converter.cs Int64Converter.cs 
        RunInstallerAttribute.cs SByteConverter.cs SingleConverter.cs 
        UInt16Converter.cs UInt32Converter.cs UInt64Converter.cs 
Log Message:


Implement number conversion routines in "System.ComponentModel".


--- NEW FILE ---
/*
 * BooleanConverter.cs - Implementation of the
 *              "System.ComponentModel.ComponentModel.BooleanConverter" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.ComponentModel
{

#if CONFIG_COMPONENT_MODEL

using System;
using System.Collections;
using System.Globalization;

public class BooleanConverter : TypeConverter
{
        // Constructor.
        public BooleanConverter()
                        {
                                // Nothing to do here.
                        }

        // Determine if we can convert from a specific type to this one.
        public override bool CanConvertFrom
                                (ITypeDescriptorContext context, Type 
sourceType)
                        {
                                if(sourceType == typeof(String))
                                {
                                        return true;
                                }
                                else
                                {
                                        return base.CanConvertFrom(context, 
sourceType);
                                }
                        }

        // Convert from another type to the one represented by this class.
        public override Object ConvertFrom(ITypeDescriptorContext context,
                                                                           
CultureInfo culture,
                                                                           
Object value)
                        {
                                if(value is String)
                                {
                                        return Boolean.Parse((String)value);
                                }
                                else
                                {
                                        return base.ConvertFrom(context, 
culture, value);
                                }
                        }

        // Return a collection of standard values for this data type.
        public override StandardValuesCollection GetStandardValues
                                (ITypeDescriptorContext context)
                        {
                                return new StandardValuesCollection
                                        (new Object [] {true, false});
                        }

        // Determine if the list of standard values is an exclusive list.
        public override bool GetStandardValuesExclusive
                                (ITypeDescriptorContext context)
                        {
                                return true;
                        }

        // Determine if "GetStandardValues" is supported.
        public override bool GetStandardValuesSupported
                                (ITypeDescriptorContext context)
                        {
                                return true;
                        }

}; // class BooleanConverter

#endif // CONFIG_COMPONENT_MODEL

}; // namespace System.ComponentModel

--- NEW FILE ---
/*
 * ByteConverter.cs - Implementation of the
 *              "System.ComponentModel.ComponentModel.ByteConverter" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.ComponentModel
{

#if CONFIG_COMPONENT_MODEL

using System;
using System.Collections;
using System.Globalization;

public class ByteConverter : BaseNumberConverter
{
        // Constructor.
        public ByteConverter()
                        {
                                // Nothing to do here.
                        }

        // Internal conversion from a string.
        internal override Object DoConvertFrom(String value, NumberFormatInfo 
nfi)
                        {
                                return Byte.Parse(value, NumberStyles.Integer, 
nfi);
                        }
        internal override Object DoConvertFromHex(String value)
                        {
                                return Convert.ToByte(value, 16);
                        }

        // Internal convert to a string.
        internal override String DoConvertTo(Object value, NumberFormatInfo nfi)
                        {
                                return ((byte)value).ToString(null, nfi);
                        }

}; // class ByteConverter

#endif // CONFIG_COMPONENT_MODEL

}; // namespace System.ComponentModel

--- NEW FILE ---
/*
 * DecimalConverter.cs - Implementation of the
 *              "System.ComponentModel.ComponentModel.DecimalConverter" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.ComponentModel
{

#if CONFIG_COMPONENT_MODEL

using System;
using System.Collections;
using System.Globalization;
using System.ComponentModel.Design.Serialization;

public class DecimalConverter : BaseNumberConverter
{
        // Constructor.
        public DecimalConverter()
                        {
                                // Nothing to do here.
                        }

        // Internal conversion from a string.
        internal override Object DoConvertFrom(String value, NumberFormatInfo 
nfi)
                        {
                                return Decimal.Parse(value, NumberStyles.Float, 
nfi);
                        }

        // Internal convert to a string.
        internal override String DoConvertTo(Object value, NumberFormatInfo nfi)
                        {
                                return ((Decimal)value).ToString(null, nfi);
                        }

        // Determine if we can convert from this type to a specific type.
        public override bool CanConvertTo
                                (ITypeDescriptorContext context, Type 
destinationType)
                        {
                        #if CONFIG_COMPONENT_MODEL_DESIGN
                                if(destinationType == 
typeof(InstanceDescriptor))
                                {
                                        return true;
                                }
                                else
                        #endif
                                {
                                        return base.CanConvertTo(context, 
destinationType);
                                }
                        }

        // Convert this object into another type.
        [TODO]
        public override Object ConvertTo(ITypeDescriptorContext context,
                                                                         
CultureInfo culture,
                                                                         Object 
value, Type destinationType)
                        {
                                if(destinationType == null)
                                {
                                        throw new 
ArgumentNullException("destinationType");
                                }
                        #if CONFIG_COMPONENT_MODEL_DESIGN
                                if(destinationType == 
typeof(InstanceDescriptor))
                                {
                                        // TODO
                                        return null;
                                }
                                else
                        #endif
                                {
                                        return base.ConvertTo(context, culture, 
value,
                                                                                
  destinationType);
                                }
                        }

}; // class DecimalConverter

#endif // CONFIG_COMPONENT_MODEL

}; // namespace System.ComponentModel

--- NEW FILE ---
/*
 * DoubleConverter.cs - Implementation of the
 *              "System.ComponentModel.ComponentModel.DoubleConverter" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.ComponentModel
{

#if CONFIG_COMPONENT_MODEL

using System;
using System.Collections;
using System.Globalization;

public class DoubleConverter : BaseNumberConverter
{
        // Constructor.
        public DoubleConverter()
                        {
                                // Nothing to do here.
                        }

        // Internal conversion from a string.
        internal override Object DoConvertFrom(String value, NumberFormatInfo 
nfi)
                        {
                                return Double.Parse(value, NumberStyles.Float, 
nfi);
                        }

        // Internal convert to a string.
        internal override String DoConvertTo(Object value, NumberFormatInfo nfi)
                        {
                                return ((double)value).ToString(null, nfi);
                        }

}; // class DoubleConverter

#endif // CONFIG_COMPONENT_MODEL

}; // namespace System.ComponentModel

--- NEW FILE ---
/*
 * Int16Converter.cs - Implementation of the
 *              "System.ComponentModel.ComponentModel.Int16Converter" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.ComponentModel
{

#if CONFIG_COMPONENT_MODEL

using System;
using System.Collections;
using System.Globalization;

public class Int16Converter : BaseNumberConverter
{
        // Constructor.
        public Int16Converter()
                        {
                                // Nothing to do here.
                        }

        // Internal conversion from a string.
        internal override Object DoConvertFrom(String value, NumberFormatInfo 
nfi)
                        {
                                return Int16.Parse(value, NumberStyles.Integer, 
nfi);
                        }
        internal override Object DoConvertFromHex(String value)
                        {
                                return Convert.ToInt16(value, 16);
                        }

        // Internal convert to a string.
        internal override String DoConvertTo(Object value, NumberFormatInfo nfi)
                        {
                                return ((short)value).ToString(null, nfi);
                        }

}; // class Int16Converter

#endif // CONFIG_COMPONENT_MODEL

}; // namespace System.ComponentModel

--- NEW FILE ---
/*
 * Int64Converter.cs - Implementation of the
 *              "System.ComponentModel.ComponentModel.Int64Converter" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.ComponentModel
{

#if CONFIG_COMPONENT_MODEL

using System;
using System.Collections;
using System.Globalization;

public class Int64Converter : BaseNumberConverter
{
        // Constructor.
        public Int64Converter()
                        {
                                // Nothing to do here.
                        }

        // Internal conversion from a string.
        internal override Object DoConvertFrom(String value, NumberFormatInfo 
nfi)
                        {
                                return Int64.Parse(value, NumberStyles.Integer, 
nfi);
                        }
        internal override Object DoConvertFromHex(String value)
                        {
                                return Convert.ToInt64(value, 16);
                        }

        // Internal convert to a string.
        internal override String DoConvertTo(Object value, NumberFormatInfo nfi)
                        {
                                return ((long)value).ToString(null, nfi);
                        }

}; // class Int64Converter

#endif // CONFIG_COMPONENT_MODEL

}; // namespace System.ComponentModel

--- NEW FILE ---
/*
 * RunInstallerAttribute.cs - Implementation of the
 *              "System.ComponentModel.RunInstallerAttribute" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.ComponentModel
{

#if !ECMA_COMPAT

using System;

[AttributeUsage(AttributeTargets.Class)]
public class RunInstallerAttribute : Attribute
{
        // Internal state.
        private bool runInstaller;

        // Builtin attribute values.
        public static readonly RunInstallerAttribute No
                        = new RunInstallerAttribute(false);
        public static readonly RunInstallerAttribute Yes
                        = new RunInstallerAttribute(true);

        // Constructor.
        public RunInstallerAttribute(bool runInstaller)
                        {
                                this.runInstaller = runInstaller;
                        }

        // Determine if the installer should be run.
        public bool RunInstaller
                        {
                                get
                                {
                                        return runInstaller;
                                }
                        }

        // Determine if two object are equal.
        public override bool Equals(Object obj)
                        {
                                RunInstallerAttribute other = (obj as 
RunInstallerAttribute);
                                if(other != null)
                                {
                                        return (other.runInstaller == 
runInstaller);
                                }
                                else
                                {
                                        return false;
                                }
                        }

        // Get the hash code for this object.
        public override int GetHashCode()
                        {
                                return (runInstaller ? 1 : 0);
                        }

        // Determine if this is a default attribute value.
        public override bool IsDefaultAttribute()
                        {
                                return !runInstaller;
                        }

}; // class RunInstallerAttribute

#endif // !ECMA_COMPAT

}; // namespace System.ComponentModel

--- NEW FILE ---
/*
 * SByteConverter.cs - Implementation of the
 *              "System.ComponentModel.ComponentModel.SByteConverter" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.ComponentModel
{

#if CONFIG_COMPONENT_MODEL

using System;
using System.Collections;
using System.Globalization;

public class SByteConverter : BaseNumberConverter
{
        // Constructor.
        public SByteConverter()
                        {
                                // Nothing to do here.
                        }

        // Internal conversion from a string.
        internal override Object DoConvertFrom(String value, NumberFormatInfo 
nfi)
                        {
                                return SByte.Parse(value, NumberStyles.Integer, 
nfi);
                        }
        internal override Object DoConvertFromHex(String value)
                        {
                                return Convert.ToSByte(value, 16);
                        }

        // Internal convert to a string.
        internal override String DoConvertTo(Object value, NumberFormatInfo nfi)
                        {
                                return ((sbyte)value).ToString(null, nfi);
                        }

}; // class SByteConverter

#endif // CONFIG_COMPONENT_MODEL

}; // namespace System.ComponentModel

--- NEW FILE ---
/*
 * SingleConverter.cs - Implementation of the
 *              "System.ComponentModel.ComponentModel.SingleConverter" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.ComponentModel
{

#if CONFIG_COMPONENT_MODEL

using System;
using System.Collections;
using System.Globalization;

public class SingleConverter : BaseNumberConverter
{
        // Constructor.
        public SingleConverter()
                        {
                                // Nothing to do here.
                        }

        // Internal conversion from a string.
        internal override Object DoConvertFrom(String value, NumberFormatInfo 
nfi)
                        {
                                return Single.Parse(value, NumberStyles.Float, 
nfi);
                        }

        // Internal convert to a string.
        internal override String DoConvertTo(Object value, NumberFormatInfo nfi)
                        {
                                return ((float)value).ToString(null, nfi);
                        }

}; // class SingleConverter

#endif // CONFIG_COMPONENT_MODEL

}; // namespace System.ComponentModel

--- NEW FILE ---
/*
 * UInt16Converter.cs - Implementation of the
 *              "System.ComponentModel.ComponentModel.UInt16Converter" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.ComponentModel
{

#if CONFIG_COMPONENT_MODEL

using System;
using System.Collections;
using System.Globalization;

public class UInt16Converter : BaseNumberConverter
{
        // Constructor.
        public UInt16Converter()
                        {
                                // Nothing to do here.
                        }

        // Internal conversion from a string.
        internal override Object DoConvertFrom(String value, NumberFormatInfo 
nfi)
                        {
                                return UInt16.Parse(value, 
NumberStyles.Integer, nfi);
                        }
        internal override Object DoConvertFromHex(String value)
                        {
                                return Convert.ToUInt16(value, 16);
                        }

        // Internal convert to a string.
        internal override String DoConvertTo(Object value, NumberFormatInfo nfi)
                        {
                                return ((ushort)value).ToString(null, nfi);
                        }

}; // class UInt16Converter

#endif // CONFIG_COMPONENT_MODEL

}; // namespace System.ComponentModel

--- NEW FILE ---
/*
 * UInt32Converter.cs - Implementation of the
 *              "System.ComponentModel.ComponentModel.UInt32Converter" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.ComponentModel
{

#if CONFIG_COMPONENT_MODEL

using System;
using System.Collections;
using System.Globalization;

public class UInt32Converter : BaseNumberConverter
{
        // Constructor.
        public UInt32Converter()
                        {
                                // Nothing to do here.
                        }

        // Internal conversion from a string.
        internal override Object DoConvertFrom(String value, NumberFormatInfo 
nfi)
                        {
                                return UInt32.Parse(value, 
NumberStyles.Integer, nfi);
                        }
        internal override Object DoConvertFromHex(String value)
                        {
                                return Convert.ToUInt32(value, 32);
                        }

        // Internal convert to a string.
        internal override String DoConvertTo(Object value, NumberFormatInfo nfi)
                        {
                                return ((uint)value).ToString(null, nfi);
                        }

}; // class UInt32Converter

#endif // CONFIG_COMPONENT_MODEL

}; // namespace System.ComponentModel

--- NEW FILE ---
/*
 * UInt64Converter.cs - Implementation of the
 *              "System.ComponentModel.ComponentModel.UInt64Converter" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.ComponentModel
{

#if CONFIG_COMPONENT_MODEL

using System;
using System.Collections;
using System.Globalization;

public class UInt64Converter : BaseNumberConverter
{
        // Constructor.
        public UInt64Converter()
                        {
                                // Nothing to do here.
                        }

        // Internal conversion from a string.
        internal override Object DoConvertFrom(String value, NumberFormatInfo 
nfi)
                        {
                                return UInt64.Parse(value, 
NumberStyles.Integer, nfi);
                        }
        internal override Object DoConvertFromHex(String value)
                        {
                                return Convert.ToUInt64(value, 64);
                        }

        // Internal convert to a string.
        internal override String DoConvertTo(Object value, NumberFormatInfo nfi)
                        {
                                return ((ulong)value).ToString(null, nfi);
                        }

}; // class UInt64Converter

#endif // CONFIG_COMPONENT_MODEL

}; // namespace System.ComponentModel

Index: BaseNumberConverter.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/System/ComponentModel/BaseNumberConverter.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** BaseNumberConverter.cs      29 May 2003 05:38:17 -0000      1.4
--- BaseNumberConverter.cs      7 Aug 2003 06:34:29 -0000       1.5
***************
*** 1,10 ****
  /*
!  * BaseNumberConverter.cs - Implementation of 
!  *                    "System.ComponentModel.BaseNumberConverter" class
   *
!  * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
!  * Copyright (C) 2002  Free Software Foundation, Inc.
!  * 
!  * Contributed by Gopal.V 
   *
   * This program is free software; you can redistribute it and/or modify
--- 1,7 ----
  /*
!  * BaseNumberConverter.cs - Implementation of the
!  *            "System.ComponentModel.ComponentModel.BaseNumberConverter" 
class.
   *
!  * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 22,27 ****
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   */
-  
- using System;
  
  namespace System.ComponentModel
--- 19,22 ----
***************
*** 30,39 ****
  #if CONFIG_COMPONENT_MODEL
  
!       public class BaseNumberConverter: TypeConverter
!       {
!               // Constructor - nothing to do.
!               public BaseNumberConverter() {}
! 
!       }
! #endif
! }//namespace
--- 25,142 ----
  #if CONFIG_COMPONENT_MODEL
  
! using System;
! using System.Collections;
! using System.Globalization;
! 
! public abstract class BaseNumberConverter : TypeConverter
! {
!       // Constructor.
!       protected BaseNumberConverter()
!                       {
!                               // Nothing to do here.
!                       }
! 
!       // Determine if we can convert from a specific type to this one.
!       public override bool CanConvertFrom
!                               (ITypeDescriptorContext context, Type 
sourceType)
!                       {
!                               if(sourceType == typeof(String))
!                               {
!                                       return true;
!                               }
!                               else
!                               {
!                                       return base.CanConvertFrom(context, 
sourceType);
!                               }
!                       }
! 
!       // Determine if we can convert from this type to a specific type.
!       public override bool CanConvertTo
!                               (ITypeDescriptorContext context, Type 
destinationType)
!                       {
!                               if(destinationType.IsPrimitive)
!                               {
!                                       return true;
!                               }
!                               else
!                               {
!                                       return base.CanConvertTo(context, 
destinationType);
!                               }
!                       }
! 
!       // Internal conversion from a string.
!       internal abstract Object DoConvertFrom(String value, NumberFormatInfo 
nfi);
!       internal virtual Object DoConvertFromHex(String value)
!                       {
!                               throw new FormatException();
!                       }
! 
!       // Convert from another type to the one represented by this class.
!       public override Object ConvertFrom(ITypeDescriptorContext context,
!                                                                          
CultureInfo culture,
!                                                                          
Object value)
!                       {
!                               String val = (value as String);
!                               if(val != null)
!                               {
!                                       if(val.StartsWith("0x") || 
val.StartsWith("0X") ||
!                                          val.StartsWith("&h") || 
val.StartsWith("&H"))
!                                       {
!                                               return 
DoConvertFromHex(val.Substring(2));
!                                       }
!                                       else if(val.StartsWith("#"))
!                                       {
!                                               return 
DoConvertFromHex(val.Substring(1));
!                                       }
!                                       else
!                                       {
!                                               return DoConvertFrom
!                                                       (val, 
NumberFormatInfo.GetInstance(culture));
!                                       }
!                               }
!                               else
!                               {
!                                       return base.ConvertFrom(context, 
culture, value);
!                               }
!                       }
! 
!       // Internal convert to a string.
!       internal abstract String DoConvertTo(Object value, NumberFormatInfo 
nfi);
! 
!       // Convert this object into another type.
!       public override Object ConvertTo(ITypeDescriptorContext context,
!                                                                        
CultureInfo culture,
!                                                                        Object 
value, Type destinationType)
!                       {
!                               if(destinationType == null)
!                               {
!                                       throw new 
ArgumentNullException("destinationType");
!                               }
!                               if(destinationType == typeof(String))
!                               {
!                                       if(value != null)
!                                       {
!                                               return DoConvertTo
!                                                       (value, 
NumberFormatInfo.GetInstance(culture));
!                                       }
!                                       else
!                                       {
!                                               return String.Empty;
!                                       }
!                               }
!                               else if(destinationType.IsPrimitive)
!                               {
!                                       return Convert.ChangeType(value, 
destinationType);
!                               }
!                               else
!                               {
!                                       return base.ConvertTo(context, culture, 
value,
!                                                                               
  destinationType);
!                               }
!                       }
! 
! }; // class BaseNumberConverter
! 
! #endif // CONFIG_COMPONENT_MODEL
! 
! }; // namespace System.ComponentModel

Index: Int32Converter.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/ComponentModel/Int32Converter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Int32Converter.cs   29 May 2003 05:38:17 -0000      1.3
--- Int32Converter.cs   7 Aug 2003 06:34:30 -0000       1.4
***************
*** 1,7 ****
  /*
!  * Int32Converter.cs - Implementation of 
"System.ComponentModel.Int32Converter" 
   *
!  * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
!  * Copyright (C) 2002  Free Software Foundation,Inc.
   *
   * This program is free software; you can redistribute it and/or modify
--- 1,7 ----
  /*
!  * Int32Converter.cs - Implementation of the
!  *            "System.ComponentModel.ComponentModel.Int32Converter" class.
   *
!  * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 20,37 ****
   */
  
- using System;
- 
  namespace System.ComponentModel
  {
  #if CONFIG_COMPONENT_MODEL
!       public class Int32Converter: BaseNumberConverter
!       {
!               [TODO]
!               public Int32Converter()
!               {
!                       throw new NotImplementedException(".ctor");
!               }
! 
!       }
! #endif        
! }//namespace
--- 20,59 ----
   */
  
  namespace System.ComponentModel
  {
+ 
  #if CONFIG_COMPONENT_MODEL
! 
! using System;
! using System.Collections;
! using System.Globalization;
! 
! public class Int32Converter : BaseNumberConverter
! {
!       // Constructor.
!       public Int32Converter()
!                       {
!                               // Nothing to do here.
!                       }
! 
!       // Internal conversion from a string.
!       internal override Object DoConvertFrom(String value, NumberFormatInfo 
nfi)
!                       {
!                               return Int32.Parse(value, NumberStyles.Integer, 
nfi);
!                       }
!       internal override Object DoConvertFromHex(String value)
!                       {
!                               return Convert.ToInt32(value, 16);
!                       }
! 
!       // Internal convert to a string.
!       internal override String DoConvertTo(Object value, NumberFormatInfo nfi)
!                       {
!                               return ((int)value).ToString(null, nfi);
!                       }
! 
! }; // class Int32Converter
! 
! #endif // CONFIG_COMPONENT_MODEL
! 
! }; // namespace System.ComponentModel

Index: StringConverter.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/System/ComponentModel/StringConverter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** StringConverter.cs  29 May 2003 05:38:17 -0000      1.3
--- StringConverter.cs  7 Aug 2003 06:34:30 -0000       1.4
***************
*** 1,8 ****
  /*
!  * StringConverter.cs - Implementation of 
!  *                                            
"System.ComponentModel.StringConverter" 
   *
!  * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
!  * Copyright (C) 2002  Free Software Foundation,Inc.
   *
   * This program is free software; you can redistribute it and/or modify
--- 1,7 ----
  /*
!  * StringConverter.cs - Implementation of the
!  *            "System.ComponentModel.ComponentModel.StringConverter" class.
   *
!  * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 21,53 ****
   */
  
  using System;
  using System.Globalization;
  
! namespace System.ComponentModel
  {
! #if CONFIG_COMPONENT_MODEL
!       public class StringConverter: TypeConverter
!       {
!               [TODO]
!               public StringConverter()
!               {
!                       throw new NotImplementedException(".ctor");
!               }
! 
!               [TODO]
!               public override bool CanConvertFrom(ITypeDescriptorContext 
context, 
!                                                                               
        Type sourceType)
!               {
!                       throw new NotImplementedException("CanConvertFrom");
!               }
! 
!               [TODO]
!               public override Object ConvertFrom(ITypeDescriptorContext 
context, 
!                                                               CultureInfo 
culture,Object value)
!               {
!                       throw new NotImplementedException("ConvertFrom");
!               }
! 
!       }
! #endif        
! }//namespace
--- 20,76 ----
   */
  
+ namespace System.ComponentModel
+ {
+ 
+ #if CONFIG_COMPONENT_MODEL
+ 
  using System;
+ using System.Collections;
  using System.Globalization;
  
! public class StringConverter : TypeConverter
  {
!       // Constructor.
!       public StringConverter()
!                       {
!                               // Nothing to do here.
!                       }
! 
!       // Determine if we can convert from a specific type to this one.
!       public override bool CanConvertFrom
!                               (ITypeDescriptorContext context, Type 
sourceType)
!                       {
!                               if(sourceType == typeof(String))
!                               {
!                                       return true;
!                               }
!                               else
!                               {
!                                       return base.CanConvertFrom(context, 
sourceType);
!                               }
!                       }
! 
!       // Convert from another type to the one represented by this class.
!       public override Object ConvertFrom(ITypeDescriptorContext context,
!                                                                          
CultureInfo culture,
!                                                                          
Object value)
!                       {
!                               if(value == null)
!                               {
!                                       return String.Empty;
!                               }
!                               else if(value is String)
!                               {
!                                       return (String)value;
!                               }
!                               else
!                               {
!                                       return base.ConvertFrom(context, 
culture, value);
!                               }
!                       }
! 
! }; // class StringConverter
! 
! #endif // CONFIG_COMPONENT_MODEL
! 
! }; // namespace System.ComponentModel





reply via email to

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