當前位置: 首頁>>代碼示例>>C#>>正文


C# Self.NancyHost類代碼示例

本文整理匯總了C#中Nancy.Hosting.Self.NancyHost的典型用法代碼示例。如果您正苦於以下問題:C# NancyHost類的具體用法?C# NancyHost怎麽用?C# NancyHost使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NancyHost類屬於Nancy.Hosting.Self命名空間,在下文中一共展示了NancyHost類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

        static void Main(string[] args)
        {
            NancyHost host = new NancyHost(new Uri("http://localhost:8812"));
            host.Start();

            Console.ReadKey();
        }
開發者ID:IngvarKofoed,項目名稱:Nancy.Linker.RootPath.Issue4.Repro,代碼行數:7,代碼來源:Program.cs

示例2: OnStart

        protected override void OnStart(string[] args)
        {
            base.OnStart(args);

            ConfigureBindings();

            var boundUris = HostnameUtil.GetUriParams(4567);
            _host = new NancyHost(boundUris);
            _host.Start();

            _core = _kernel.Get<IMuroCore>();

            try
            {
                if (args.Any())
                {
                    _core.Initialise(args[0]);
                }
                else
                {
                    _core.Initialise();
                }
            }
            catch (Exception)
            {
                _core.Shutdown();
                throw;
            }
        }
開發者ID:thenathanjones,項目名稱:muro,代碼行數:29,代碼來源:Program.cs

示例3: Main

        static void Main(string[] args)
        {
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings { Formatting = Formatting.Indented };

            using (ActionScheduler scheduler = new ActionScheduler())
            using (var host = new NancyHost(new Uri("http://localhost:8090")))
            {
                host.Start();
                Console.WriteLine("Nancy Running at http://localhost:8090");
                Console.WriteLine("Press any key to exit");

                Process.Start("http://localhost:8090/metrics/");

                SampleMetrics.RunSomeRequests();

                scheduler.Start(TimeSpan.FromMilliseconds(500), () =>
                {
                    SetCounterSample.RunSomeRequests();
                    SetMeterSample.RunSomeRequests();
                    UserValueHistogramSample.RunSomeRequests();
                    UserValueTimerSample.RunSomeRequests();
                    SampleMetrics.RunSomeRequests();
                });

                HealthChecksSample.RegisterHealthChecks();

                Console.ReadKey();
            }
        }
開發者ID:Abbyjeet,項目名稱:Metrics.NET,代碼行數:29,代碼來源:Program.cs

示例4: Start

        /// <summary>
        /// 監聽端口 啟動站點
        /// </summary>
        /// <param name="urls">監聽ip端口列表</param>
        public static NancyHost Start(int port)
        {
            try
            {
                _host = new NancyHost(new Uri(string.Format("http://localhost:{0}", port)));
                _host.Start();
                LogHelper.WriteLog("Web管理站點啟動成功,請打開 http://127.0.0.1:" + port + "進行瀏覽");

                if (SystemConfig.WebPort != port)
                {
                    //更新係統參數配置表監聽端口
                    SystemConfig.WebPort = port;
                    ConfigManager.UpdateValueByKey("SystemConfig", "WebPort", port.ToString());
                }
                return _host;
            }
            catch (HttpListenerException ex)
            {
                LogHelper.WriteLog("Web管理站點啟動失敗", ex);
                Random random = new Random();
                port = random.Next(port - 1000, port + 1000);
                Console.WriteLine(ex.Message);
                Console.WriteLine(" 重新嘗試端口:" + port);
                return Start(port);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("Web管理站點啟動失敗", ex);
                throw ex;
            }
        }
開發者ID:CrazyJson,項目名稱:TaskManager,代碼行數:35,代碼來源:Startup.cs

示例5: Main

        public static void Main(string[] args)
        {
            // bool from configuration files.
            OsmSharp.Service.Tiles.ApiBootstrapper.BootFromConfiguration();

            // start listening.
            var uri = new Uri("http://localhost:1234");
            HostConfiguration configuration = new HostConfiguration();
            configuration.UrlReservations.CreateAutomatically = true;
            using (var host = new NancyHost(configuration, uri))
            {
                try
                {
                    host.Start();

                    Console.WriteLine("The OsmSharp routing service is running at " + uri);
                    Console.WriteLine("Press [Enter] to close the host.");
                    Console.ReadLine();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine("Press [Enter] to close the host.");
                    Console.ReadLine();
                }
            }
        }
開發者ID:smccloud,項目名稱:OsmSharp.Service.Tiles,代碼行數:27,代碼來源:Program.cs

示例6: Main

        static void Main(string[] args)
        {
            var ip = "10.0.1.15";
            var port = "3580";
            var selection = "";

            Console.WriteLine("Enter IP address. Default is 10.0.1.15");
            selection = Console.ReadLine();
            if (!string.IsNullOrEmpty(selection))
                ip = selection;

            Console.WriteLine("Enter port. Default is 3580");
            selection = Console.ReadLine();
            if (!string.IsNullOrEmpty(selection))
                port = selection;



            var uri = new Uri(string.Format("http://{0}:{1}",ip, port));

            RegisterService(ip, port);

            using (var host1 = new NancyHost(uri))
            //using (var customerService = new CustomerServiceReciever(busFactory, translationService))
            {
                host1.Start();

                Console.WriteLine("Your application is running on " + uri);
                Console.ReadLine();
            }
        }
開發者ID:FociSolutions,項目名稱:Foci.DSB,代碼行數:31,代碼來源:Program.cs

示例7: Main

        static void Main(string[] args)
        {
            // Note: The URI must *exactly* match the one specified in the URL ACL.
            // This leads to a problem when you use +, because the Uri constructor doesn't like it.
            var uri = "http://localhost:1234/";
            if (args.Length != 0)
                uri = args[0];

            var stop = new ManualResetEvent(false);
            Console.CancelKeyPress += (sender, e) =>
                {
                    Console.WriteLine("^C");
                    stop.Set();
                };

            var host = new NancyHost(new Uri(uri));
            host.Start();

            Console.WriteLine("Nancy Self Host listening on {0}", uri);
            Console.WriteLine("Press Ctrl+C to quit.");

            stop.WaitOne();

            host.Stop();
        }
開發者ID:rlipscombe,項目名稱:nancy-hosting,代碼行數:25,代碼來源:Program.cs

示例8: Main

        static int Main(string[] args)
        {
            if (args.Length == 0 ||
                string.IsNullOrEmpty(UserKey = args[0]))
            {
                Console.WriteLine("userKey argument is required");
                return 1;
            }

            const int port = 40001;
            var address = string.Format("http://localhost:{0}", port);

            var hostConfig = new HostConfiguration
            {
                UrlReservations = new UrlReservations
                {
                    CreateAutomatically = true
                }
            };

            using (var host = new NancyHost(hostConfig, new Uri(address)))
            {
                host.Start();
                var scheduler = ApiBootstrapper.Container.Resolve<Scheduler>();

                Console.WriteLine("started {0}", port);

                while (scheduler.State != SystemState.Finished)
                {
                    Thread.Sleep(1000);
                }
            }

            return 0;
        }
開發者ID:ryascl,項目名稱:design-challenge-server-clr,代碼行數:35,代碼來源:Program.cs

示例9: Main

        static void Main(string[] args)
        {
            var port = 3400;
            HostConfiguration hostConfigs = new HostConfiguration();
            hostConfigs.UrlReservations.CreateAutomatically = true;

            while (true)
            {
                try
                {
                    using (var host = new NancyHost(hostConfigs, new Uri("http://localhost:" + port)))
                    {
                        host.Start();

                        Console.WriteLine("Your application is running on port " + port);
                        Console.WriteLine("Press any key to close the host.");
                        Console.ReadKey();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    port++;
                }
            }
        }
開發者ID:yodiwo,項目名稱:plegma,代碼行數:26,代碼來源:Program.cs

示例10: Init

        public void Init()
        {
            _host = new NancyHost(new Uri(RestBaseUrl));
            _host.Start();

            StartHub();
        }
開發者ID:304NotModified,項目名稱:NLog.SignalR,代碼行數:7,代碼來源:OutOfProcessHubFixture.cs

示例11: Start

 public void Start()
 {
     Log.Debug("Starting self hosted website");
     _nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:1234"));
     _nancyHost.Start();
     Log.Debug("Done starting self hosted website");
 }
開發者ID:awlawl,項目名稱:Maestro,代碼行數:7,代碼來源:SelfHostedWebsite.cs

示例12: Run

        public void Run()
        {
            EnsureInstallation();

            foreach (var service in _services)
            {
                Console.WriteLine("Starting service {0}", service.ServiceName);
                service.Start();
            }

            _nancy = new NancyHost(_uris);
            _nancy.Start();

            Console.WriteLine("Running server at {0}", string.Join(", ", _uris
                .Select(u => u.ToString())
            ));

            Console.ReadLine();

            Console.WriteLine("Stopping server");
            _nancy.Stop();

            foreach (var service in _services)
            {
                Console.WriteLine("Stopping service {0}", service.ServiceName);
                service.Stop();
            }
        }
開發者ID:seyyedi,項目名稱:remote-mpc,代碼行數:28,代碼來源:Server.cs

示例13: Run

        public void Run(CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
                return;

            var nancyConfig = new HostConfiguration
            {
                UrlReservations = new UrlReservations
                {
                    CreateAutomatically = true
                }
            };

            var bootstrapper = new ApiBootstrapper(_repository);

            var host = new NancyHost(bootstrapper, nancyConfig, _baseUri);
            cancellationToken.Register(() =>
            {
                Log.InfoFormat("Stopping Nancy host at \"{0}\".", _baseUri);
                host.Stop();
                Log.InfoFormat("Nancy host at \"{0}\" successfully stopped.", _baseUri);
            });

            Log.InfoFormat(CultureInfo.InvariantCulture, "Starting Nancy host at \"{0}\".", _baseUri);
            host.Start();
        }
開發者ID:sjlbos,項目名稱:SENG462_DTS,代碼行數:26,代碼來源:NancyHostLauncherWorker.cs

示例14: WebServer

 public WebServer(INancyBootstrapper bootstrapper)
 {
     _nancyHost = new NancyHost(new Uri("http://localhost:1234"), bootstrapper, new HostConfiguration
     {
         RewriteLocalhost = false
     });
 }
開發者ID:kbortnik,項目名稱:mailfunnel,代碼行數:7,代碼來源:WebServer.cs

示例15: Main

        static void Main(string[] args)
        {
            /***
             * Note:
             *  When using multiple network interfaces, you should not use localhost but a fully qualified ip (v4)
             * 
             ***/
            //SSL: For SSL on Windows rewrite http to https
            var uri = new Uri("http://localhost:"+ConvenienceSystemBackendServer.ConvenienceServer.getPort());
            //var uri = new Uri("http://192.168.1.39:" + ConvenienceSystemBackendServer.ConvenienceServer.getPort());


            using (var host = new NancyHost(uri))
            {
                host.Start();

                Console.WriteLine("Your application is running on " + uri);
                /*Console.WriteLine("Enter 'q' and press [Enter] to close the host.");

                while (true)
                {
                    string line = Console.ReadLine();
                    if (line == "q")
                        break;
                }*/
                while (true)
                    Thread.Sleep(50000);

                /*
                * Remark:
                *   using Sleep here because ReadLine/yield on Unix/Linux often has problems with nohup execution resulting in continously high load on the server
                */
            }
        }
開發者ID:auxua,項目名稱:ConvenienceSystem2,代碼行數:34,代碼來源:Program.cs


注:本文中的Nancy.Hosting.Self.NancyHost類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。