Skip to main content
Skip Navigation LinksHome Extending the Spotfire Platform Creating Extensions to the Spotfire Platform Creating a Transformation Transformation: Returning a Column of Undefined Data Type

©Spotfire 2008

Transformation: Returning a Column of Undefined Data Type

This reader adds a new column to the data set which contains a Color object, a data type that is not a supported in Spotfire. The example only shows the reader.

private class ColorTransformationReader : CustomDataRowReader { private DataRowReader input; private List<DataRowReaderColumn> columns; private MutableValueCursor<object> colorCursor; private Random random; public ColorTransformationReader(DataRowReader input) { this.random = new Random(); this.input = input; this.columns = new List<DataRowReaderColumn>(); this.columns.AddRange(input.Columns); this.colorCursor = (MutableValueCursor<object>) DataValueCursor.CreateMutableCursor(DataType.Undefined); this.columns.Add( new DataRowReaderColumn( "Color", DataType.Undefined, new DataColumnProperties(), this.colorCursor)); } protected override IEnumerable<DataRowReaderColumn> GetColumnsCore() { return this.columns; } protected override ResultProperties GetResultPropertiesCore() { return new ResultProperties(); } protected override bool MoveNextCore() { if (!this.input.MoveNext()) { return false; } Color c = random.NextDouble() > 0.5 ? Color.DarkMagenta : Color.ForestGreen; colorCursor.MutableDataValue.Value = c; return true; } protected override void ResetCore() { this.input.Reset(); } }