• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Hosting.StartOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Owin.Hosting.StartOptions的典型用法代码示例。如果您正苦于以下问题:C# StartOptions类的具体用法?C# StartOptions怎么用?C# StartOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StartOptions类属于Microsoft.Owin.Hosting命名空间,在下文中一共展示了StartOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Start

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

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

            const string url = "http://localhost:10000";
            StartOptions options = new StartOptions();
            options.Urls.Add(string.Format("http://{0}:10000", Environment.MachineName));
            options.Urls.Add("http://localhost:10000/");
            options.Urls.Add(uri);

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

            var hubConnection = new HubConnection(url);
            var hubProxy = hubConnection.CreateHubProxy("MyHub");

            hubConnection.Start().ContinueWith(task =>
            {

            }).Wait();

            var timer = new Timer(x =>
            {
                if (ConnectionMapping.Count <= 1) return;

                hubProxy.Invoke("Send").Wait();
            }, null, 0, 2000);
        }
开发者ID:DeanMcgarrigle,项目名称:Predictor,代码行数:30,代码来源:WinService.cs


示例17: Start

        public static void Start(SnowSettings settings)
        {
            Console.WriteLine("Sandra.Snow : Starting up a testing server");

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

            Startup.Settings = settings;

            using (WebApp.Start<Startup>(options))
            {
                Console.WriteLine("Sandra.Snow : Listening on http://locahost:5498/");
                Console.WriteLine(" - attempting to open your browser...");
                
                Process.Start("http://localhost:5498/");

                Console.WriteLine(" - press any to quit the testing server...");
                Console.ReadKey();
                Console.WriteLine("");
                Console.WriteLine("Sandra.Snow : Exited testing server");
            }
        }
开发者ID:KalebDark,项目名称:Sandra.Snow,代码行数:25,代码来源:SnowServer.cs


示例18: Start

        public const double SizeCapForDownload = 51200; // 50 KB size limit

        public static IDisposable Start(Dev2Endpoint[] endpoints)
        {
            // Make long polling connections wait a maximum of 110 seconds for a
            // response. When that time expires, trigger a timeout command and
            // make the client reconnect.
            GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(180);

            // Wait a maximum of 30 seconds after a transport connection is lost
            // before raising the Disconnected event to terminate the SignalR connection.
            GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(30);

            // For transports other than long polling, send a keepalive packet every
            // 10 seconds. 
            // This value must be no more than 1/3 of the DisconnectTimeout value.
            GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(10);

            GlobalHost.Configuration.DefaultMessageBufferSize = 1000;
            GlobalHost.Configuration.MaxIncomingWebSocketMessageSize = null;
            GlobalHost.Configuration.TransportConnectTimeout = TimeSpan.FromSeconds(10);
            
            var startOptions = new StartOptions();
            
            foreach(var endpoint in endpoints)
            {
                startOptions.Urls.Add(endpoint.Url);
            }
            return WebApp.Start<WebServerStartup>(startOptions);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:30,代码来源:WebServerStartup.cs


示例19: Main

        static void Main(string[] args)
        {
            var address = ConfigurationManager.AppSettings["useSecurePort"] == "true"
                                   ? ConfigurationManager.AppSettings["secureAddress"]
                                   : ConfigurationManager.AppSettings["unsecureAddress"];

            var startOpt = new StartOptions(address)
            {
                ServerFactory = typeof(SocketServerFactory).AssemblyQualifiedName,
            };

            try
            {
                // Start OWIN host 
                using (WebApp.Start<Startup>(startOpt))
                {
                    Console.WriteLine("Press Enter to stop the server");
                    Console.WriteLine("The following URLs could be used for testing:");
                    Console.WriteLine(address + "simpleTest.txt");
                    Console.WriteLine(address + "10mbTest.txt");
                    
                    Console.ReadLine(); 
                } 
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("Error => {0} : {1}", 
                    ex.Message, 
                    (ex.InnerException != null) ? ex.InnerException.Message : String.Empty));
               	Console.ReadLine(); 
           
            }
        }
开发者ID:Nangal,项目名称:http2-katana,代码行数:33,代码来源:Program.cs


示例20: _SetServerEnableState

		private void _SetServerEnableState(bool value, int port)
		{
			if (value)
			{
				StopServer();
				var options = new StartOptions {ServerFactory = "Nowin", Port = port}; //use the Nowin _server to listen for connections
				try
				{
					_server = WebApp.Start<Startup>(options);
				}
				catch (Exception ex)
				{
					Logging.Error("Unable to start web _server.", ex);
					return;
				}
				if (LiveContext == null)
				{
					LiveContext = VixenSystem.Contexts.CreateLiveContext("Web Server");
					LiveContext.Start();
				}
				
			}
			else
			{
				StopServer();
				if (LiveContext != null)
				{
					//We are the only current consumer of LiveContext, so shut it off when we are done.
					VixenSystem.Contexts.ReleaseContext(LiveContext);
					LiveContext = null;
				}
			}
		}
开发者ID:stewmc,项目名称:vixen,代码行数:33,代码来源:Module.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Security.AuthenticationProperties类代码示例发布时间:2022-05-26
下一篇:
C# Owin.OwinMiddleware类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap