示例#1
0
        protected override void OnStart(string[] args)
        {
            _serviceManager = ServerManager.Servers();

            Task.Run(() =>
            {
                _serviceManager.StartAll();
                _serviceManager.WaitForConnections();
            });
        }
示例#2
0
        public static ServerManager Servers()
        {
            lock (_lock)
            {
                if (_instance == null)
                {
                    _instance = new ServerManager();
                    AppDomain.CurrentDomain.UnhandledException -= CurrentDomainOnUnhandledException;
                    AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
                }
            }

            return _instance;
        }
示例#3
0
        private static void Main(string[] args)
        {
            _serviceManager = ServerManager.Servers();

            Task.Run(() =>
            {
                _serviceManager.StartAll();

                foreach (var s in _serviceManager.AllServers)
                {
                    System.Console.WriteLine("Listening on {0}", s.Port);
                }

                _serviceManager.WaitForConnections();
            });

            System.Console.ReadLine();
        }
示例#4
0
        public static void Cleanup()
        {
            if (_iisExpress != null)
            {
                _iisExpress.Dispose();
            }

            var iexps = Process.GetProcessesByName("IISExpress");
            foreach (var iexp in iexps)
            {
                iexp.Kill();
            }

            if (_serviceManager != null)
            {
                _serviceManager.Stop();
                _serviceManager = null;
            }
        }
示例#5
0
        public static void Init(TestContext ctx)
        {
            ServicePointManager.Expect100Continue = false;
            ServicePointManager.CheckCertificateRevocationList = false;
            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => { return true; };

            _serviceManager = ServerManager.Servers().StartAll();

            var iexps = Process.GetProcessesByName("IISExpress");
            foreach (var iexp in iexps)
            {
                iexp.Kill();
            }

            var projDir = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.Parent.Parent.FullName;
            var webroot = Path.Combine(projDir, "Websites");

            _iisExpress = new IISExpress(new Parameters
            {
                Path = webroot,
                Port = 56123,
                Systray = false
            });
        }
示例#6
0
 protected override void OnStop()
 {
     _serviceManager.Stop();
     _serviceManager = null;
 }