当前位置: 首页>>代码示例>>C#>>正文


C# NancyHost.Start方法代码示例

本文整理汇总了C#中Nancy.Hosting.Self.NancyHost.Start方法的典型用法代码示例。如果您正苦于以下问题:C# NancyHost.Start方法的具体用法?C# NancyHost.Start怎么用?C# NancyHost.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nancy.Hosting.Self.NancyHost的用法示例。


在下文中一共展示了NancyHost.Start方法的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: Init

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

            StartHub();
        }
开发者ID:304NotModified,项目名称:NLog.SignalR,代码行数:7,代码来源:OutOfProcessHubFixture.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: 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

示例10: 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

示例11: 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

示例12: 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

示例13: Start

 public void Start()
 {
     var hostUrls = ConfigurationManager.AppSettings["hostUrls"];
     var urlList = hostUrls.Split(',').Select(f => new Uri(f)).ToArray();
     _nancyHost = new NancyHost(urlList);
     _nancyHost.Start();
 }
开发者ID:cognisant,项目名称:cr-cqrs-scaffold,代码行数:7,代码来源:Program.cs

示例14: Main

        public static void Main(string[] args)
        {
            BasicConfigurator.Configure ();

            using (var host = new NancyHost(new Uri("http://localhost:1234")))
            {
                host.Start();
                Console.ReadLine();
            }

            /*var game = new mtgfool.Core.Game ();
            var player1 = new mtgfool.Core.Player ("Johan",game);
            var player2 = new mtgfool.Core.Player ("Liliana",game);
            var mountain = mtgfool.Core.CardFactory.GetInstance ("Mountain", player1);

            mountain.SetLocation (mtgfool.Core.LOCATION.Hand);

            game.AddPlayer (player1);
            game.AddPlayer (player2);
            game.Start ();

            while (game.TurnNumber < 4) {
                game.NextStep ();
                var va = game.GetValidActions ();
                if (va.Count > 0) {
                    va [0].Execute ();
                }
            }

            game.End ();*/
        }
开发者ID:johanjordaan,项目名称:mtgfool,代码行数:31,代码来源:Program.cs

示例15: 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


注:本文中的Nancy.Hosting.Self.NancyHost.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。