Răsfoiți Sursa

2004-07-03 Zoltan Varga <[email protected]>

	* Module.cs: Initialize FilterTypeName[IgnoreCase]. Fixes #61048.

svn path=/trunk/mcs/; revision=30662
Zoltan Varga 21 ani în urmă
părinte
comite
45d0bc41e7

+ 4 - 0
mcs/class/corlib/System.Reflection/ChangeLog

@@ -1,3 +1,7 @@
+2004-07-03  Zoltan Varga  <[email protected]>
+
+	* Module.cs: Initialize FilterTypeName[IgnoreCase]. Fixes #61048.
+
 2004-06-17  Gert Driesen <[email protected]>
 
 	* Pointer.cs: remove serializable attribute to match MS.NET

+ 21 - 0
mcs/class/corlib/System.Reflection/Module.cs

@@ -55,6 +55,11 @@ namespace System.Reflection {
 		const BindingFlags defaultBindingFlags = 
 			BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance;
 		
+		static Module () {
+			FilterTypeName = new TypeFilter (filter_by_type_name);
+			FilterTypeNameIgnoreCase = new TypeFilter (filter_by_type_name_ignore_case);
+		}
+
 		internal Module () { }
 
 		~Module () {
@@ -215,6 +220,22 @@ namespace System.Reflection {
 			return new Guid (GetGuidInternal ());
 		}
 
+		private static bool filter_by_type_name (Type m, object filterCriteria) {
+			string s = (string)filterCriteria;
+			if (s.EndsWith ("*"))
+				return m.Name.StartsWith (s.Substring (0, s.Length - 1));
+			else
+				return m.Name == s;
+		}
+
+		private static bool filter_by_type_name_ignore_case (Type m, object filterCriteria) {
+			string s = (string)filterCriteria;
+			if (s.EndsWith ("*"))
+				return m.Name.ToLower ().StartsWith (s.Substring (0, s.Length - 1).ToLower ());
+			else
+				return String.Compare (m.Name, s, true) == 0;
+		}
+
 		[MethodImplAttribute (MethodImplOptions.InternalCall)]
 		private extern string GetGuidInternal ();