Update
This commit is contained in:
64
src/BackOffice.BFF.WebApi/Common/Mappings/GeneralMapping.cs
Normal file
64
src/BackOffice.BFF.WebApi/Common/Mappings/GeneralMapping.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System.Globalization;
|
||||
namespace BackOffice.BFF.WebApi.Common.Mappings;
|
||||
|
||||
public class GeneralMapping : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.NewConfig<string, decimal>()
|
||||
.MapWith(src => decimal.Parse(src));
|
||||
|
||||
config.NewConfig<decimal, string>()
|
||||
.MapWith(src => src.ToString("R", new CultureInfo("en-us")));
|
||||
|
||||
config.NewConfig<decimal?, string>()
|
||||
.MapWith(src => src == null ? string.Empty : src.Value.ToString("R", new CultureInfo("en-us")));
|
||||
|
||||
config.NewConfig<string, decimal?>()
|
||||
.MapWith(src => string.IsNullOrEmpty(src) ? null : decimal.Parse(src));
|
||||
|
||||
config.NewConfig<Guid, string>()
|
||||
.MapWith(src => src == Guid.Empty ? string.Empty : src.ToString());
|
||||
|
||||
config.NewConfig<string, Guid>()
|
||||
.MapWith(src => string.IsNullOrEmpty(src) ? Guid.Empty : Guid.Parse(src));
|
||||
|
||||
config.NewConfig<string, Guid?>()
|
||||
.MapWith(src => string.IsNullOrEmpty(src) ? null : Guid.Parse(src));
|
||||
|
||||
config.NewConfig<Timestamp, DateTime>()
|
||||
.MapWith(src => src.ToDateTime());
|
||||
|
||||
config.NewConfig<Timestamp, DateTime?>()
|
||||
.MapWith(src => src == null ? null : src.ToDateTime());
|
||||
|
||||
config.NewConfig<DateTime, Timestamp>()
|
||||
.MapWith(src => Timestamp.FromDateTime(DateTime.SpecifyKind(src, DateTimeKind.Utc)));
|
||||
|
||||
config.NewConfig<DateTime?, Timestamp>()
|
||||
.MapWith(src => src.HasValue ? Timestamp.FromDateTime(DateTime.SpecifyKind(src.Value, DateTimeKind.Utc)) : null);
|
||||
|
||||
config.NewConfig<Duration, TimeSpan>()
|
||||
.MapWith(src => src.ToTimeSpan());
|
||||
|
||||
config.NewConfig<Duration, TimeSpan?>()
|
||||
.MapWith(src => src == null ? null : src.ToTimeSpan());
|
||||
|
||||
config.NewConfig<TimeSpan, Duration>()
|
||||
.MapWith(src => Duration.FromTimeSpan(src));
|
||||
|
||||
config.NewConfig<TimeSpan?, Duration>()
|
||||
.MapWith(src => src.HasValue ? Duration.FromTimeSpan(src.Value) : null);
|
||||
|
||||
config.Default
|
||||
.UseDestinationValue(member => member.SetterModifier == AccessModifier.None &&
|
||||
member.Type.IsGenericType &&
|
||||
member.Type.GetGenericTypeDefinition() == typeof(Google.Protobuf.Collections.RepeatedField<>));
|
||||
|
||||
config.NewConfig<Google.Protobuf.ByteString, byte[]>()
|
||||
.MapWith(src => src.ToByteArray());
|
||||
|
||||
config.NewConfig<byte[], Google.Protobuf.ByteString>()
|
||||
.MapWith(src => Google.Protobuf.ByteString.CopyFrom(src));
|
||||
}
|
||||
}
|
||||
10
src/BackOffice.BFF.WebApi/Common/Mappings/PackageProfile.cs
Normal file
10
src/BackOffice.BFF.WebApi/Common/Mappings/PackageProfile.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace BackOffice.BFF.WebApi.Common.Mappings;
|
||||
|
||||
public class PackageProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
//config.NewConfig<Source,Destination>()
|
||||
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
|
||||
}
|
||||
}
|
||||
10
src/BackOffice.BFF.WebApi/Common/Mappings/RoleProfile.cs
Normal file
10
src/BackOffice.BFF.WebApi/Common/Mappings/RoleProfile.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace BackOffice.BFF.WebApi.Common.Mappings;
|
||||
|
||||
public class RoleProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
//config.NewConfig<Source,Destination>()
|
||||
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace BackOffice.BFF.WebApi.Common.Mappings;
|
||||
|
||||
public class UserAddressProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
//config.NewConfig<Source,Destination>()
|
||||
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace BackOffice.BFF.WebApi.Common.Mappings;
|
||||
|
||||
public class UserOrderProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
//config.NewConfig<Source,Destination>()
|
||||
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
|
||||
}
|
||||
}
|
||||
10
src/BackOffice.BFF.WebApi/Common/Mappings/UserProfile.cs
Normal file
10
src/BackOffice.BFF.WebApi/Common/Mappings/UserProfile.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace BackOffice.BFF.WebApi.Common.Mappings;
|
||||
|
||||
public class UserProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
//config.NewConfig<Source,Destination>()
|
||||
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
|
||||
}
|
||||
}
|
||||
10
src/BackOffice.BFF.WebApi/Common/Mappings/UserRoleProfile.cs
Normal file
10
src/BackOffice.BFF.WebApi/Common/Mappings/UserRoleProfile.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace BackOffice.BFF.WebApi.Common.Mappings;
|
||||
|
||||
public class UserRoleProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
//config.NewConfig<Source,Destination>()
|
||||
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user