From 3ac55b724fbbbedd1b093c0c852cb3350c6af02c Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 09:43:40 +0000 Subject: Utilisateur : Fcolin Date : 8/02/06 Heure : 17:13 Archivé dans $/CSharp/Ivy/IvyPPC Commentaire: clarification du type de retour sur die (vss 52) --- CSharp/Ivy/Ivy/Ivy.cs | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/CSharp/Ivy/Ivy/Ivy.cs b/CSharp/Ivy/Ivy/Ivy.cs index cded94b..276825f 100644 --- a/CSharp/Ivy/Ivy/Ivy.cs +++ b/CSharp/Ivy/Ivy/Ivy.cs @@ -27,29 +27,6 @@ namespace IvyBus /// The Main bus Class /// /// - -#if (PocketPC) - public class CreateDelegate - { - object eventtarget; - MethodInfo mymethod; - object [] methodparams = new Object[2]; - - public void Invoke(object sender, System.EventArgs e) - { - methodparams[1] = e; - mymethod.Invoke(eventtarget, methodparams); - } - - public CreateDelegate(MethodInfo mi, object eventTarget, object eventObject) - { - eventtarget = eventTarget; - mymethod = mi; - methodparams[0] = eventObject; - methodparams[1] = null; - } - } -#endif #if (!PocketPC) [ToolboxItemFilter("System.Windows.Forms.Form",ToolboxItemFilterType.Allow)] @@ -58,11 +35,13 @@ namespace IvyBus #endif public class Ivy : System.ComponentModel.Component { - /* Event handler */ + /* return value for Die Event */ + public enum ApplicationExit { FORCE_EXIT, DONT_EXIT }; + /* Event handler */ public delegate void DirectMessageHandler (IvyClient app, int id, string arg ); public delegate void ClientConnectedHandler (IvyClient app); public delegate void ClientDisconnectedHandler (IvyClient app); - public delegate bool DieHandler (IvyClient app, int id, string arg ); + public delegate ApplicationExit DieHandler(IvyClient app, int id, string arg); public delegate void ClientAddBindingHandler (IvyClient app, string arg ); public delegate void ClientRemoveBindingHandler (IvyClient app, string arg ); @@ -377,12 +356,13 @@ namespace IvyBus { //TODO check paramater type MessageHandler Debug.WriteLine("IvyBinding '" + attr.GetExpression(null) + "' to Method " + m.Name); + MessageHandler handler; #if (PocketPC) - //bindMsg(attr.GetExpression(null), (MessageHandler) DynamicMethod.CreateDelegate(m)); - + handler = null; // TODO #else - bindMsg(attr.GetExpression(null), (MessageHandler)Delegate.CreateDelegate(typeof(MessageHandler),m)); + handler = (MessageHandler)Delegate.CreateDelegate(typeof(MessageHandler), m) #endif + bindMsg(attr.GetExpression(null), handler); } } } @@ -397,11 +377,13 @@ namespace IvyBus { //TODO check paramater type MessageHandler traceDebug("IvyBinding '" + attr.GetExpression(obj) + "' to Method " + m.Name); + MessageHandler handler; #if (PocketPC) - //bindMsg(attr.GetExpression(obj), (MessageHandler) new CreateDelegate( m, obj, null)); + handler = null; // TODO #else - bindMsg(attr.GetExpression(obj), (MessageHandler)Delegate.CreateDelegate(typeof(MessageHandler), obj, m)); + handler = (MessageHandler)Delegate.CreateDelegate(typeof(MessageHandler), obj, m); #endif + bindMsg(attr.GetExpression(obj), handler); } } @@ -793,15 +775,15 @@ namespace IvyBus else BindingRemove( app,regexp); } } - internal bool FireDie (IvyClient app, int id, string arg ) + internal ApplicationExit FireDie(IvyClient app, int id, string arg) { if ( dieReceived != null ) { if (IsSynchronous()) - return (bool )syncControl.Invoke( dieReceived, new object[]{app,id,arg}); + return (ApplicationExit)syncControl.Invoke(dieReceived, new object[] { app, id, arg }); else return dieReceived( app, id, arg); } - return false; + return ApplicationExit.FORCE_EXIT; } -- cgit v1.1