feat(core): add internal crypto isin resolution and subtitle mapping
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace FinlyticCore.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// ValueConverter for DateTime guaranteeing DateTimeKind.Utc when writing to and reading from PostgreSQL.
|
||||
/// </summary>
|
||||
public class UtcDateTimeConverter : ValueConverter<DateTime, DateTime>
|
||||
{
|
||||
public UtcDateTimeConverter()
|
||||
: base(
|
||||
v => v.Kind == DateTimeKind.Utc ? v : DateTime.SpecifyKind(v, DateTimeKind.Utc),
|
||||
v => DateTime.SpecifyKind(v, DateTimeKind.Utc))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ValueConverter for nullable DateTime? guaranteeing DateTimeKind.Utc when writing to and reading from PostgreSQL.
|
||||
/// </summary>
|
||||
public class NullableUtcDateTimeConverter : ValueConverter<DateTime?, DateTime?>
|
||||
{
|
||||
public NullableUtcDateTimeConverter()
|
||||
: base(
|
||||
v => v.HasValue ? (v.Value.Kind == DateTimeKind.Utc ? v.Value : DateTime.SpecifyKind(v.Value, DateTimeKind.Utc)) : v,
|
||||
v => v.HasValue ? DateTime.SpecifyKind(v.Value, DateTimeKind.Utc) : v)
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user