public static void EnsureAutomataIsOfType(this Automata automata, AutomataType automataType, Exception throwException)
 {
     ValidationUtils.EnsureEquals(
         automataType.ToString(),
         automata.GetAutomataType().ToString(),
         throwException
         );
 }
Beispiel #2
0
        public override String ToString()
        {
            String newLine        = Environment.NewLine;
            String tab            = "\t";
            String quoteChar      = "'";
            String commaSeparator = ", ";
            String type           = tab + quoteChar + AutomataType.ToString() + quoteChar;
            String states         = "";
            String symbols        = "";
            String initialState   = tab + quoteChar + InitialState?.ToString() + quoteChar;
            String finalStates    = tab;
            String transitions    = "";

            States.ForEach(
                x => states += quoteChar + x.ToString() + quoteChar + commaSeparator
                );
            if (states.Length >= 3)
            {
                states = states.Substring(0, states.Length - 2);
            }
            Symbols.ForEach(
                x => symbols += quoteChar + x + quoteChar + commaSeparator
                );
            if (symbols.Length >= 3)
            {
                symbols = symbols.Substring(0, symbols.Length - 2);
            }
            FinalStates.ForEach(
                x => finalStates += quoteChar + x.ToString() + quoteChar + commaSeparator
                );
            if (finalStates.Length >= 3)
            {
                finalStates = finalStates.Substring(0, finalStates.Length - 2);
            }
            Transitions.ForEach(
                x => transitions += tab + quoteChar + x.ToString() + quoteChar + newLine
                );

            return
                ($"Type: {newLine}{type}{newLine}" +
                 $"States: {newLine}{tab}{states}{newLine}" +
                 $"Symbols: {newLine}{tab}{symbols}{newLine}" +
                 $"InitialState: {newLine}{initialState}{newLine}" +
                 $"FinalStates: {newLine}{finalStates}{newLine}" +
                 $"Transitions: {newLine}{transitions}");
        }
Beispiel #3
0
 public static String SerializeType(AutomataType type)
 {
     return(type.ToString());
 }