From: Dion O. <dol...@us...> - 2005-11-17 20:15:46
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29402/magicajax/Core Modified Files: Util.cs Log Message: Added a array of types from the input parameters for getting a private method. This solves the 'System.Reflection.AmbiguousMatchException' for .NET 2.0 Index: Util.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Util.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Util.cs 17 Nov 2005 15:06:31 -0000 1.1 --- Util.cs 17 Nov 2005 20:15:38 -0000 1.2 *************** *** 18,24 **** /// <param name="parameters"></param> /// <returns></returns> ! public static object CallPrivateMethod (object instance, Type type, string methodName, params object[] parameters) { ! return type.GetMethod(methodName, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(instance, parameters); } --- 18,24 ---- /// <param name="parameters"></param> /// <returns></returns> ! public static object CallPrivateMethod(object instance, Type type, string methodName, params object[] parameters) { ! return type.GetMethod(methodName, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic, null, GetTypesOfParameters(parameters), null).Invoke(instance, parameters); } *************** *** 52,55 **** --- 52,74 ---- } + /// <summary> + /// Returns an array of types from the input object array + /// </summary> + /// <param name="parameters"></param> + /// <returns></returns> + private static Type[] GetTypesOfParameters(object[] parameters) + { + if (parameters != null) + { + Type[] types = new Type[parameters.Length]; + for (int i = 0; i < parameters.Length; i++) + { + types[i] = parameters[i].GetType(); + } + return types; + } + return null; + } + private Util() { |