diff --git a/src/CSharp/EasyMicroservices.Mapper.AutoMapper/EasyMicroservices.Mapper.AutoMapper.csproj b/src/CSharp/EasyMicroservices.Mapper.AutoMapper/EasyMicroservices.Mapper.AutoMapper.csproj index 4044fd7..8b27dba 100644 --- a/src/CSharp/EasyMicroservices.Mapper.AutoMapper/EasyMicroservices.Mapper.AutoMapper.csproj +++ b/src/CSharp/EasyMicroservices.Mapper.AutoMapper/EasyMicroservices.Mapper.AutoMapper.csproj @@ -5,7 +5,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.5 + 0.0.0.7 Map objects. EasyMicroservices@gmail.com map,mapper,clone,coppy @@ -23,7 +23,7 @@ - 12.0.1 + 13.0.1 diff --git a/src/CSharp/EasyMicroservices.Mapper.AutoMapper/Providers/AutoMapperProvider.cs b/src/CSharp/EasyMicroservices.Mapper.AutoMapper/Providers/AutoMapperProvider.cs index a9e8471..5e804be 100644 --- a/src/CSharp/EasyMicroservices.Mapper.AutoMapper/Providers/AutoMapperProvider.cs +++ b/src/CSharp/EasyMicroservices.Mapper.AutoMapper/Providers/AutoMapperProvider.cs @@ -31,12 +31,12 @@ public AutoMapperProvider(MapperConfiguration mapperConfiguration) /// /// /// - /// + /// /// /// /// /// - public override TTo Map(object fromObject, string uniqueRecordId = default, string language = default, params object[] parameters) + public override TTo Map(object fromObject, string uniqueIdentity = default, string language = default, params object[] parameters) { return _mapper.Map(fromObject); } diff --git a/src/CSharp/EasyMicroservices.Mapper.CompileTimeMapper/EasyMicroservices.Mapper.CompileTimeMapper.csproj b/src/CSharp/EasyMicroservices.Mapper.CompileTimeMapper/EasyMicroservices.Mapper.CompileTimeMapper.csproj index 2fca5b2..c4d4754 100644 --- a/src/CSharp/EasyMicroservices.Mapper.CompileTimeMapper/EasyMicroservices.Mapper.CompileTimeMapper.csproj +++ b/src/CSharp/EasyMicroservices.Mapper.CompileTimeMapper/EasyMicroservices.Mapper.CompileTimeMapper.csproj @@ -5,7 +5,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.6 + 0.0.0.7 Map objects. EasyMicroservices@gmail.com map,mapper,clone,coppy diff --git a/src/CSharp/EasyMicroservices.Mapper.CompileTimeMapper/Interfaces/IMapper.cs b/src/CSharp/EasyMicroservices.Mapper.CompileTimeMapper/Interfaces/IMapper.cs index 999aef5..8fa6450 100644 --- a/src/CSharp/EasyMicroservices.Mapper.CompileTimeMapper/Interfaces/IMapper.cs +++ b/src/CSharp/EasyMicroservices.Mapper.CompileTimeMapper/Interfaces/IMapper.cs @@ -13,40 +13,40 @@ public interface IMapper : IMapper /// /// /// - /// + /// /// /// /// - public TTo Map(TFrom fromObject, string uniqueRecordId, string language, object[] parameters); + public TTo Map(TFrom fromObject, string uniqueIdentity, string language, object[] parameters); /// /// /// /// - /// + /// /// /// /// - public TFrom Map(TTo fromObject, string uniqueRecordId, string language, object[] parameters); + public TFrom Map(TTo fromObject, string uniqueIdentity, string language, object[] parameters); /// /// /// /// - /// + /// /// /// /// - public Task MapAsync(TFrom fromObject, string uniqueRecordId, string language, object[] parameters); + public Task MapAsync(TFrom fromObject, string uniqueIdentity, string language, object[] parameters); /// /// /// /// - /// + /// /// /// /// - public Task MapAsync(TTo fromObject, string uniqueRecordId, string language, object[] parameters); + public Task MapAsync(TTo fromObject, string uniqueIdentity, string language, object[] parameters); } /// @@ -58,19 +58,19 @@ public interface IMapper /// /// /// - /// + /// /// /// /// - public object MapObject(object fromObject, string uniqueRecordId, string language, object[] parameters); + public object MapObject(object fromObject, string uniqueIdentity, string language, object[] parameters); /// /// /// /// - /// + /// /// /// /// - public Task MapObjectAsync(object fromObject, string uniqueRecordId, string language, object[] parameters); + public Task MapObjectAsync(object fromObject, string uniqueIdentity, string language, object[] parameters); } } diff --git a/src/CSharp/EasyMicroservices.Mapper.CompileTimeMapper/Providers/CompileTimeMapperProvider.cs b/src/CSharp/EasyMicroservices.Mapper.CompileTimeMapper/Providers/CompileTimeMapperProvider.cs index 8de299f..7517c9f 100644 --- a/src/CSharp/EasyMicroservices.Mapper.CompileTimeMapper/Providers/CompileTimeMapperProvider.cs +++ b/src/CSharp/EasyMicroservices.Mapper.CompileTimeMapper/Providers/CompileTimeMapperProvider.cs @@ -64,12 +64,12 @@ void AddMapperForType(Type fromType, Type toType, IMapper mapper) /// /// /// - /// + /// /// /// /// /// - public override TTo Map(object fromObject, string uniqueRecordId = null, string language = null, params object[] parameters) + public override TTo Map(object fromObject, string uniqueIdentity = null, string language = null, params object[] parameters) { if (fromObject == null) return default; @@ -77,11 +77,11 @@ public override TTo Map(object fromObject, string uniqueRecordId = null, st { if (mappers.TryGetValue(typeof(TTo), out IMapper mapper)) { - return (TTo)mapper.MapObject(fromObject, uniqueRecordId, language, parameters); + return (TTo)mapper.MapObject(fromObject, uniqueIdentity, language, parameters); } } if (_backupMapperProvider != null) - return _backupMapperProvider.Map(fromObject, uniqueRecordId, language, parameters); + return _backupMapperProvider.Map(fromObject, uniqueIdentity, language, parameters); throw new Exception($"mapper not found for {fromObject.GetType()} and {typeof(TTo)}"); } @@ -90,12 +90,12 @@ public override TTo Map(object fromObject, string uniqueRecordId = null, st /// /// /// - /// + /// /// /// /// /// - public override async Task MapAsync(object fromObject, string uniqueRecordId = null, string language = null, params object[] parameters) + public override async Task MapAsync(object fromObject, string uniqueIdentity = null, string language = null, params object[] parameters) { if (fromObject == null) return default; @@ -103,11 +103,11 @@ public override async Task MapAsync(object fromObject, string uniqueRe { if (mappers.TryGetValue(typeof(TTo), out IMapper mapper)) { - return (TTo)await mapper.MapObjectAsync(fromObject, uniqueRecordId, language, parameters); + return (TTo)await mapper.MapObjectAsync(fromObject, uniqueIdentity, language, parameters); } } if (_backupMapperProvider != null) - return await _backupMapperProvider.MapAsync(fromObject, uniqueRecordId, language, parameters); + return await _backupMapperProvider.MapAsync(fromObject, uniqueIdentity, language, parameters); throw new Exception($"mapper not found for {fromObject.GetType()} and {typeof(TTo)}"); } } diff --git a/src/CSharp/EasyMicroservices.Mapper.SerializerMapper/EasyMicroservices.Mapper.SerializerMapper.csproj b/src/CSharp/EasyMicroservices.Mapper.SerializerMapper/EasyMicroservices.Mapper.SerializerMapper.csproj index 86f085f..66e805d 100644 --- a/src/CSharp/EasyMicroservices.Mapper.SerializerMapper/EasyMicroservices.Mapper.SerializerMapper.csproj +++ b/src/CSharp/EasyMicroservices.Mapper.SerializerMapper/EasyMicroservices.Mapper.SerializerMapper.csproj @@ -1,11 +1,11 @@ - + netstandard2.0;netstandard2.1;net6.0;net45 AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.3 + 0.0.0.7 Map objects. EasyMicroservices@gmail.com map,mapper,clone,coppy @@ -16,7 +16,7 @@ - + diff --git a/src/CSharp/EasyMicroservices.Mapper.SerializerMapper/Providers/SerializerMapperProvider.cs b/src/CSharp/EasyMicroservices.Mapper.SerializerMapper/Providers/SerializerMapperProvider.cs index bb34ef2..e0ba4dd 100644 --- a/src/CSharp/EasyMicroservices.Mapper.SerializerMapper/Providers/SerializerMapperProvider.cs +++ b/src/CSharp/EasyMicroservices.Mapper.SerializerMapper/Providers/SerializerMapperProvider.cs @@ -38,12 +38,12 @@ public SerializerMapperProvider(IBinarySerializationProvider binarySerialization /// /// /// - /// + /// /// /// /// /// - public override TTo Map(object fromObject, string uniqueRecordId = default, string language = default, params object[] parameters) + public override TTo Map(object fromObject, string uniqueIdentity = default, string language = default, params object[] parameters) { if (_textSerialization != null) return _textSerialization.Deserialize(_textSerialization.Serialize(fromObject)); diff --git a/src/CSharp/EasyMicroservices.Mapper.Tests/EasyMicroservices.Mapper.Tests.csproj b/src/CSharp/EasyMicroservices.Mapper.Tests/EasyMicroservices.Mapper.Tests.csproj index 09eb3fc..01744b0 100644 --- a/src/CSharp/EasyMicroservices.Mapper.Tests/EasyMicroservices.Mapper.Tests.csproj +++ b/src/CSharp/EasyMicroservices.Mapper.Tests/EasyMicroservices.Mapper.Tests.csproj @@ -7,10 +7,10 @@ - - - - + + + + diff --git a/src/CSharp/EasyMicroservices.Mapper/EasyMicroservices.Mapper.csproj b/src/CSharp/EasyMicroservices.Mapper/EasyMicroservices.Mapper.csproj index e584f66..77e3b57 100644 --- a/src/CSharp/EasyMicroservices.Mapper/EasyMicroservices.Mapper.csproj +++ b/src/CSharp/EasyMicroservices.Mapper/EasyMicroservices.Mapper.csproj @@ -5,7 +5,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.5 + 0.0.0.7 Map objects. EasyMicroservices@gmail.com map,mapper,clone,coppy diff --git a/src/CSharp/EasyMicroservices.Mapper/Interfaces/IMapperProviderAsync.cs b/src/CSharp/EasyMicroservices.Mapper/Interfaces/IMapperProviderAsync.cs index 2727e5b..5ae16d5 100644 --- a/src/CSharp/EasyMicroservices.Mapper/Interfaces/IMapperProviderAsync.cs +++ b/src/CSharp/EasyMicroservices.Mapper/Interfaces/IMapperProviderAsync.cs @@ -15,50 +15,61 @@ public interface IMapperProviderAsync /// map from object type /// map to object type /// object to map - /// + /// /// /// /// mapped object - Task MapAsync(TFrom fromObject = default, string uniqueRecordId = default, string language = default, params object[] parameters); + Task MapAsync(TFrom fromObject = default, string uniqueIdentity = default, string language = default, params object[] parameters); /// /// map an object to another object /// /// map to object type /// object to map - /// + /// /// /// /// mapped object - Task MapAsync(object fromObject, string uniqueRecordId = default, string language = default, params object[] parameters); + Task MapAsync(object fromObject, string uniqueIdentity = default, string language = default, params object[] parameters); /// /// map enumerable to a list /// /// /// - /// + /// /// /// /// - Task> MapToListAsync(IEnumerable fromObject, string uniqueRecordId = default, string language = default, params object[] parameters); + Task> MapToListAsync(IEnumerable fromObject, string uniqueIdentity = default, string language = default, params object[] parameters); /// /// /// + /// /// /// - /// + /// /// /// /// - Task> MapSingleToListAsync(object fromObject, string uniqueRecordId = default, string language = default, params object[] parameters); + Task> MapToDictionaryAsync(IEnumerable fromObject, string uniqueIdentity = default, string language = default, params object[] parameters); + /// + /// + /// + /// + /// + /// + /// + /// + /// + Task> MapSingleToListAsync(object fromObject, string uniqueIdentity = default, string language = default, params object[] parameters); /// /// map a list to first item /// /// /// - /// + /// /// /// /// - Task MapToFirstAsync(IEnumerable fromObject, string uniqueRecordId = default, string language = default, params object[] parameters); + Task MapToFirstAsync(IEnumerable fromObject, string uniqueIdentity = default, string language = default, params object[] parameters); } } diff --git a/src/CSharp/EasyMicroservices.Mapper/Interfaces/IMapperProviderSync.cs b/src/CSharp/EasyMicroservices.Mapper/Interfaces/IMapperProviderSync.cs index 478e336..ad05b55 100644 --- a/src/CSharp/EasyMicroservices.Mapper/Interfaces/IMapperProviderSync.cs +++ b/src/CSharp/EasyMicroservices.Mapper/Interfaces/IMapperProviderSync.cs @@ -14,50 +14,61 @@ public interface IMapperProviderSync /// map from object type /// map to object type /// object to map - /// + /// /// /// /// mapped object - TTo Map(TFrom fromObject = default, string uniqueRecordId = default, string language = default, params object[] parameters); + TTo Map(TFrom fromObject = default, string uniqueIdentity = default, string language = default, params object[] parameters); /// /// map an object to another object /// /// map to object type /// object to map - /// + /// /// /// /// mapped object - TTo Map(object fromObject, string uniqueRecordId = default, string language = default, params object[] parameters); + TTo Map(object fromObject, string uniqueIdentity = default, string language = default, params object[] parameters); /// /// map enumerable to a list /// /// /// - /// + /// /// /// /// - List MapToList(IEnumerable fromObject, string uniqueRecordId = default, string language = default, params object[] parameters); + List MapToList(IEnumerable fromObject, string uniqueIdentity = default, string language = default, params object[] parameters); /// /// /// + /// /// /// - /// + /// /// /// /// - List MapSingleToList(object fromObject, string uniqueRecordId = default, string language = default, params object[] parameters); + Dictionary MapToDictionary(IEnumerable fromObject, string uniqueIdentity = default, string language = default, params object[] parameters); + /// + /// + /// + /// + /// + /// + /// + /// + /// + List MapSingleToList(object fromObject, string uniqueIdentity = default, string language = default, params object[] parameters); /// /// map a list to first item /// /// /// - /// + /// /// /// /// - TTo MapToFirst(IEnumerable fromObject, string uniqueRecordId = default, string language = default, params object[] parameters); + TTo MapToFirst(IEnumerable fromObject, string uniqueIdentity = default, string language = default, params object[] parameters); } } diff --git a/src/CSharp/EasyMicroservices.Mapper/Providers/BaseMapperProvider.cs b/src/CSharp/EasyMicroservices.Mapper/Providers/BaseMapperProvider.cs index 30ae986..b23a9f5 100644 --- a/src/CSharp/EasyMicroservices.Mapper/Providers/BaseMapperProvider.cs +++ b/src/CSharp/EasyMicroservices.Mapper/Providers/BaseMapperProvider.cs @@ -16,11 +16,11 @@ public abstract class BaseMapperProvider : IMapperProvider /// /// /// - /// + /// /// /// /// - public TTo Map(TFrom fromObject, string uniqueRecordId = default, string language = default, params object[] parameters) + public TTo Map(TFrom fromObject, string uniqueIdentity = default, string language = default, params object[] parameters) { return Map(fromObject); } @@ -30,11 +30,11 @@ public TTo Map(TFrom fromObject, string uniqueRecordId = default, st /// /// /// - /// + /// /// /// /// - public abstract TTo Map(object fromObject, string uniqueRecordId = default, string language = default, params object[] parameters); + public abstract TTo Map(object fromObject, string uniqueIdentity = default, string language = default, params object[] parameters); /// @@ -42,11 +42,11 @@ public TTo Map(TFrom fromObject, string uniqueRecordId = default, st /// /// /// - /// + /// /// /// /// - public List MapSingleToList(object fromObject, string uniqueRecordId = default, string language = default, params object[] parameters) + public List MapSingleToList(object fromObject, string uniqueIdentity = default, string language = default, params object[] parameters) { return new List() { @@ -59,11 +59,11 @@ public List MapSingleToList(object fromObject, string uniqueRecordId = /// /// /// - /// + /// /// /// /// - public TTo MapToFirst(IEnumerable fromObject, string uniqueRecordId = default, string language = default, params object[] parameters) + public TTo MapToFirst(IEnumerable fromObject, string uniqueIdentity = default, string language = default, params object[] parameters) { if (fromObject == null) return default; @@ -79,11 +79,11 @@ public TTo MapToFirst(IEnumerable fromObject, string uniqueRecordId = defau /// /// /// - /// + /// /// /// /// - public List MapToList(IEnumerable fromObject, string uniqueRecordId = default, string language = default, params object[] parameters) + public List MapToList(IEnumerable fromObject, string uniqueIdentity = default, string language = default, params object[] parameters) { if (fromObject == null) return default; @@ -101,13 +101,13 @@ public List MapToList(IEnumerable fromObject, string uniqueRecordId = /// /// /// - /// + /// /// /// /// - public Task MapAsync(TFrom fromObject = default, string uniqueRecordId = null, string language = null, params object[] parameters) + public Task MapAsync(TFrom fromObject = default, string uniqueIdentity = null, string language = null, params object[] parameters) { - return Task.FromResult(Map(fromObject, uniqueRecordId, language, parameters)); + return Task.FromResult(Map(fromObject, uniqueIdentity, language, parameters)); } /// @@ -115,14 +115,14 @@ public Task MapAsync(TFrom fromObject = default, string uniqueR /// /// /// - /// + /// /// /// /// /// - public virtual Task MapAsync(object fromObject, string uniqueRecordId = null, string language = null, params object[] parameters) + public virtual Task MapAsync(object fromObject, string uniqueIdentity = null, string language = null, params object[] parameters) { - return Task.FromResult(Map(fromObject, uniqueRecordId, language, parameters)); + return Task.FromResult(Map(fromObject, uniqueIdentity, language, parameters)); } /// @@ -130,12 +130,12 @@ public virtual Task MapAsync(object fromObject, string uniqueRecordId /// /// /// - /// + /// /// /// /// /// - public async Task> MapSingleToListAsync(object fromObject, string uniqueRecordId = null, string language = null, params object[] parameters) + public async Task> MapSingleToListAsync(object fromObject, string uniqueIdentity = null, string language = null, params object[] parameters) { return new List() { @@ -148,12 +148,12 @@ await MapAsync(fromObject) /// /// /// - /// + /// /// /// /// /// - public async Task MapToFirstAsync(IEnumerable fromObject, string uniqueRecordId = null, string language = null, params object[] parameters) + public async Task MapToFirstAsync(IEnumerable fromObject, string uniqueIdentity = null, string language = null, params object[] parameters) { if (fromObject == null) return default; @@ -169,12 +169,12 @@ public async Task MapToFirstAsync(IEnumerable fromObject, string uniqu /// /// /// - /// + /// /// /// /// /// - public async Task> MapToListAsync(IEnumerable fromObject, string uniqueRecordId = null, string language = null, params object[] parameters) + public async Task> MapToListAsync(IEnumerable fromObject, string uniqueIdentity = null, string language = null, params object[] parameters) { if (fromObject == null) return default; @@ -185,5 +185,49 @@ public async Task> MapToListAsync(IEnumerable fromObject, string } return result; } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Dictionary MapToDictionary(IEnumerable fromObject, string uniqueIdentity = null, string language = null, params object[] parameters) + { + if (fromObject == null) + return default; + Dictionary result = new(); + foreach (var item in fromObject) + { + result.Add(item, Map(item)); + } + return result; + } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public async Task> MapToDictionaryAsync(IEnumerable fromObject, string uniqueIdentity = null, string language = null, params object[] parameters) + { + if (fromObject == null) + return default; + Dictionary result = new(); + foreach (var item in fromObject) + { + result.Add(item, await MapAsync(item)); + } + return result; + } } }