Esempio n. 1
0
        public static bool RegisterDelegate(string name, Delegate action)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            CCommand existingCmd = FindCommand(name);

            if (existingCmd != null)
            {
                CDelegateCommand delegateCmd = existingCmd as CDelegateCommand;
                if (delegateCmd != null)
                {
                    Log.w("Overriding command: {0}", name);
                    delegateCmd.ActionDelegate = action;

                    return(true);
                }

                Log.e("Another command with the same name exists: {0}", name);
                return(false);
            }

            return(Register(new CDelegateCommand(name, action)));
        }
Esempio n. 2
0
 public static bool UnregisterAll(object target)
 {
     return(target != null && Unregister(delegate(CCommand cmd)
     {
         CDelegateCommand delegateCmd = cmd as CDelegateCommand;
         return delegateCmd != null && delegateCmd.ActionDelegate.Target == target;
     }));
 }
Esempio n. 3
0
 public static bool Unregister(Delegate del)
 {
     return(Unregister(delegate(CCommand cmd)
     {
         CDelegateCommand delegateCmd = cmd as CDelegateCommand;
         return delegateCmd != null && delegateCmd.ActionDelegate == del;
     }));
 }