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


C# Hosting.StartOptions類代碼示例

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


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

示例1: Configure

        private void Configure(AzureServiceBusOwinServiceConfiguration config, Action<IAppBuilder> startup)
        {
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            var options = new StartOptions();
            if (string.IsNullOrWhiteSpace(options.AppStartup))
            {
                // Populate AppStartup for use in host.AppName
                options.AppStartup = startup.Method.ReflectedType.FullName;
            }

            var testServerFactory = new AzureServiceBusOwinServerFactory(config);
            var services = ServicesFactory.Create();
            var engine = services.GetService<IHostingEngine>();
            var context = new StartContext(options)
            {
                ServerFactory = new ServerFactoryAdapter(testServerFactory),
                Startup = startup
            };
            _started = engine.Start(context);
            _next = testServerFactory.Invoke;
        }
開發者ID:pmhsfelix,項目名稱:ndc-london-13-web-api,代碼行數:25,代碼來源:AzureServiceBusOwinServer.cs

示例2: Start

        public bool Start(HostControl hostControl)
        {
            if (string.IsNullOrEmpty(TestConfig.Instance.ServerUrl))
            {
                throw new Exception("Url為空 無法啟動服務器");
            }

            Pioneer.WxSdk.SdkSetup.MessageTokenGetter = (dic) =>
            {

                PublicAccount pa = new PublicAccount();

                pa.EncryptionKey = TestConfig.Instance.EncryptionKey;
                pa.MessageToken = TestConfig.Instance.Token;
                pa.AppId = TestConfig.Instance.AppId;
                return pa;
            };

            SdkSetup.RegisterListener(new WxSdk.Message.DefaultMessageListener());

            StartOptions so = new StartOptions();
            so.Urls.Add(TestConfig.Instance.ServerUrl);

            innerHost = WebApp.Start(so, builder =>
            {
                builder.Use(new MessageModel().ProcessRequest);
            });

            logger.Info("監聽地址:" + TestConfig.Instance.ServerUrl);

            logger.Info("啟動成功");

            return true;
        }
開發者ID:findersky,項目名稱:WxSdk,代碼行數:34,代碼來源:SdkService.cs

示例3: Main

        static void Main(string[] args)
        {
            StartOptions options = new StartOptions();
            options.Urls.Add(webAddress);
            options.Urls.Add(string.Format("http://{0}:{1}/", Environment.MachineName, port));
            Console.WriteLine("Press enter to stop service");
            Log.Logging.Info("DeviceManager|Starting service|{0}", webAddress);

            using (WebApp.Start<Startup>(webAddress))
            {
                Log.Logging.Info("DeviceManager|Service started|{0}", webAddress);

                var scannerRepository = new DeviceRepository();
                var deviceConnectionManager = new DeviceConnectionManager(scannerRepository);

                deviceConnectionManager.InitializeConfig();
                deviceConnectionManager.ConnectAll();
                var input = Console.ReadLine();

                Log.Logging.Info("DeviceManager|Stopping service|{0}", webAddress);
                Log.Logging.Info("DeviceManager|Disposing|Please wait");
                deviceConnectionManager.DisposeAll();
            }

            Log.Logging.Info("DeviceManager|Service stopped|{0}", webAddress);

        }
開發者ID:chriswong11,項目名稱:Integram,代碼行數:27,代碼來源:NetworkServiceConsole.cs

示例4: Start

        public void Start()
        {
            var siteUrl = Settings.Default.SiteUrl;
            var portNumber = Settings.Default.PortNumber;
            var uri = $"http://*:{portNumber}{siteUrl}";

            SmartDBEntities.SetConnection(Settings.Default.DBServer, Settings.Default.DBName,
                Settings.Default.DBUser,
                Encryption.Decrypt(Settings.Default.DBPassword));

            Program.ProcessLog.Write("Database connection string to " + Settings.Default.DBServer +
                                     " has successfully been made.");
            if (SmartDBEntities.IsDBAvailable)
                Program.ProcessLog.Write("Database connection  " + Settings.Default.DBServer +
                                         " has successfully been made.");
            else
                Program.ProcessLog.Write("Database connection  " + Settings.Default.DBServer + " has failed.");
            var options = new StartOptions();
#if DEBUG
            options.Urls.Add($"http://{Environment.MachineName}:15000");
            options.Urls.Add("http://localhost:15000/");
#endif
            options.Urls.Add(uri);
            Host = WebApp.Start<Startup>(options);
        }
開發者ID:MHAWeb,項目名稱:MachSecure.SmartLaneOverview.Hub,代碼行數:25,代碼來源:HostService.cs

示例5: Init

        public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            this.logger = providerRuntime.GetLogger("Dashboard");

            var router = new Router();
            new DashboardController(router, TaskScheduler.Current,  providerRuntime);

            var options = new StartOptions
            {
                ServerFactory = "Nowin",
                Port = config.Properties.ContainsKey("Port") ? int.Parse(config.Properties["Port"]) : 8080,
            };

            var username = config.Properties.ContainsKey("Username") ? config.Properties["Username"] : null;
            var password = config.Properties.ContainsKey("Password") ? config.Properties["Password"] : null;
            try
            {
                host = WebApp.Start(options, app => new WebServer(router, username, password).Configuration(app));
            }
            catch (Exception ex)
            {
                this.logger.Error(10001, ex.ToString());
            }

            this.logger.Verbose($"Dashboard listening on {options.Port}");

            this.profiler = new GrainProfiler(TaskScheduler.Current, providerRuntime);

            var dashboardGrain = providerRuntime.GrainFactory.GetGrain<IDashboardGrain>(0);
            return dashboardGrain.Init();
        }
開發者ID:ZeBobo5,項目名稱:OrleansDashboard,代碼行數:31,代碼來源:Dashboard.cs

示例6: Owin

	    private static void Owin()
	    {
		    var options = new StartOptions
			    {
				    ServerFactory = "Nowin",
				    Port = 8081
			    };

		    using (WebApp.Start<Startup>(options))
		    {
			    string localIp = "?";
				IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
				foreach (IPAddress ip in host.AddressList)
				{
					if (ip.AddressFamily == AddressFamily.InterNetwork)
					{
						localIp = ip.ToString();
					}
				}	
				Console.WriteLine(string.Format("Running a http server on port http://{0}:{1}",localIp, options.Port));
				while (true)
				{
					Thread.Sleep(1000);
				}
		    }
	    }
開發者ID:rolfwessels,項目名稱:DarthVaderBuildIndicator,代碼行數:26,代碼來源:Program.cs

示例7: Main

        private static void Main(string[] args)
        {
            Bootstrapper.Init();

            var port = ConfigurationManager.AppSettings["Port"];

            var options = new StartOptions($"http://*:{port}")
            {
                ServerFactory = "Microsoft.Owin.Host.HttpListener"
            };

            using (var scope = Bootstrapper.Container.BeginLifetimeScope())
            {
                var startup = scope.Resolve<Startup>();

                var service = scope.Resolve<Service>();

                Task.Run(() => service.Start());

                // Start OWIN host
                using (WebApp.Start(options, startup.Configuration))
                {
                    foreach (var url in options.Urls)
                    {
                        Console.WriteLine($"Service listening on {url}");
                    }

                    Console.ReadLine();
                }
            }
        }
開發者ID:RagtimeWilly,項目名稱:RockinChair,代碼行數:31,代碼來源:Program.cs

示例8: RunServer

        public static void RunServer(StartOptions options)
        {
            if (options == null)
            {
                return;
            }

            string boot;
            if (!options.Settings.TryGetValue("boot", out boot)
                || string.IsNullOrWhiteSpace(boot))
            {
                options.Settings["boot"] = "Domain";
            }

            ResolveAssembliesFromDirectory(
                Path.Combine(Directory.GetCurrentDirectory(), "bin"));

            WriteLine("Starting with " + GetDisplayUrl(options));

            IServiceProvider services = ServicesFactory.Create();
            var starter = services.GetService<IHostingStarter>();
            IDisposable server = starter.Start(options);

            WriteLine("Started successfully");

            WriteLine("Press Enter to exit");
            Console.ReadLine();

            WriteLine("Terminating.");

            server.Dispose();
        }
開發者ID:Xamarui,項目名稱:Katana,代碼行數:32,代碼來源:Program.cs

示例9: CreateApp

        public IDisposable CreateApp(List<string> urls)
        {
            var services = CreateServiceFactory();
            var engine = services.GetService<IHostingEngine>();

            var options = new StartOptions()
            {
                ServerFactory = "Microsoft.Owin.Host.HttpListener"
            };

            urls.ForEach(options.Urls.Add);

            var context = new StartContext(options) { Startup = BuildApp };


            try
            {
                return engine.Start(context);
            }
            catch (TargetInvocationException ex)
            {
                if (ex.InnerException == null)
                {
                    throw;
                }

                if (ex.InnerException is HttpListenerException)
                {
                    throw new PortInUseException("Port {0} is already in use, please ensure NzbDrone is not already running.", ex, _configFileProvider.Port);
                }

                throw ex.InnerException;
            }
        }
開發者ID:Djohnnie,項目名稱:Sonarr,代碼行數:34,代碼來源:OwinServiceProvider.cs

示例10: Main

		private static void Main()
		{
			var options = new StartOptions();
			options.Urls.Add(ConfigurationManager.AppSettings["ServerUrl"]);

			using (WebApp.Start<Startup>(options))
			{
				Console.WriteLine("Server running on {0}", options.Urls[0]);

				do
				{
					var readLine = Console.ReadLine();

					if (readLine != null)
					{
						if (readLine.ToLower() == "start")
						{
							Sync.ConsolePauseEvent.Reset();
						}
						if (readLine.ToLower() == "pause")
						{
							Sync.ConsolePauseEvent.Set();
						}
					}
				} while (true);
			}
		}
開發者ID:Rustemt,項目名稱:SignalR.ForexRates,代碼行數:27,代碼來源:Program.cs

示例11: BeforeAnyTests

		public void BeforeAnyTests() {
			var options = new StartOptions();
			options.Urls.Add( "http://+:" + PORT );

			m_disposeHandle = WebApp.Start( options, OwinStartup );

		}
開發者ID:j3parker,項目名稱:D2L.Security.OAuth2,代碼行數:7,代碼來源:SetupFixture.cs

示例12: Main

        public static void Main(string[] args)
        {
            var evt = new ManualResetEvent (false);

            var basePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", ".."));
            Console.WriteLine(basePath);
            Console.Title = "IdentityServer3 SelfHost";

            Log.Logger = new LoggerConfiguration()
                .WriteTo
                .LiterateConsole(outputTemplate: "{Timestamp:HH:MM} [{Level}] ({Name:l}){NewLine} {Message}{NewLine}{Exception}")
                .CreateLogger();
            var port = ((args != null && args.Length > 1) ? args [0] : null) ?? Environment.GetEnvironmentVariable ("PORT") ?? "44002";
            var url = string.Format ("http://+:{0}/", port);
            var startOptions = new StartOptions();
            startOptions.Urls.Add(url);
            using (WebApp.Start(url, (appBuilder) =>
            {
                new Startup(basePath).Configuration(appBuilder);
            }))
            {
                Console.WriteLine("\n\nServer listening at {0}. Press ctrl+c to stop", url);
                Console.CancelKeyPress += (sender, e) => evt.Set ();
                evt.WaitOne ();
                Console.WriteLine ("Exited");
            }
        }
開發者ID:mequanta,項目名稱:Janitor-old,代碼行數:27,代碼來源:Program.cs

示例13: Start

        public void Start()
        {
            var siteUrl = Settings.Default.SiteUrl;
            var portNumber = Settings.Default.PortNumber;

            var uri = string.Format("http://*:{0}{1}", portNumber, siteUrl);

            SmartDBEntities.SetConnection(Settings.Default.DBServer, Settings.Default.DBName,
                   Settings.Default.DBUser,
                   Encryption.Decrypt(Settings.Default.DBPassword));

            Program.ProcessLog.Write("Database connection string to " + Settings.Default.DBServer + " has successfully been made.");

            if (SmartDBEntities.IsDBAvailable)
                Program.ProcessLog.Write("Database connection  " + Settings.Default.DBServer + " has successfully been made.");
            else
                Program.ProcessLog.Write("Database connection  " + Settings.Default.DBServer + " has failed.");

            StartOptions options = new StartOptions();
            options.Urls.Add(uri);
            Program.ProcessLog.Write("connection has been added to uri.");
            options.Urls.Add("http://localhost:14000");
            Program.ProcessLog.Write("14000 has been added");

            try
            {
                host = WebApp.Start<Startup>(options);

            }
            catch (Exception ex)
            {
                Program.ProcessLog.Write(ex.ToString());
            }
            Program.ProcessLog.Write("Service has been initialised");
        }
開發者ID:MHAWeb,項目名稱:BoardingPassGenerator,代碼行數:35,代碼來源:WinService.cs

示例14: Main

		static void Main(string[] args)
		{
			var url = "http://+:8080";

			var options = new StartOptions
			{
				ServerFactory = "Nowin",
				Port = 8080
			};

			/*
			var loggerConfig = new LoggerConfiguration()
				.MinimumLevel.Debug()
				.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(NuSearchConfiguration.CreateUri(9200))
				{
					AutoRegisterTemplate = true,
					Period = TimeSpan.FromSeconds(2)
				});

			Serilog.Log.Logger = loggerConfig.CreateLogger();
			 */

			using (WebApp.Start<Bootstrap>(options))
			{
				Console.WriteLine("Running on {0}", url);
				Console.WriteLine("Press enter to exit");
				Console.ReadLine();
			}


		}
開發者ID:yangecnu,項目名稱:elasticsearch-net-example,代碼行數:31,代碼來源:Program.cs

示例15: Configure

        private void Configure(Action<IAppBuilder> startup, StartOptions options = null)
        {
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            options = options ?? new StartOptions();
            if (string.IsNullOrWhiteSpace(options.AppStartup))
            {
                // Populate AppStartup for use in host.AppName
                options.AppStartup = startup.Method.ReflectedType.FullName;
            }

            var testServerFactory = new OwinEmbeddedServerFactory();
            IServiceProvider services = ServicesFactory.Create(
                serviceProvider => serviceProvider.AddInstance<ITraceOutputFactory>(new NullTraceOutputFactory())
                );
            var engine = services.GetService<IHostingEngine>();
            var context = new StartContext(options)
            {
                ServerFactory = new ServerFactoryAdapter(testServerFactory),
                Startup = startup
            };
            _started = engine.Start(context);
            _next = testServerFactory.Invoke;
        }
開發者ID:j2jensen,項目名稱:ravendb,代碼行數:27,代碼來源:OwinEmbeddedHost.cs


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