Ejemplo n.º 1
0
        public static void DefineGenerateKeyHandler(string classType, string methodName)
        {
            Type cType = Type.GetType(classType);

            if (cType == null)
            {
                throw new GDAException("GenerateKeyHandler\r\nType {0} not found", classType);
            }
            MethodInfo[] methods = cType.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public);
                        #if !PocketPC
            MethodInfo method = Array.Find(methods, delegate(MethodInfo mi) {
                return(mi.Name == methodName);
            });
                        #else
            MethodInfo method = null;
            foreach (var i in methods)
            {
                if (i.Name == methodName)
                {
                    method = i;
                    break;
                }
            }
#endif
            if (method == null)
            {
                throw new GDAException("GenerateKeyHandler\r\nMethod {0} not found in {1}.", methodName, cType.FullName);
            }
                        #if !PocketPC
            GDAOperations.SetGlobalGenerateKeyHandler((GenerateKeyHandler)Delegate.CreateDelegate(typeof(GenerateKeyHandler), method));
                        #else
            GDAOperations.SetGlobalGenerateKeyHandler(delegate(object sender, GenerateKeyArgs args)
            {
                method.Invoke(null, new object[] { sender, args });
            });
#endif
        }