Пример #1
0
        public static void AddCommand(CommandPair pair)
        {
            CommandPair command = GetCommand(pair.Command);

            if (command != null)
            {
                command = pair;
            }
            else
            {
                commands.Add(pair);
            }
        }
Пример #2
0
        private static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            Thread.CurrentThread.Priority       = ThreadPriority.Highest;

            Console.WriteLine("ExeLauncher");
            Console.WriteLine("(c) 2012-2014 Marius Gheorghe");
            Console.WriteLine("");

            try
            {
                if (ParseConfig() == false)
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error {0}", ex.Message);
                return;
            }

            //any paths
            if (ApplicationContext.Paths.Count == 0)
            {
                Console.WriteLine("No valid input paths found. Modify the config file and enter the paths.");
                return;
            }

            //is it help ?
            if (args.Length == 1 && args[0] == "?")
            {
                Console.WriteLine("Sample: el starcraft.exe");
                return;
            }


            List <string> listArguments = new List <string>();

            for (int i = 1; i < args.Length; i++)
            {
                listArguments.Add(args[i]);
            }

            //load previously cached commands
            CommandPairManager.LoadCommands();

            //look it up
            string command = args[0];

            //look it in the cache
            CommandPair commandPair = CommandPairManager.GetCommand(command);

            if (commandPair != null)
            {
                if (File.Exists(commandPair.Path))
                {
                    Console.WriteLine("found it in cache");

                    (new Launcher(listArguments)).RunProcess(new[] { commandPair.Path });

                    return;
                }
            }

            bool result = (new Launcher(listArguments)).Launch(command);

            if (result == false)
            {
                Console.WriteLine("No luck....Make sure you typed the exe filename correctly");
            }

            CommandPairManager.Persist();
        }