[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/System/ComponentModel EnumConverter.
From: |
Gopal.V <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/System/ComponentModel EnumConverter.cs,1.2,1.3 |
Date: |
Wed, 01 Jan 2003 13:29:22 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System/ComponentModel
In directory subversions:/tmp/cvs-serv13653/System/ComponentModel
Modified Files:
EnumConverter.cs
Log Message:
Patch #905 for System.ComponentModel namespace
Index: EnumConverter.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/ComponentModel/EnumConverter.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** EnumConverter.cs 31 Dec 2002 06:40:28 -0000 1.2
--- EnumConverter.cs 1 Jan 2003 18:29:20 -0000 1.3
***************
*** 29,50 ****
public class EnumConverter: TypeConverter
{
! [TODO]
public EnumConverter(Type type)
{
! throw new NotImplementedException(".ctor");
}
- [TODO]
public override bool CanConvertFrom(ITypeDescriptorContext
context,
Type sourceType)
{
! throw new NotImplementedException("CanConvertFrom");
}
- [TODO]
public override bool CanConvertTo(ITypeDescriptorContext
context,
Type destinationType)
{
! throw new NotImplementedException("CanConvertTo");
}
--- 29,53 ----
public class EnumConverter: TypeConverter
{
! private Type type;
!
public EnumConverter(Type type)
{
! this.type = type;
}
public override bool CanConvertFrom(ITypeDescriptorContext
context,
Type sourceType)
{
! if (sourceType == typeof(string))
! return true;
! /* TODO: Find a better way ? */
! return base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext
context,
Type destinationType)
{
! /* TODO: Find a better way ? */
! return base.CanConvertTo(context, destinationType);
}
***************
*** 53,71 ****
CultureInfo culture, Object value)
{
! throw new NotImplementedException("ConvertFrom");
! }
! [TODO]
public override Object ConvertTo(ITypeDescriptorContext
context,
CultureInfo culture, Object value, Type
destinationType)
{
! throw new NotImplementedException("ConvertTo");
}
- [TODO]
public override bool IsValid(ITypeDescriptorContext context,
Object
value)
{
! throw new NotImplementedException("IsValid");
}
--- 56,92 ----
CultureInfo culture, Object value)
{
! /* TODO: Find a better way ? */
! string val = value as string;
! if (val == null)
! return base.ConvertFrom(context, culture,
value);
! string[] values = val.Split(new char[] {','});
! int j;
! IList vals = (IList) Enum.GetValues(this.type);
! foreach (string s in values)
! {
! for (j=0; j<vals.Count; j++)
! {
! if (s == vals[j].ToString())
! return Enum.ToObject(type, j);
! }
! }
! return Enum.ToObject(type, -1); // not a valid enum
string, throw an exception? which one?
! }
!
!
public override Object ConvertTo(ITypeDescriptorContext
context,
CultureInfo culture, Object value, Type
destinationType)
{
! /* TODO: Find a better way ? */
! if (destinationType == typeof(string))
! return value.ToString();
! return base.ConvertTo(context, culture, value,
destinationType);
}
public override bool IsValid(ITypeDescriptorContext context,
Object
value)
{
! return Enum.IsDefined(type, value);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/System/ComponentModel EnumConverter.cs,1.2,1.3,
Gopal.V <address@hidden> <=