Refactoring, database structure changed
This commit is contained in:
15
WatchIt.DTO/Converters/ColorJsonConverter.cs
Normal file
15
WatchIt.DTO/Converters/ColorJsonConverter.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Drawing;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace WatchIt.DTO.Converters;
|
||||
|
||||
public class ColorJsonConverter : JsonConverter<Color>
|
||||
{
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public override Color Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ColorTranslator.FromHtml(reader.GetString());
|
||||
public override void Write(Utf8JsonWriter writer, Color value, JsonSerializerOptions options) => writer.WriteStringValue("#" + value.R.ToString("X2") + value.G.ToString("X2") + value.B.ToString("X2"));
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user