Esempio n. 1
0
        static void Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                ServiceBase.Run(new WindowsService());
                return;
            }

            var server = new IndexerServer();

            server.Start();
            Console.WriteLine("Listening on " + server.UriPrefix + ". Type \"exit\" and press enter to exit");

			string instance = "Pages";
			var commands = new Dictionary<string, Action<string>>(StringComparer.InvariantCultureIgnoreCase);

			commands["debug"] = (arg) => Trace.Listeners.Add(new ConsoleWriterTraceListener());
			commands["exit"] = (arg) => { server.Stop(); Environment.Exit(-1); };
			commands["cls"] = (arg) => Console.Clear();
			commands["search"] = (arg) => Search(server, instance, arg);
			commands["count"] = (arg) => Count(server, instance);
			commands["instance"] = (arg) => { if (string.IsNullOrEmpty(arg)) Console.WriteLine("Current instance: " + instance); else instance = arg; };
			commands["help"] = (arg) => { Console.WriteLine("Available commands: "); foreach (var command in commands) Console.WriteLine(" * " + command.Key); };

			try
			{	        
				do
				{
					Console.Write(">");
					var input = Console.ReadLine();
					var command = input.Split(' ')[0];
					var argument = input.Substring(command.Length);

					Action<string> action;
					if (commands.TryGetValue(command, out action))
						action(argument);
					else if (!string.IsNullOrEmpty(command))
						Console.WriteLine("Invalid command");
					
				} while (true);

			}
			finally
			{
				Console.WriteLine("Exiting...");
				server.Stop();
			}
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                ServiceBase.Run(new WindowsService());
                return;
            }

            var server = new IndexerServer();

            server.Start();

            Console.WriteLine("Listening on " + server.UriPrefix + ". Press enter key to exit");
            string command = "";

            do
            {
                command = Console.ReadLine();
                if ("debug".Equals(command, StringComparison.InvariantCultureIgnoreCase))
                {
                    Trace.Listeners.Add(new ConsoleWriterTraceListener());
                }
                if ("exit".Equals(command, StringComparison.InvariantCultureIgnoreCase))
                {
                    break;
                }
                if ("cls".Equals(command, StringComparison.InvariantCultureIgnoreCase))
                {
                    Console.Clear();
                }
            } while (!string.IsNullOrEmpty(command));

            Console.WriteLine("Exiting...");
            server.Stop();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                ServiceBase.Run(new WindowsService());
                return;
            }

            var server = new IndexerServer();

            server.Start();

            Console.WriteLine("Listening on " + server.UriPrefix + ". Press enter key to exit");
            string command = "";
            do
            {
                command = Console.ReadLine();
                if ("debug".Equals(command, StringComparison.InvariantCultureIgnoreCase))
                    Trace.Listeners.Add(new ConsoleWriterTraceListener());
                if ("exit".Equals(command, StringComparison.InvariantCultureIgnoreCase))
                    break;
                if ("cls".Equals(command, StringComparison.InvariantCultureIgnoreCase))
                    Console.Clear();
            } while (!string.IsNullOrEmpty(command));

            Console.WriteLine("Exiting...");
            server.Stop();
        }
Esempio n. 4
0
        protected override void OnStop()
        {
            server.Stop();

            base.OnStop();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                ServiceBase.Run(new WindowsService());
                return;
            }

            var server = new IndexerServer();

            server.Start();
            Console.WriteLine("Listening on " + server.UriPrefix + ". Type \"exit\" and press enter to exit");

            string instance = "Pages";
            var    commands = new Dictionary <string, Action <string> >(StringComparer.InvariantCultureIgnoreCase);

            commands["debug"]    = (arg) => Trace.Listeners.Add(new ConsoleWriterTraceListener());
            commands["exit"]     = (arg) => { server.Stop(); Environment.Exit(-1); };
            commands["cls"]      = (arg) => Console.Clear();
            commands["search"]   = (arg) => Search(server, instance, arg);
            commands["count"]    = (arg) => Count(server, instance);
            commands["instance"] = (arg) => { if (string.IsNullOrEmpty(arg))
                                              {
                                                  Console.WriteLine("Current instance: " + instance);
                                              }
                                              else
                                              {
                                                  instance = arg;
                                              } };
            commands["help"] = (arg) => { Console.WriteLine("Available commands: "); foreach (var command in commands)
                                          {
                                              Console.WriteLine(" * " + command.Key);
                                          }
            };

            try
            {
                do
                {
                    Console.Write(">");
                    var input    = Console.ReadLine();
                    var command  = input.Split(' ')[0];
                    var argument = input.Substring(command.Length);

                    Action <string> action;
                    if (commands.TryGetValue(command, out action))
                    {
                        action(argument);
                    }
                    else if (!string.IsNullOrEmpty(command))
                    {
                        Console.WriteLine("Invalid command");
                    }
                } while (true);
            }
            finally
            {
                Console.WriteLine("Exiting...");
                server.Stop();
            }
        }