Exemplo n.º 1
0
        public bool Execute(AnkhCommand command, CommandEventArgs e)
        {
            EnsureLoaded();
            CommandMapItem item;

            if (_map.TryGetValue(command, out item))
            {
                try
                {
                    e.Prepare(item);

                    CommandUpdateEventArgs u = new CommandUpdateEventArgs(command, e.Context);
                    item.OnUpdate(u);
                    if (u.Enabled)
                    {
                        item.OnExecute(e);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    IAnkhErrorHandler eh = GetService <IAnkhErrorHandler>();

                    if (eh != null && eh.IsEnabled(ex))
                    {
                        eh.OnError(ex, e);
                        return(true); // If we return false VS shows another error box!
                    }

                    throw;
                }

                return(item.IsHandled);
            }

            return(false);
        }
Exemplo n.º 2
0
        public bool Execute(AnkhCommand command, CommandEventArgs e)
        {
            EnsureLoaded();
            CommandMapItem item;

            if (_map.TryGetValue(command, out item))
            {
                try
                {
                    e.Prepare(item);

                    CommandUpdateEventArgs u = new CommandUpdateEventArgs(command, e.Context);
                    item.OnUpdate(u);
                    if (u.Enabled)
                    {
                        item.OnExecute(e);
                    }
                    else
                        return false;
                }
                catch (Exception ex)
                {
                    IAnkhErrorHandler eh = GetService<IAnkhErrorHandler>();

                    if (eh != null && eh.IsEnabled(ex))
                    {
                        eh.OnError(ex, e);
                        return true; // If we return false VS shows another error box!
                    }

                    throw;

                }

                return item.IsHandled;
            }

            return false;
        }