Beispiel #1
0
 /// <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");
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 /// <inheritdoc/>
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     return(ArgbColor.Parse((string)value));
 }