Observable logs (refactor some code)

This commit is contained in:
Stef Heyenrath
2017-10-07 15:28:36 +02:00
parent 2d39a18b70
commit 207688e42b
9 changed files with 221 additions and 155 deletions

View File

@@ -25,9 +25,7 @@ namespace WireMock.Owin
{
Urls.Add(uriPrefix);
int port;
string host;
PortUtil.TryExtractProtocolAndPort(uriPrefix, out host, out port);
PortUtil.TryExtractProtocolAndPort(uriPrefix, out string host, out int port);
Ports.Add(port);
}

View File

@@ -163,7 +163,10 @@ namespace WireMock.Owin
if (_options.MaxRequestLogCount != null)
{
var amount = _options.LogEntries.Count - _options.MaxRequestLogCount.Value;
for (var i = 0; i < amount; i++, _options.LogEntries.RemoveAt(0)) ;
for (int i = 0; i < amount; i++)
{
_options.LogEntries.RemoveAt(0);
}
}
if (_options.RequestLogExpirationDuration != null)
@@ -174,7 +177,9 @@ namespace WireMock.Owin
{
var le = _options.LogEntries[i];
if (le.RequestMessage.DateTime <= checkTime)
{
_options.LogEntries.RemoveAt(i);
}
}
}
}

View File

@@ -16,7 +16,7 @@ namespace WireMock.Owin
public IList<Mapping> Mappings { get; set; }
public ObservableCollection<LogEntry> LogEntries { get; set; }
public ObservableCollection<LogEntry> LogEntries { get; }
public int? RequestLogExpirationDuration { get; set; }