/// <summary> /// A method adds inputted element to exists expression and validate the expression with adding a inputted element. </summary> /// <param name="input"> A inputted element </param> /// <param name="separated"> A infix notation expression InputElement list </param> /// <returns> A element adding result status </returns> public AddingElementResult GetseparatedPlainText(string input, out IEnumerable <InputElement> separated) { double inputNumber; separated = expressionElements; if (input.Length < 1) { IsLastValidationSucceed = false; return(new InvalidFormatUsed()); } if (Double.TryParse(input, out inputNumber)) { Literal InputLiteral = new Literal(input); if (IsEmptyInputElements) { expressionElements.Add(InputLiteral); IsEqualUsed = false; IsLastValidationSucceed = true; return(new AddingPossible()); } else { AddingElementResult res = expressionElements.Last().CheckPossibilityAddingElement(ref expressionElements, ref IsEqualUsed, ref IsLastValidationSucceed, InputLiteral); IsEqualUsed = false; if (res is AddingPossible) { IsLastValidationSucceed = true; } else { IsLastValidationSucceed = false; } return(res); } } InputElement inputElem = Operators.GetOperatorAsInputElement(input); IOperator inputOper = inputElem as IOperator; if (inputOper == null) { IsLastValidationSucceed = false; return(new InvalidFormatUsed()); } if (IsEmptyInputElements) { if (OperandType.LEFT == inputOper.OperandType || OperandType.BOTH == inputOper.OperandType) { // Exceptional Case : '.' => '0.' if (inputOper is Point) { expressionElements.Add(new Literal("0")); } else { return(new InvalidFormatUsed()); } } expressionElements.Add(inputElem); Operators.GetOperatorAsInputElement(input)?.PostAddingWork(ref expressionElements); IsEqualUsed = false; IsLastValidationSucceed = true; return(new AddingPossible()); } if (inputElem.AlternativeWork(ref expressionElements, ref IsEqualUsed, ref IsLastValidationSucceed)) { IsEqualUsed = false; IsLastValidationSucceed = true; return(new AddingPossible()); } // Exceptional case : Only one '.' if (input.CompareTo(".") == 0) { if (CheckDotExist()) { separated = expressionElements; IsLastValidationSucceed = true; return(new AddingImpossible()); } } else if (input.CompareTo("R") == 0) { if (ReverseSign(out separated)) { return(new AddingPossible()); } return(new InvalidFormatUsed()); } expressionElements.Last().CheckPossibilityAddingElement(ref expressionElements, ref IsEqualUsed, ref IsLastValidationSucceed, inputOper as InputElement); IsEqualUsed = false; IsLastValidationSucceed = true; return(new AddingPossible()); }