public override void Write(Utf8JsonWriter writer, IndexableOption <T> value, JsonSerializerOptions options)
 {
     if (value.IsIndexed && value.IndexedValues != null)
     {
         JsonSerializer.Serialize(writer, value.IndexedValues, value.IndexedValues.GetType(), options);
     }
     else if (value.SingleValue != null)
     {
         JsonSerializer.Serialize(writer, value.SingleValue, value.SingleValue.GetType(), options);
     }
 }
Esempio n. 2
0
 protected ChartDataset(
     string label,
     IndexableOption <object> backgroundColor,
     IndexableOption <object> borderColor,
     int borderWidth
     )
 {
     Label           = label;
     BackgroundColor = backgroundColor;
     BorderColor     = borderColor;
     BorderWidth     = borderWidth;
 }
Esempio n. 3
0
        /// <summary>
        /// Determines whether the specified <see cref="IndexableOption{T}"/> instance is considered equal to the current instance.
        /// </summary>
        /// <param name="other">The <see cref="IndexableOption{T}"/> to compare with.</param>
        /// <returns>true if the objects are considered equal; otherwise, false.</returns>
        public bool Equals(IndexableOption <T> other)
        {
            if (IsIndexed != other.IsIndexed)
            {
                return(false);
            }

            if (IsIndexed)
            {
                if (IndexedValues == other.IndexedValues)
                {
                    return(true);
                }

                return(Enumerable.SequenceEqual(IndexedValues, other.IndexedValues));
            }
            else
            {
                return(EqualityComparer <T> .Default.Equals(SingleValue, other.SingleValue));
            }
        }