Esempio n. 1
0
        private static void StartServer(string solutionPath, string clientPathMode, int port, Verbosity verbosity)
        {
            var logger = new Logger(verbosity);
            try
            {
                Configuration.ConfigurationLoader.Load(clientPathMode);

                var solution = new CSharpSolution(logger);
                Console.CancelKeyPress +=
                    (sender, e) =>
                        {
                            solution.Terminated = true;
                            Console.WriteLine("Ctrl-C pressed");
                            e.Cancel = true;
                        };
                var nancyHost = new NancyHost(new Bootstrapper(
                                                solution,
                                                new NativeFileSystem(),
                                                logger),
                                                new HostConfiguration{RewriteLocalhost=false},
                                                new Uri("http://localhost:" + port));

                nancyHost.Start();
                logger.Debug("OmniSharp server is listening");
                solution.LoadSolution(solutionPath.ApplyPathReplacementsForServer());
                logger.Debug("Solution has finished loading");
                while (!solution.Terminated)
                {
                    Thread.Sleep(1000);
                }

                Console.WriteLine("Quit gracefully");
                nancyHost.Stop();
            }
            catch(Exception e)
            {
                if(e is SocketException || e is HttpListenerException)
                {
                    logger.Error("Detected an OmniSharp instance already running on port " + port + ". Press a key.");
                    return;
                }
                throw;
            }
        }
Esempio n. 2
0
        private static void StartServer(string solutionPath, int port, bool verbose)
        {
            try
            {
                var solution = new CSharpSolution();
                Console.CancelKeyPress +=
                    (sender, e) =>
                        {
                            solution.Terminated = true;
                            Console.WriteLine("Ctrl-C pressed");
                            e.Cancel = true;
                        };

                var nancyHost = new NancyHost(new Bootstrapper(solution, new NativeFileSystem(), verbose), new HostConfiguration{RewriteLocalhost=false}, new Uri("http://localhost:" + port));

                nancyHost.Start();
                Console.WriteLine("OmniSharp server is listening");
                solution.LoadSolution(solutionPath);
                Console.WriteLine("Solution has finished loading");
                while (!solution.Terminated)
                {
                    Thread.Sleep(1000);
                }

                Console.WriteLine("Quit gracefully");
                nancyHost.Stop();
            }
            catch(Exception e)
            {
                if(e is SocketException || e is HttpListenerException)
                {
                    Console.Error.WriteLine("Detected an OmniSharp instance already running on port " + port + ". Press a key.");
                    Console.ReadKey();
                    return;
                }
                throw;
            }
        }
Esempio n. 3
0
 public SolutionTest()
 {
     _solution = new CSharpSolution (new Logger (Verbosity.Verbose));
     _solution.LoadSolution (Environment.CurrentDirectory + "/Solution/minimal/minimal.sln");
 }
Esempio n. 4
0
 public SolutionTest()
 {
     var path = Environment.CurrentDirectory + "/Solution/minimal/minimal.sln";
     _solution = new CSharpSolution (new FileSystem(), path, new Logger(Verbosity.Verbose));
     _solution.LoadSolution ();
 }