本文整理汇总了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);
}
}
}
示例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)) };
}
示例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)) };
}
示例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);
}
}