Ejemplo n.º 1
0
        //private static regexMarkerCollection<consoleStyleMarkerEnum> _consoleStyleMarkers;/
        //public static regexMarkerCollection<consoleStyleMarkerEnum> consoleStyleMarkers

        public static void consoleWriteLine(String line, Boolean breakLine = true)
        {
            regexMarkerResultCollection <consoleStyleMarkerEnum> result = consolePlatformExtensions.consoleStyleMarkers.process(line);
            ConsoleColor lastColor = Console.ForegroundColor;
            ConsoleColor lastBg    = Console.BackgroundColor;

            foreach (regexMarkerResult res in result.GetByOrder())
            {
                if ((consoleStyleMarkerEnum)res.marker == result.defaultMarker)
                {
                    Console.ForegroundColor = lastColor;
                    Console.BackgroundColor = lastBg;
                }
                else
                {
                    regexMarkerForConsole regRule = consolePlatformExtensions.consoleStyleMarkers[(consoleStyleMarkerEnum)res.marker] as regexMarkerForConsole;

                    Console.ForegroundColor = regRule.foreground;
                    Console.BackgroundColor = regRule.background;
                }
                Console.Write(res.content);
            }
            if (breakLine)
            {
                Console.WriteLine();
            }

            Console.ForegroundColor = lastColor;
            Console.BackgroundColor = lastBg;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Interprets the specified code into graph instruction sequence
        /// </summary>
        /// <param name="code">The code.</param>
        /// <returns></returns>
        public GraphBuildInstructionSequence Interpret(String code)
        {
            GraphBuildInstructionSequence output = new GraphBuildInstructionSequence();

            List <String> lines = code.SplitSmart(Environment.NewLine);

            foreach (String line in lines)
            {
                regexMarkerResultCollection syntaxInstructions = SyntaxMarkers.process(line);
                foreach (regexMarkerResult result in syntaxInstructions.GetByOrder())
                {
                    GraphBuildInstruction instruction = new GraphBuildInstruction()
                    {
                        InstructionType = result.marker,
                        Parameters      = result.GetGroups()
                    };
                    output.Add(instruction);
                }

                output.Add(new GraphBuildInstruction());
            }

            return(output);
        }