public void SetExpression(string key, string value, Calculator calc) { m_key = key; m_expression = value; if (calc != null) { m_tree = ExpressionTreeNode.Parse(m_expression, calc); } m_bufferSet = false; //Find variable on forehand to make calculation faster. int propIndex = m_key.LastIndexOf(Calculator.PROPERTY_CHAR); string varName; if (propIndex != -1) { varName = m_key.Substring(0, propIndex); } else { varName = m_key; } if (calc != null) { m_variable = calc.Variable(varName); if (m_variable == null) throw new System.Exception("Invalid variable key: " + key); } m_propName = m_key.Substring(propIndex + 1); }