using System; using System.Collections.Generic; using Core.Components.Charting.Data; using OxyPlot; using OxyPlot.Series; namespace Core.Components.OxyPlot.Converter { /// /// Provides an abstract base class for transforming in specific /// instances. /// public abstract class ChartDataConverter { /// /// Returns the type that the can convert /// into a new instance. /// protected abstract Type SupportedType { get; } /// /// Transforms a given object into a . Can be used as a /// . /// /// The object to convert into a . /// A new based on . /// Thrown when is not /// of type of . protected static DataPoint TupleToDataPoint(object obj) { var point = (Tuple) obj; return new DataPoint(point.Item1, point.Item2); } /// /// Checks whether the can convert the . /// /// The to check for. /// true if the can be converted by the /// , false otherwise. internal bool CanConvertSeries(ChartData data) { return data.GetType() == SupportedType; } /// /// Creates one or more based on the that was given. /// /// The data to transform into a . /// A new of . internal abstract IList Convert(ChartData data); } }