fix net452 (#454)

This commit is contained in:
Stef Heyenrath
2020-04-17 12:18:45 +02:00
committed by GitHub
parent d2ac56e49a
commit a8934ec7f9
2 changed files with 584 additions and 581 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,43 +1,43 @@
using System.Collections.Generic; using System.Collections.Generic;
using WireMock.Util; using WireMock.Util;
namespace WireMock.Owin namespace WireMock.Owin
{ {
internal class HostUrlOptions internal class HostUrlOptions
{ {
public ICollection<string> Urls { get; set; } public ICollection<string> Urls { get; set; }
public int? Port { get; set; } public int? Port { get; set; }
public bool UseSSL { get; set; } public bool UseSSL { get; set; }
public ICollection<(string Url, int Port)> GetDetails() public ICollection<(string Url, int Port)> GetDetails()
{ {
var list = new List<(string Url, int Port)>(); var list = new List<(string Url, int Port)>();
if (Urls == null) if (Urls == null)
{ {
int port = Port ?? FindFreeTcpPort(); int port = Port > 0 ? Port.Value : FindFreeTcpPort();
list.Add(($"{(UseSSL ? "https" : "http")}://localhost:{port}", port)); list.Add(($"{(UseSSL ? "https" : "http")}://localhost:{port}", port));
} }
else else
{ {
foreach (string url in Urls) foreach (string url in Urls)
{ {
PortUtils.TryExtract(url, out string protocol, out string host, out int port); PortUtils.TryExtract(url, out string protocol, out string host, out int port);
list.Add((url, port)); list.Add((url, port));
} }
} }
return list; return list;
} }
private int FindFreeTcpPort() private int FindFreeTcpPort()
{ {
#if USE_ASPNETCORE || NETSTANDARD2_0 || NETSTANDARD2_1 #if USE_ASPNETCORE || NETSTANDARD2_0 || NETSTANDARD2_1
return 0; return 0;
#else #else
return PortUtils.FindFreeTcpPort(); return PortUtils.FindFreeTcpPort();
#endif #endif
} }
} }
} }