From 08a7292d753162947c77cdd3ccf4183e5d929243 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sat, 6 Jan 2024 10:10:43 +0100 Subject: [PATCH 1/3] TinyMapper.Signed --- src/WireMock.Net/WireMock.Net.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index f64c641ce..76bb4e484 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -69,7 +69,7 @@ - + From f74d0b7db61684bcf5fcec4167fe5a0fcb040755 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sat, 6 Jan 2024 11:30:21 +0100 Subject: [PATCH 2/3] ok? --- src/WireMock.Net/WireMock.Net.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index 76bb4e484..059f03303 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -69,7 +69,7 @@ - + From bf47f7e492a3b399d0d0d426d0a85ed3a4b23a04 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sat, 6 Jan 2024 12:25:03 +0100 Subject: [PATCH 3/3] Stef.ClassMapper --- .../Serialization/MappingConverter.cs | 4 +- .../Server/WireMockServer.Admin.cs | 4 +- .../Server/WireMockServer.ConvertMapping.cs | 4 +- src/WireMock.Net/Util/MapperUtils.cs | 54 +++++++++++++++++++ src/WireMock.Net/Util/TinyMapperUtils.cs | 54 ------------------- src/WireMock.Net/WireMock.Net.csproj | 3 +- 6 files changed, 62 insertions(+), 61 deletions(-) create mode 100644 src/WireMock.Net/Util/MapperUtils.cs delete mode 100644 src/WireMock.Net/Util/TinyMapperUtils.cs diff --git a/src/WireMock.Net/Serialization/MappingConverter.cs b/src/WireMock.Net/Serialization/MappingConverter.cs index c7cac97ab..52ac84cb1 100644 --- a/src/WireMock.Net/Serialization/MappingConverter.cs +++ b/src/WireMock.Net/Serialization/MappingConverter.cs @@ -375,9 +375,9 @@ public MappingModel ToMappingModel(IMapping mapping) mappingModel.Response.BodyEncoding = null; mappingModel.Response.Fault = null; - mappingModel.Response.WebProxy = TinyMapperUtils.Instance.Map(response.ProxyAndRecordSettings.WebProxySettings); + mappingModel.Response.WebProxy = MapperUtils.Instance.Map(response.ProxyAndRecordSettings.WebProxySettings); mappingModel.Response.ProxyUrl = response.ProxyAndRecordSettings.Url; - mappingModel.Response.ProxyUrlReplaceSettings = TinyMapperUtils.Instance.Map(response.ProxyAndRecordSettings.ReplaceSettings); + mappingModel.Response.ProxyUrlReplaceSettings = MapperUtils.Instance.Map(response.ProxyAndRecordSettings.ReplaceSettings); } else { diff --git a/src/WireMock.Net/Server/WireMockServer.Admin.cs b/src/WireMock.Net/Server/WireMockServer.Admin.cs index 6e5e41a18..d48ebce1e 100644 --- a/src/WireMock.Net/Server/WireMockServer.Admin.cs +++ b/src/WireMock.Net/Server/WireMockServer.Admin.cs @@ -249,7 +249,7 @@ private IResponseMessage SettingsGet(IRequestMessage requestMessage) #endif }; - model.ProxyAndRecordSettings = TinyMapperUtils.Instance.Map(_settings.ProxyAndRecordSettings); + model.ProxyAndRecordSettings = MapperUtils.Instance.Map(_settings.ProxyAndRecordSettings); return ToJson(model); } @@ -268,7 +268,7 @@ private IResponseMessage SettingsUpdate(IRequestMessage requestMessage) _settings.DoNotSaveDynamicResponseInLogEntry = settings.DoNotSaveDynamicResponseInLogEntry; _settings.HandleRequestsSynchronously = settings.HandleRequestsSynchronously; _settings.MaxRequestLogCount = settings.MaxRequestLogCount; - _settings.ProxyAndRecordSettings = TinyMapperUtils.Instance.Map(settings.ProxyAndRecordSettings); + _settings.ProxyAndRecordSettings = MapperUtils.Instance.Map(settings.ProxyAndRecordSettings); _settings.QueryParameterMultipleValueSupport = settings.QueryParameterMultipleValueSupport; _settings.ReadStaticMappings = settings.ReadStaticMappings; _settings.RequestLogExpirationDuration = settings.RequestLogExpirationDuration; diff --git a/src/WireMock.Net/Server/WireMockServer.ConvertMapping.cs b/src/WireMock.Net/Server/WireMockServer.ConvertMapping.cs index 67d5d2722..3b42dc2dd 100644 --- a/src/WireMock.Net/Server/WireMockServer.ConvertMapping.cs +++ b/src/WireMock.Net/Server/WireMockServer.ConvertMapping.cs @@ -282,8 +282,8 @@ private static IResponseBuilder InitResponseBuilder(ResponseModel responseModel) { Url = responseModel.ProxyUrl!, ClientX509Certificate2ThumbprintOrSubjectName = responseModel.X509Certificate2ThumbprintOrSubjectName, - WebProxySettings = TinyMapperUtils.Instance.Map(responseModel.WebProxy), - ReplaceSettings = TinyMapperUtils.Instance.Map(responseModel.ProxyUrlReplaceSettings) + WebProxySettings = MapperUtils.Instance.Map(responseModel.WebProxy), + ReplaceSettings = MapperUtils.Instance.Map(responseModel.ProxyUrlReplaceSettings) }; return responseBuilder.WithProxy(proxyAndRecordSettings); diff --git a/src/WireMock.Net/Util/MapperUtils.cs b/src/WireMock.Net/Util/MapperUtils.cs new file mode 100644 index 000000000..8a2a7eb4a --- /dev/null +++ b/src/WireMock.Net/Util/MapperUtils.cs @@ -0,0 +1,54 @@ +using WireMock.Admin.Mappings; +using WireMock.Admin.Settings; +using WireMock.Settings; +using ClassMapper; + +namespace WireMock.Util; + +internal sealed class MapperUtils +{ + public static MapperUtils Instance { get; } = new(); + + private MapperUtils() + { + Mapper.Bind(); + Mapper.Bind(); + Mapper.Bind(); + Mapper.Bind(); + + Mapper.Bind(); + Mapper.Bind(); + Mapper.Bind(); + Mapper.Bind(); + } + + public ProxyAndRecordSettingsModel? Map(ProxyAndRecordSettings? instance) + { + return instance == null ? null : Mapper.Map(instance); + } + + public ProxyAndRecordSettings? Map(ProxyAndRecordSettingsModel? model) + { + return model == null ? null : Mapper.Map(model); + } + + public ProxyUrlReplaceSettingsModel? Map(ProxyUrlReplaceSettings? instance) + { + return instance == null ? null : Mapper.Map(instance); + } + + public ProxyUrlReplaceSettings? Map(ProxyUrlReplaceSettingsModel? model) + { + return model == null ? null : Mapper.Map(model); + } + + public WebProxyModel? Map(WebProxySettings? instance) + { + return instance == null ? null : Mapper.Map(instance); + } + + public WebProxySettings? Map(WebProxyModel? model) + { + return model == null ? null : Mapper.Map(model); + } +} \ No newline at end of file diff --git a/src/WireMock.Net/Util/TinyMapperUtils.cs b/src/WireMock.Net/Util/TinyMapperUtils.cs deleted file mode 100644 index 52c74f746..000000000 --- a/src/WireMock.Net/Util/TinyMapperUtils.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Nelibur.ObjectMapper; -using WireMock.Admin.Mappings; -using WireMock.Admin.Settings; -using WireMock.Settings; - -namespace WireMock.Util; - -internal sealed class TinyMapperUtils -{ - public static TinyMapperUtils Instance { get; } = new(); - - private TinyMapperUtils() - { - TinyMapper.Bind(); - TinyMapper.Bind(); - TinyMapper.Bind(); - TinyMapper.Bind(); - - TinyMapper.Bind(); - TinyMapper.Bind(); - TinyMapper.Bind(); - TinyMapper.Bind(); - } - - public ProxyAndRecordSettingsModel? Map(ProxyAndRecordSettings? instance) - { - return instance == null ? null : TinyMapper.Map(instance); - } - - public ProxyAndRecordSettings? Map(ProxyAndRecordSettingsModel? model) - { - return model == null ? null : TinyMapper.Map(model); - } - - public ProxyUrlReplaceSettingsModel? Map(ProxyUrlReplaceSettings? instance) - { - return instance == null ? null : TinyMapper.Map(instance); - } - - public ProxyUrlReplaceSettings? Map(ProxyUrlReplaceSettingsModel? model) - { - return model == null ? null : TinyMapper.Map(model); - } - - public WebProxyModel? Map(WebProxySettings? instance) - { - return instance == null ? null : TinyMapper.Map(instance); - } - - public WebProxySettings? Map(WebProxyModel? model) - { - return model == null ? null : TinyMapper.Map(model); - } -} \ No newline at end of file diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index 059f03303..41c125a6e 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -69,7 +69,8 @@ - + +