/// <summary> /// Display all valid options at <see cref="cs"/>. /// </summary> private void displayOptions() { displayTitle(); log.info("Valid boolean operators:"); log.info("\n"); foreach (var op in operatorActions) { log.info( string.Format("\t['{0}']. {1}: {2}", op.Value.keys.Select(key => key.ToString()).ToList().toStringSeparator("' or '"), op.Key.ToString().toUpperCaseSeparator(), op.Value.symbol )); } log.info("\n"); foreach (var extra in extraActions) { log.info( string.Format("\t['{0}']: {1}", extra.Key.ToString(), extra.Value )); } log.info(string.Format("\t['{0}']. Execute expression.", executionKey.ToString())); log.info( string.Format("\t['{0}']. Remove last addition.", deletionKeys.Select(key => key.ToString()).ToList().toStringSeparator("' or '") )); log.info("\n"); log.warning( string.Format("{0}", hasParenthesis && isMissingParenthesis ? "Missing parenthesis on expression!" : "" )); log.info("\n"); log.info( string.Format("Expression: {0}", string.IsNullOrEmpty(expression) ? "empty" : expression )); }
/// <summary> /// Handle <see cref="ck"/> based on its own dependency. /// </summary> /// <param name="key"></param> private void handleKeys(ck key) { if (allowedKeys.Contains(key)) { if (letterKeys.Contains(key)) { expression += key.ToString().ToUpperInvariant(); } if (optionKeys.Contains(key)) { expression += getOperation(key).symbol; } if (deletionKeys.Contains(key) && !string.IsNullOrEmpty(expression)) { expression = expression.Remove(expression.Length - 1); } if (parenthesisKeys.Contains(key)) { expression += extraActions[key]; } handleParenthesis(); if (executionKey == key) { if (!isEmpty()) { if (hasParenthesis) { if (isMissingParenthesis) { log.error("\r\nExpression is invalid due missing parenthesis statement!"); log.info("\n"); log.warning("Press any key to continue..."); cs.ReadKey(true); cs.Clear(); handleCalculator(); return; } } handleExecution(); return; } else { log.error("\r\nExpression is empty!"); log.info("\n"); log.warning("Press any key to continue..."); cs.ReadKey(true); } } } else { log.error($"\rConsole key '{key.ToString()}' isn't allowed!"); log.info("\n"); log.warning("Press any key to continue..."); cs.ReadKey(true); } cs.Clear(); handleCalculator(); }