0

I’m attempting to attach a generic/abstract DataSeries to an INotifyPropertyChanged object. However, the TX, TY generics seem to block me from using it as expected. Can anyone help me out?

More info on the abstract class: https://www.scichart.com/documentation/v5.x/webframe.html#SciChart.Charting~SciChart.Charting.Model.DataSeries.DataSeries%602.html

internal class DataSeriesAbstract : INotifyPropertyChanged
{
    public string dataName;
    public double lastAppendedTimestamp = 0.0f;

    public List<AbstractChartViewModel> subscribers;

    // gives an error that TX and TY cannot be found
    public DataSeries<TX, TY> realData;
    public DataSeries<TX, TY> Data
    {
        get { return realData; }
        set
        {
            realData = value;
            OnPropertyChanged(dataName);
        }
    }
...
}

Thank you,
Mike

slacker
  • 137
  • 9

2 Answers2

3

Your class would need to provide the generics as well. This would change your class declaration to be as follows:

internal class DataSeriesAbstract<TX, TY> : INotifyPropertyChanged where TX : IComparable where TY : IComparable

The where constraints will be critical if you do this, because the DataSeries has those same constraints.

Now, if you know the concrete types for your data series, you can just use that instead of the TX, TY. For example:

public DataSeries<double, double> realData;
public DataSeries<double, double> Data
0

At minimum, you will need to add them as generic parameters to the class, plus any constraints

internal class DataSeriesAbstract<TX, TY>: INotifyPropertyChanged
{
   ...

Additional Resources

Generic Classes (C# Programming Guide)

TheGeneral
  • 79,002
  • 9
  • 103
  • 141