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


C# WebApplicationBuilder.GetAddresses方法代码示例

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


在下文中一共展示了WebApplicationBuilder.GetAddresses方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public static void Main(string[] args)
        {
            if (Environment.GetEnvironmentVariable("ASPNET_ENV") == "Debug")
            {
                // Build an ASP.NET 5 web application that serves as the communication listener.
                var webApp = new WebApplicationBuilder().UseConfiguration(WebApplicationConfiguration.GetDefault())
                                                        .ConfigureLogging(factory =>
                                                        {
                                                            factory.AddConsole();
                                                        })
                                                        .UseStartup<Startup>()
                                                        .Build();

                // Replace the address with the one dynamically allocated by Service Fabric.
                webApp.GetAddresses().Clear();
                webApp.GetAddresses().Add(ListeningAddress);
                webApp.Run();

                Thread.Sleep(Timeout.Infinite);

            }
            else
            {
                using (var fabricRuntime = FabricRuntime.Create())
                {
                    fabricRuntime.RegisterServiceType("MicroserviceTemplateType", typeof(MicroserviceTemplate));

                    Thread.Sleep(Timeout.Infinite);
                }
            }
        }
开发者ID:jjcollinge,项目名称:blanky,代码行数:31,代码来源:Program.cs

示例2: CreateServiceInstanceListeners

        protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
        {
            // Build an ASP.NET 5 web application that serves as the communication listener.
            var webApp = new WebApplicationBuilder().UseConfiguration(WebApplicationConfiguration.GetDefault())
                                                    .UseStartup<Startup>()
                                                    .Build();

            // Replace the address with the one dynamically allocated by Service Fabric.
            string listeningAddress = AspNetCommunicationListener.GetListeningAddress(ServiceInitializationParameters, "ServiceDeployerTypeEndpoint");
            webApp.GetAddresses().Clear();
            webApp.GetAddresses().Add(listeningAddress);

            return new[] { new ServiceInstanceListener(_ => new AspNetCommunicationListener(webApp)) };
        }
开发者ID:jjcollinge,项目名称:blanky,代码行数:14,代码来源:ServiceDeployer.cs

示例3: CreateServiceInstanceListeners

        protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
        {
            // Build an ASP.NET 5 web application that serves as the communication listener.
            var webApp = new WebApplicationBuilder().UseConfiguration(WebApplicationConfiguration.GetDefault())
                                                    .UseStartup<Startup>()
                                                    .Build();

            // Replace the address with the one dynamically allocated by Service Fabric.
            var endpoint = ServiceInitializationParameters.CodePackageActivationContext.GetEndpoint("GatewayTypeEndpoint");
            webApp.GetAddresses().Clear();
            webApp.GetAddresses().Add($"{endpoint.Protocol}://+:{endpoint.Port}");

            return new[] { new ServiceInstanceListener(_ => new AspNetCommunicationListener(webApp)) };
        }
开发者ID:lawrencegripper,项目名称:Hosting,代码行数:14,代码来源:GatewayService.cs

示例4: Main

        public static void Main(string[] args)
        {
            if (Environment.GetEnvironmentVariable("ASPNET_ENV") == "Debug")
            {
                try
                {
                    // Build an ASP.NET 5 web application that serves as the communication listener.
                    var webApp = new WebApplicationBuilder().UseConfiguration(WebApplicationConfiguration.GetDefault())
                                                            .ConfigureLogging(factory =>
                                                            {
                                                                factory.AddConsole();
                                                            })
                                                            .UseStartup<Startup>()
                                                            .Build();

                    webApp.GetAddresses().Clear();
                    webApp.GetAddresses().Add(LocalListeningAddress);
                    Console.WriteLine(LocalListeningAddress);
                    webApp.Run();
                    Thread.Sleep(Timeout.Infinite);

                }
                catch (Exception ex)
                {
                    Console.WriteLine("Crashed: {0}", ex);
                    Console.ReadLine();
                }

            }

            using (var fabricRuntime = FabricRuntime.Create())
            {
                fabricRuntime.RegisterServiceType("ServiceDeployerType", typeof(ServiceDeployer));

                Thread.Sleep(Timeout.Infinite);
            }
        }
开发者ID:jjcollinge,项目名称:blanky,代码行数:37,代码来源:Program.cs


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