mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-23 00:38:28 +02:00
. (#339)
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VersionPrefix>1.0.30</VersionPrefix>
|
<VersionPrefix>1.0.31</VersionPrefix>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Choose>
|
<Choose>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
https://github.com/StefH/GitHubReleaseNotes
|
https://github.com/StefH/GitHubReleaseNotes
|
||||||
|
|
||||||
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid --version 1.0.30.0
|
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid --version 1.0.31.0
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using WireMock.Handlers;
|
using WireMock.Handlers;
|
||||||
using WireMock.Logging;
|
using WireMock.Logging;
|
||||||
using WireMock.Matchers;
|
using WireMock.Matchers;
|
||||||
|
using WireMock.Util;
|
||||||
#if !USE_ASPNETCORE
|
#if !USE_ASPNETCORE
|
||||||
using Owin;
|
using Owin;
|
||||||
#else
|
#else
|
||||||
@@ -26,7 +26,7 @@ namespace WireMock.Owin
|
|||||||
|
|
||||||
ConcurrentDictionary<string, ScenarioState> Scenarios { get; }
|
ConcurrentDictionary<string, ScenarioState> Scenarios { get; }
|
||||||
|
|
||||||
ObservableCollection<LogEntry> LogEntries { get; }
|
ConcurrentObservableCollection<LogEntry> LogEntries { get; }
|
||||||
|
|
||||||
int? RequestLogExpirationDuration { get; set; }
|
int? RequestLogExpirationDuration { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,8 @@ namespace WireMock.Owin
|
|||||||
|
|
||||||
if (_options.MaxRequestLogCount != null)
|
if (_options.MaxRequestLogCount != null)
|
||||||
{
|
{
|
||||||
foreach (var logEntry in _options.LogEntries.OrderBy(le => le.RequestMessage.DateTime).Take(_options.LogEntries.Count - _options.MaxRequestLogCount.Value).ToList())
|
var logEntries = _options.LogEntries.ToList();
|
||||||
|
foreach (var logEntry in logEntries.OrderBy(le => le.RequestMessage.DateTime).Take(logEntries.Count - _options.MaxRequestLogCount.Value))
|
||||||
{
|
{
|
||||||
_options.LogEntries.Remove(logEntry);
|
_options.LogEntries.Remove(logEntry);
|
||||||
}
|
}
|
||||||
@@ -172,7 +173,7 @@ namespace WireMock.Owin
|
|||||||
{
|
{
|
||||||
var checkTime = DateTime.UtcNow.AddHours(-_options.RequestLogExpirationDuration.Value);
|
var checkTime = DateTime.UtcNow.AddHours(-_options.RequestLogExpirationDuration.Value);
|
||||||
|
|
||||||
foreach (var logEntry in _options.LogEntries.Where(le => le.RequestMessage.DateTime < checkTime).ToList())
|
foreach (var logEntry in _options.LogEntries.ToList().Where(le => le.RequestMessage.DateTime < checkTime))
|
||||||
{
|
{
|
||||||
_options.LogEntries.Remove(logEntry);
|
_options.LogEntries.Remove(logEntry);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace WireMock.Owin
|
|||||||
|
|
||||||
public ConcurrentDictionary<string, ScenarioState> Scenarios { get; } = new ConcurrentDictionary<string, ScenarioState>();
|
public ConcurrentDictionary<string, ScenarioState> Scenarios { get; } = new ConcurrentDictionary<string, ScenarioState>();
|
||||||
|
|
||||||
public ObservableCollection<LogEntry> LogEntries { get; } = new ConcurrentObservableCollection<LogEntry>();
|
public ConcurrentObservableCollection<LogEntry> LogEntries { get; } = new ConcurrentObservableCollection<LogEntry>();
|
||||||
|
|
||||||
public int? RequestLogExpirationDuration { get; set; }
|
public int? RequestLogExpirationDuration { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using WireMock.Logging;
|
using WireMock.Logging;
|
||||||
using WireMock.Matchers.Request;
|
|
||||||
using System.Linq;
|
|
||||||
using WireMock.Matchers;
|
using WireMock.Matchers;
|
||||||
|
using WireMock.Matchers.Request;
|
||||||
|
|
||||||
namespace WireMock.Server
|
namespace WireMock.Server
|
||||||
{
|
{
|
||||||
@@ -27,7 +27,7 @@ namespace WireMock.Server
|
|||||||
/// Gets the request logs.
|
/// Gets the request logs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public IEnumerable<LogEntry> LogEntries => new ReadOnlyCollection<LogEntry>(_options.LogEntries.ToArray());
|
public IEnumerable<LogEntry> LogEntries => new ReadOnlyCollection<LogEntry>(_options.LogEntries.ToList());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The search log-entries based on matchers.
|
/// The search log-entries based on matchers.
|
||||||
@@ -73,7 +73,7 @@ namespace WireMock.Server
|
|||||||
public bool DeleteLogEntry(Guid guid)
|
public bool DeleteLogEntry(Guid guid)
|
||||||
{
|
{
|
||||||
// Check a logentry exists with the same GUID, if so, remove it.
|
// Check a logentry exists with the same GUID, if so, remove it.
|
||||||
var existing = _options.LogEntries.FirstOrDefault(m => m.Guid == guid);
|
var existing = _options.LogEntries.ToList().FirstOrDefault(m => m.Guid == guid);
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
{
|
{
|
||||||
_options.LogEntries.Remove(existing);
|
_options.LogEntries.Remove(existing);
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace WireMock.Util
|
namespace WireMock.Util
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A special Collection that overrides methods of <see cref="ObservableCollection{T}"/> to make them thread safe
|
/// A special Collection that overrides methods of <see cref="ObservableCollection{T}"/> to make them thread safe.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of elements in the collection.</typeparam>
|
/// <typeparam name="T">The type of elements in the collection.</typeparam>
|
||||||
/// <inheritdoc cref="ObservableCollection{T}" />
|
/// <inheritdoc cref="ObservableCollection{T}" />
|
||||||
public class ConcurrentObservableCollection<T> : ObservableCollection<T>
|
internal class ConcurrentObservableCollection<T> : ObservableCollection<T>
|
||||||
{
|
{
|
||||||
private readonly object _lockObject = new object();
|
private readonly object _lockObject = new object();
|
||||||
|
|
||||||
@@ -73,5 +74,13 @@ namespace WireMock.Util
|
|||||||
base.MoveItem(oldIndex, newIndex);
|
base.MoveItem(oldIndex, newIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<T> ToList()
|
||||||
|
{
|
||||||
|
lock (_lockObject)
|
||||||
|
{
|
||||||
|
return Items.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user