mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-27 02:38:30 +02:00
Fix LogEntries: collection was modified exception (#309)
* _options.LogEntries.ToArray() * . * update error message
This commit is contained in:
29
src/WireMock.Net/Util/CloneUtils.cs
Normal file
29
src/WireMock.Net/Util/CloneUtils.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using FastDeepCloner;
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace WireMock.Util
|
||||
{
|
||||
internal static class CloneUtils
|
||||
{
|
||||
private static FastDeepClonerSettings settings = new FastDeepCloner.FastDeepClonerSettings()
|
||||
{
|
||||
FieldType = FastDeepCloner.FieldType.FieldInfo,
|
||||
OnCreateInstance = new FastDeepCloner.Extensions.CreateInstance((Type type) =>
|
||||
{
|
||||
#if !NETSTANDARD1_3
|
||||
return FormatterServices.GetUninitializedObject(type);
|
||||
#else
|
||||
|
||||
#endif
|
||||
})
|
||||
};
|
||||
|
||||
public static T DeepClone<T>(T objectToBeCloned) where T : class
|
||||
{
|
||||
//return CloneExtensionsEx.CloneFactory.GetClone(objectToBeCloned);
|
||||
// Expression.Lambda<Func<object>>(Expression.New(type)).Compile()
|
||||
return FastDeepCloner.DeepCloner.Clone(objectToBeCloned, settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user