mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-23 16:58:27 +02:00
fix net452 (#454)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user