/// <inheritdoc/> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (objectType == typeof(ArgbColor)) { return(ArgbColor.Parse((string)reader.Value)); } throw new ArgumentException("objectType"); }
public void Parse_String_Using_Predefined_Color_Names() { var target = ArgbColor.Parse("Magenta"); Assert.Equal(0xFF, target.A); Assert.Equal(0xFF, target.R); Assert.Equal(0x00, target.G); Assert.Equal(0xFF, target.B); }
public void Parse_String_Statring_With_Hash_And_No_Alpha_Channel() { var target = ArgbColor.Parse("#ABCDEF"); Assert.Equal(0xFF, target.A); Assert.Equal(0xAB, target.R); Assert.Equal(0xCD, target.G); Assert.Equal(0xEF, target.B); }
/// <inheritdoc/> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { return(ArgbColor.Parse((string)value)); }