private static void GetPart(FormulaExpression expression, string partToken)
 {
     var signEqMatch = ExpressionRegexp.OperatorRegex.Match(expression.StringExpression);
     var signEqIndex = signEqMatch.Index;
     var sPart = partToken == "Left" 
         ? expression.StringExpression.Substring(0, signEqIndex).Trim() 
         : expression.StringExpression.Substring(signEqIndex + signEqMatch.Length).Trim();
     if (sPart == "")
     {
         Logger.Error("Часть выражения записана неверно");
     }
     var part = new FormulaExpressionPart(expression, sPart);
     if (partToken == "Left")
         expression.TargetPart = part;
     else
         expression.SourcePart = part;
     var captures = ExpressionRegexp.OperandRegex.Matches(sPart);
     for (var i = 0; i < captures.Count; i++)
     {
         var a1Ref = captures[i].Value.Trim();
         var varName = String.Format("v{0}", i);
         part.Variables.Add(varName, a1Ref);
         part.StringExpressionPart = part.StringExpressionPart.Replace(a1Ref, varName);
     }
 }
 public FormulaExpressionPart(FormulaExpression expression, string stringExpressionPart)
 {
     this.Expression = expression;
     this.Variables = new Dictionary<string, string>();
     _calc = new CalculationEngine();
     this.StringExpressionPart = stringExpressionPart;
 }
 public static FormulaExpression Parse(string exp)
 {
     var resultExp = new FormulaExpression();
     resultExp.StringExpression = exp;
     GetPart(resultExp, "Left");
     GetPart(resultExp, "Right");
     return resultExp;
 }