Jelajahi Sumber

* Assembly.cs: Removed TODO for CreateQualifiedName.
* AssemblyName.cs: Fixed serialization code.
* AssemblyNameProxy.cs: Implemented.
* Module.cs: Implemented GetMethod() methods, FindTypes() and GetObjectData.

svn path=/trunk/mcs/; revision=25694

Lluis Sanchez 22 tahun lalu
induk
melakukan
b370142742

+ 2 - 2
mcs/class/corlib/System.Reflection/Assembly.cs

@@ -82,6 +82,7 @@ namespace System.Reflection {
 			}
 		}
 
+		[MonoTODO]
 		public bool GlobalAssemblyCache {
 			get {
 				//TODO: if we ever have a GAC, fix this.
@@ -264,10 +265,9 @@ namespace System.Reflection {
 			return GetName ().Name;
 		}
 
-		[MonoTODO]
 		public static String CreateQualifiedName (String assemblyName, String typeName) 
 		{
-			return typeName + "," + assemblyName;
+			return typeName + ", " + assemblyName;
 		}
 
 		public static Assembly GetAssembly (Type type)

+ 26 - 9
mcs/class/corlib/System.Reflection/AssemblyName.cs

@@ -37,6 +37,7 @@ namespace System.Reflection {
 		byte[] publicKey;
 		byte[] keyToken;
 		AssemblyVersionCompatibility versioncompat;
+		Version version;
 		
 		public AssemblyName ()
 		{
@@ -48,7 +49,7 @@ namespace System.Reflection {
 		{
 			name = si.GetString ("_Name");
 			codebase = si.GetString ("_CodeBase");
-			Version = (Version)si.GetValue ("_Version", typeof (Version));
+			version = (Version)si.GetValue ("_Version", typeof (Version));
 		}
 
 		public string Name {
@@ -123,15 +124,19 @@ namespace System.Reflection {
 
 		public Version Version {
 			get {
+				if (version != null) return version;
+				
 				if (name == null)
 					return null;
 				if (build == -1)
-					return new Version (major, minor);
+					version = new Version (major, minor);
 				else
 					if (revision == -1)
-						return new Version (major, minor, build);
+						version = new Version (major, minor, build);
 				else
-					return new Version (major, minor, build, revision);
+					version = new Version (major, minor, build, revision);
+
+				return version;
 			}
 
 			set {
@@ -139,6 +144,7 @@ namespace System.Reflection {
 				minor = value.Minor;
 				build = value.Build;
 				revision = value.Revision;
+				version = value;
 			}
 		}
 
@@ -208,17 +214,28 @@ namespace System.Reflection {
 			info.AddValue ("_Version", Version);
 		}
 
-		// required to implement ICloneable
-		[MonoTODO()]
 		public object Clone() 
 		{
-			return null;
+			AssemblyName an = new AssemblyName ();
+			an.name = name;
+			an.codebase = codebase;
+			an.major = major;
+			an.minor = minor;
+			an.build = build;
+			an.revision = revision;
+			an.cultureinfo = cultureinfo;
+			an.flags = flags;
+			an.hashalg = hashalg;
+			an.keypair = keypair;
+			an.publicKey = publicKey;
+			an.keyToken = keyToken;
+			an.versioncompat = versioncompat;
+			return an;
 		}
 
-		// required to implement IDeserializationCallback
-		[MonoTODO()]
 		public void OnDeserialization (object sender) 
 		{
+			Version = version;
 		}
 
 		public static AssemblyName GetAssemblyName (string assemblyFile) 

+ 2 - 2
mcs/class/corlib/System.Reflection/AssemblyNameProxy.cs

@@ -2,6 +2,7 @@
 // System.Reflection.AssemblyNameProxy.cs
 //
 // Author: Duncan Mak  ([email protected])
+//         Lluis Sanchez Gual ([email protected])
 //
 // (C) Ximian, Inc. http://www.ximian.com
 //
@@ -18,10 +19,9 @@ namespace System.Reflection
 		}
 
 		// Method
-		[MonoTODO]
 		public AssemblyName GetAssemblyName (string assemblyFile)
 		{
-			return null;
+			return AssemblyName.GetAssemblyName (assemblyFile);
 		}
 	}
 }

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

@@ -1,3 +1,10 @@
+2004-04-19  Lluis Sanchez Gual  <[email protected]>
+
+	* Assembly.cs: Removed TODO for CreateQualifiedName.
+	* AssemblyName.cs: Fixed serialization code.
+	* AssemblyNameProxy.cs: Implemented.
+	* Module.cs: Implemented GetMethod() methods, FindTypes() and GetObjectData.
+
 2004-04-07  Martin Baulig  <[email protected]>
 
 	* MonoGenericInst.cs (MonoGenericParam): Removed.

+ 15 - 22
mcs/class/corlib/System.Reflection/Module.cs

@@ -29,6 +29,9 @@ namespace System.Reflection {
 		internal string scopename;
 		internal bool is_resource;
 	
+		const BindingFlags defaultBindingFlags = 
+			BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance;
+		
 		internal Module () { }
 
 		~Module () {
@@ -51,10 +54,14 @@ namespace System.Reflection {
 			get { return scopename; }
 		}
 	
-		[MonoTODO]
 		public virtual Type[] FindTypes(TypeFilter filter, object filterCriteria) 
 		{
-			return null;
+			System.Collections.ArrayList filtered = new System.Collections.ArrayList ();
+			Type[] types = GetTypes ();
+			foreach (Type t in types)
+				if (filter (t, filterCriteria))
+					filtered.Add (t);
+			return (Type[])filtered.ToArray (typeof(Type));
 		}
 	
 		public virtual object[] GetCustomAttributes(bool inherit) 
@@ -91,54 +98,40 @@ namespace System.Reflection {
 			return GetGlobalType ().GetFields (BindingFlags.Public | BindingFlags.Static);
 		}
 	
-		[MonoTODO]
 		public MethodInfo GetMethod (string name) 
 		{
-			if (IsResource ())
-				return null;
-
-			return null;
+			return GetMethodImpl (name, defaultBindingFlags, null, CallingConventions.Any, Type.EmptyTypes, null);
 		}
 	
-		[MonoTODO]
 		public MethodInfo GetMethod (string name, Type[] types) 
 		{
-			if (IsResource ())
-				return null;
-
-			return null;
+			return GetMethodImpl (name, defaultBindingFlags, null, CallingConventions.Any, types, null);
 		}
 	
-		[MonoTODO]
 		public MethodInfo GetMethod (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) 
 		{
-			if (IsResource ())
-				return null;
-
-			return null;
+			return GetMethodImpl (name, bindingAttr, binder, callConvention, types, modifiers);
 		}
 	
-		[MonoTODO]
 		protected virtual MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) 
 		{
 			if (IsResource ())
 				return null;
 
-			return null;
+			return GetGlobalType ().GetMethod (name, bindingAttr, binder, callConvention, types, modifiers);
 		}
 	
-		[MonoTODO]
 		public MethodInfo[] GetMethods () 
 		{
 			if (IsResource ())
 				return new MethodInfo [0];
 
-			return null;
+			return GetGlobalType ().GetMethods ();
 		}
 	
-		[MonoTODO]
 		public virtual void GetObjectData (SerializationInfo info, StreamingContext context) 
 		{
+			UnitySerializationHolder.GetModuleData (this, info, context);
 		}
 	
 		public X509Certificate GetSignerCertificate ()