fitSharp
Write Our Own Cell Operator
Cell Operators are classes that change the default handling of cells. For example, we can write a cell operator that lets us put the string "pi" in a cell and treats this as a numeric value instead of a string.

Every cell operator inherits from fitSharp.Fit.Operators.CellOperator. There are five different types of operator interfaces we can implement, each controlling a different aspect of cell behavior:Our cell operator class is going to change how we parse cell contents, so we implement fitSharp.Machine.Engine.ParseOperator<Cell>.
using fitSharp.Fit.Operators;
using fitSharp.Machine.Engine;
public class ParsePi: CellOperator, ParseOperator<Cell> {
The CanParse method override determines which cells are processed by our operator. We check for "pi" in the cell and also that we are working with a numeric type. This preserves normal behavior if we're using "pi" as a string input or expected value.
  public bool CanParse(Type type, TypedValue instance, Tree<Cell> parameters) {
    return type == typeof(double) && parameters.Value.Text == "pi";
  }
Overriding the Parse method changes the behavior when the cell is parsed to create an input or an expected value.
  public TypedValue Parse(Type type, TypedValue instance, TreeTree<Cell> parameters) {
    return new TypedValue(System.Math.PI);
  }
}

Copyright © 2022 Syterra Software Inc. All rights reserved.