This commit is contained in:
King
2025-09-28 15:24:13 +03:30
parent 514b3a5975
commit 4241523443
222 changed files with 8139 additions and 0 deletions

View 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));
}
}

View 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}");
}
}

View 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}");
}
}

View File

@@ -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}");
}
}

View File

@@ -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}");
}
}

View 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}");
}
}

View 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}");
}
}