/// <summary> /// Creates a deep clone of the source object. /// </summary> /// <returns>A deep clone.</returns> public ComputedExpression DeepClone() { var registry = new StandardParameterRegistry(stringFormatters); var context = new NodeCloningContext { ParameterRegistry = registry, SpecialRequestFunction = specialObjectRequestFunc }; return(new ComputedExpression(initialExpression, body?.DeepClone(context), RecognizedCorrectly, registry, stringFormatters, specialObjectRequestFunc)); }
internal WorkingExpressionSet( string expression, MathDefinition mathDefinition, Dictionary <string, Type> nonaryFunctions, Dictionary <string, Type> unaryFunctions, Dictionary <string, Type> binaryFunctions, Dictionary <string, Type> ternaryFunctions, LevelDictionary <Type, IConstantsExtractor> extractors, LevelDictionary <Type, IConstantInterpreter> interpreters, List <IStringFormatter> stringFormatters, CancellationToken cancellationToken) { ParameterRegistry = new StandardParameterRegistry(stringFormatters); ConstantsTable = new Dictionary <string, ConstantNodeBase>(); ReverseConstantsTable = new Dictionary <string, string>(); SymbolTable = new Dictionary <string, ExpressionSymbol>(); ReverseSymbolTable = new Dictionary <string, string>(); StringFormatters = stringFormatters; CancellationToken = cancellationToken; Expression = expression; Definition = mathDefinition; AllOperatorsInOrder = new[] { mathDefinition.GreaterThanOrEqualSymbol, mathDefinition.LessThanOrEqualSymbol, mathDefinition.GreaterThanSymbol, mathDefinition.LessThanSymbol, mathDefinition.NotEqualsSymbol, mathDefinition.EqualsSymbol, mathDefinition.XorSymbol, mathDefinition.OrSymbol, mathDefinition.AndSymbol, mathDefinition.AddSymbol, mathDefinition.SubtractSymbol, mathDefinition.DivideSymbol, mathDefinition.MultiplySymbol, mathDefinition.PowerSymbol, mathDefinition.LeftShiftSymbol, mathDefinition.RightShiftSymbol, mathDefinition.NotSymbol }; NonaryFunctions = nonaryFunctions; UnaryFunctions = unaryFunctions; BinaryFunctions = binaryFunctions; TernaryFunctions = ternaryFunctions; Extractors = extractors; Interpreters = interpreters; FunctionRegex = new Regex( $@"(?'functionName'.*?){Regex.Escape(mathDefinition.Parentheses.Left)}(?'expression'.*?){Regex.Escape(mathDefinition.Parentheses.Right)}"); }