public void ReplaceLastOperand(IOperand operand) { if (Operands.Count == 0) { throw new InvalidOperationException("There are no operands to replace."); } int stealIndex = Operands.Count - 1; NativeOperation op = Operands[stealIndex] as NativeOperation; // Check if the "steal" target is itself something that we can steal from, if so, // recurse. This rule of checkiung association type is a bit confusing, this should // be a property? if (op != null && op.Operands.Count > 1 && op.AssociationType == AssociationType.Multiplicaton) { IOperation func = (IOperation)op; func.ReplaceLastOperand(operand); } else { _Operands[Operands.Count - 1] = operand; } }
protected override IOperand CopyTo(IOperand operand) { NativeOperation target = (NativeOperation)operand; foreach (var item in _Operators) { target._Operators.Add(item); } return(base.CopyTo(target)); }