Exemplo n.º 1
0
        /**
         * Execute a shortcut in an xml shorcuts file from the given parameters
         */
        public static bool ExecuteShortcut(ShortcutParams parameters)
        {
            JArgumentNullException.Check(parameters, "parameters");

            try
            {
                var profile = parameters.Profile;
                var xmlFile = new XmlShortcutFile(parameters.File);
                var shortcut = xmlFile.GetShortcut(parameters.Profile, parameters.Shortcut);

                if (shortcut != null)
                {
                    shortcut.Params += " " + parameters.Args;
                    return shortcut.Execute();
                }

                return false;
            }
            catch (JRunXmlException ex)
            {
                throw CreateXmlException(ex);
            }
            catch (JRunException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new JException(ex, "Could not execute shortcut \"{0}\" for profile \"{1}\" in xml file \"{2}\"", parameters.Shortcut, parameters.Profile, parameters.File);
            }
        }
Exemplo n.º 2
0
        /**
         * Enumerates the names of all shortcuts (explicit and virtual) in the xml shortcuts file.
         * Useful for auto-complete.
         */
        public static IEnumerable<string> GetAllShortcutNames(ShortcutParams parameters)
        {
            try
            {
                var xmlFile = new XmlShortcutFile(parameters.File);

                return xmlFile.GetAllShortcutNames(parameters.Profile);
            }
            catch (JRunXmlException ex)
            {
                throw CreateXmlException(ex);
            }
            catch (Exception ex)
            {
                throw new JException(ex, "Could not get all shortcut names for profile \"{0}\" in xml file \"{1}\"", parameters.Profile, parameters.File);
            }
        }