public static bool CanBeElement(string testString, out FormulaElement element)
        {
            bool canBe = false;

            canBe |= Bracket.CanBeBracket(testString, out Bracket bracket);
            if (bracket is object)
            {
                element = bracket;
                return(true);
            }

            canBe |= Operation.CanBeOperation(testString, out Operation op);
            if (op is object)
            {
                element = op;
                return(true);
            }

            canBe |= Variable.CanBeVariable(testString, out Variable variable);
            if (variable is object)
            {
                element = variable;
                return(true);
            }

            element = null;
            return(canBe);
        }
Beispiel #2
0
 public static bool IsPair(Bracket first, Bracket second)
 {
     foreach (var pair in _instances)
     {
         if ((pair[0] == first && pair[1] == second) ||
             (pair[0] == second && pair[1] == first))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #3
0
        public static bool CanBeBracket(string testString, out Bracket bracket)
        {
            bool canBe = false;

            foreach (var pair in _instances)
            {
                foreach (Bracket b in pair)
                {
                    canBe |= b.Name.StartsWith(testString);
                    if (b.Name.Equals(testString))
                    {
                        bracket = b;
                        return(true);
                    }
                }
            }
            bracket = null;
            return(canBe);
        }
 public static bool CanBeElement(string testString)
 {
     return(Bracket.CanBeBracket(testString) || Operation.CanBeOperation(testString) ||
            Variable.CanBeVariable(testString));
 }