public Calculator(DataSet dataSet) { // Attach this OperationalData = dataSet; // Subscribe to Data change events. OperationalData.DataChanged += Addition; OperationalData.DataChanged += Subtract; OperationalData.DataChanged += Multiplication; OperationalData.DataChanged += Division; }
public CalculatorViewModel() { CalculationData = new DataSet(); CalculationData.A = 45; CalculationData.B = 9; Calculator = new Calculator(CalculationData); Calculator.Add = 12; Calculator.Sub = 21; Calculator.Mul = 12; Calculator.Div = 21; }
private static void Main(string[] args) { var data = new DataSet(); data.A = 3; data.B = 4; var calculator = new Calculator(data); data.A = 6; // This will // Unsubscribe from all events. calculator.Dispose(); }