2
0
Эх сурвалжийг харах

Some late-night patch commits for Miguel.

* TabPage.cs (constructor): added a constructor for constructing tab
pages with a title. Patch from Jonathan Hogg
<[email protected]>.

* EnumConverter.cs (ConvertFrom): Removed the special handling for
multiple values. This is done in Enum.Parse already.

* TypeDescriptor.cs (GetConverter): Does not work for enumeration
types because EnumConverter does not have a default
constructor. Fixed by changing the special handling for
enumeration types.

svn path=/trunk/mcs/; revision=18074
Duncan Mak 22 жил өмнө
parent
commit
45d8f67e10

+ 5 - 0
mcs/class/System.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,3 +1,8 @@
+2003-09-13  Duncan Mak  <[email protected]>
+
+	* TabPage.cs (constructor): added a constructor for constructing
+	tab pages with a title. Patch from Jonathan Hogg
+	<[email protected]>.
 
 2003-09-01  Dennis Hayes <[email protected]>
 	* Application.cs

+ 4 - 0
mcs/class/System.Windows.Forms/System.Windows.Forms/TabPage.cs

@@ -39,6 +39,10 @@ namespace System.Windows.Forms {
 			imageIndex = -1;
 		}
 
+		public TabPage (string textValue) : this() {
+			text = textValue;
+		}
+
 		[EditorBrowsable (EditorBrowsableState.Never)]	 
 		public override AnchorStyles Anchor {
 			get {	return base.Anchor; }

+ 13 - 0
mcs/class/System/System.ComponentModel/ChangeLog

@@ -1,3 +1,16 @@
+2003-09-13  Duncan Mak  <[email protected]>
+
+	Patch from Jörg Rosenkranz <[email protected]>, this fixes the
+	bugs described in bug #48351.
+
+	* EnumConverter.cs (ConvertFrom): Removed the special handling for
+	multiple values. This is done in Enum.Parse already.
+
+	* TypeDescriptor.cs (GetConverter): Does not work for enumeration
+	types because EnumConverter does not have a default
+	constructor. Fixed by changing the special handling for
+	enumeration types.
+
 2003-08-31  Jerome Laban <[email protected]>
         * Container.cs: A site without name cannot be duplicate.
 

+ 1 - 7
mcs/class/System/System.ComponentModel/EnumConverter.cs

@@ -57,13 +57,7 @@ namespace System.ComponentModel
 			if (val == null)
 				return base.ConvertFrom(context, culture, value);
 
-			string [] subValues = val.Split (new char [] {','});
-					
-			long longResult = 0;
-			foreach (string s in subValues)
-				longResult |= (long) Enum.Parse (type, s, true);
-
-			return Enum.ToObject (type, longResult);
+			return Enum.Parse (type, val, true);
 		}
 
 		public override bool IsValid (ITypeDescriptorContext context, object value)

+ 25 - 28
mcs/class/System/System.ComponentModel/TypeDescriptor.cs

@@ -195,7 +195,6 @@ public sealed class TypeDescriptor
 				defaultConverters.Add (typeof (Array), typeof (ArrayConverter));
 				defaultConverters.Add (typeof (CultureInfo), typeof (CultureInfoConverter));
 				defaultConverters.Add (typeof (DateTime), typeof (DateTimeConverter));
-				defaultConverters.Add (typeof (Enum), typeof (EnumConverter));
 				defaultConverters.Add (typeof (Guid), typeof (GuidConverter));
 				defaultConverters.Add (typeof (TimeSpan), typeof (TimeSpanConverter));
 				defaultConverters.Add (typeof (ICollection), typeof (CollectionConverter));
@@ -208,38 +207,36 @@ public sealed class TypeDescriptor
 	
 	public static TypeConverter GetConverter (Type type)
 	{
-		Type t = DefaultConverters [type] as Type;
-		string converter_name = null;
-		if (t == null) {
-			object [] attrs = type.GetCustomAttributes (false);
-			foreach (object o in attrs){
-				if (o is TypeConverterAttribute){
-					TypeConverterAttribute tc = (TypeConverterAttribute) o;
-					converter_name = tc.ConverterTypeName;
-					break;
+		if (type.IsEnum) {
+			// EnumConverter needs to know the enum type
+			return new EnumConverter(type);
+		} else {
+			Type t = DefaultConverters [type] as Type;
+			string converter_name = null;
+			if (t == null) {
+				object [] attrs = type.GetCustomAttributes (false);
+				foreach (object o in attrs){
+					if (o is TypeConverterAttribute){
+						TypeConverterAttribute tc = (TypeConverterAttribute) o;
+						converter_name = tc.ConverterTypeName;
+						break;
+					}
 				}
-			}
-
-			if (converter_name == null && type.IsEnum) {
-				t = (Type) DefaultConverters [typeof (Enum)];
+			} else {
 				converter_name = t.FullName;
 			}
-
-		} else {
-			converter_name = t.FullName;
-		}
+	
+			if (converter_name == null)
+				return null;
+	
+			object converter = null;
+			try {
+				converter = Activator.CreateInstance (Type.GetType (converter_name));
+			} catch (Exception){
+			}
 		
-
-		if (converter_name == null)
-			return null;
-
-		object converter = null;
-		try {
-			converter = Activator.CreateInstance (Type.GetType (converter_name));
-		} catch (Exception){
+			return converter as TypeConverter;
 		}
-	
-		return converter as TypeConverter;
 	}
 
 	[MonoTODO]