Esempio n. 1
0
        /// <inheritdoc/>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            var color = value as ArgbColor;

            if (color != null)
            {
                return(ArgbColor.ToHtml(color));
            }
            throw new NotSupportedException();
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            switch (value as IColor)
            {
            case IArgbColor argbColor:
                writer.WriteValue(ArgbColor.ToHtml(argbColor));
                break;

            default:
                throw new NotSupportedException($"The {value.GetType()} color type is not supported.");
            }
        }
Esempio n. 3
0
 /// <inheritdoc/>
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     return(value is ArgbColor color?ArgbColor.ToHtml(color) : throw new NotSupportedException());
 }
Esempio n. 4
0
 /// <inheritdoc/>
 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     writer.WriteValue(ArgbColor.ToHtml((ArgbColor)value));
 }
Esempio n. 5
0
        public void ToHtml_Should_Return_Color_String_Statring_With_Hash()
        {
            var target = _factory.CreateArgbColor(0xFF, 0x7F, 0x5A, 0x45);

            Assert.Equal("#FF7F5A45", ArgbColor.ToHtml(target));
        }