Beispiel #1
0
        public static void Main(string[] args)
        {
            int port = 0;
            if (args.Length == 0)
            {
                port = 3333;
            }
            else if (args.Length == 1)
            {
                if (!int.TryParse(args[0], out port))
                {
                    Console.Error.WriteLine("Usage: flux.exe [port]");
                    Environment.Exit(1);
                }
            }
            else
            {
                Console.Error.WriteLine("Usage: flux.exe [port]");
                Environment.Exit(1);
            }

            using (var server = new Server(port))
            {
                _fixer = new Fixer(server.Start, server.Stop);

                if (Directory.EnumerateFiles(Environment.CurrentDirectory, "*.dll").Any())
                {
                    FixUpAssemblies(_fixer, "*.dll", Environment.CurrentDirectory);
                }
                else
                {
                    var bin = Path.Combine(Environment.CurrentDirectory, "bin");
                    if (Directory.Exists(bin))
                    {
                        FixUpAssemblies(_fixer, "*.dll", bin);
                    }
                    else
                    {
                        Console.Error.WriteLine("No application found in {0} or {0}\\bin", Environment.CurrentDirectory);
                        Environment.Exit(1);
                    }
                }

                Console.CancelKeyPress += ConsoleOnCancelKeyPress;
                Console.TreatControlCAsInput = false;
                _fixer.Start();
                Console.WriteLine("Flux {0}: listening on port {1}. Press CTRL-C to stop.", Assembly.GetExecutingAssembly().GetName().Version, port);
                while (!_stop)
                {
                    Console.ReadKey();
                }
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var prefix = args.Length == 1 ? args[0] : "http://*:3333/";
            using (var server = new Server(prefix))
            {
                var fixer = new Fixer(func => server.Start(func), server.Stop);

                using (var catalog = new DirectoryCatalog(Environment.CurrentDirectory))
                {
                    var container = new CompositionContainer(catalog);
                    container.ComposeParts(fixer);
                }

                fixer.Start();
                Console.Write("Running. Press Enter to stop.");
                Console.ReadLine();
                fixer.Stop();
            }
        }