ReadLines() public static method

public static ReadLines ( object context, TextReader reader, LineParserDelegate parser, [ lineNumber ) : bool
context object
reader TextReader
parser LineParserDelegate
lineNumber [
return bool
示例#1
0
    public override void LoadCommand(Project project, System.IO.TextReader reader, string line, ref int lineNumber)
    {
        base.LoadCommand(project, reader, line, ref lineNumber);

        List <string> parts = ProjectSerializer.ReadTokens(line);

        if (parts[parts.Count - 1] != "{")
        {
            project.Warnings.Add(string.Format("Line {0}: The Random command requires a {{ at the end of the line.", lineNumber));
        }
        else
        {
            parts.RemoveAt(0);
            parts.RemoveAt(parts.Count - 1);

            if (parts.Count == 0)
            {
                if (ProjectSerializer.ReadLines(new object[] { project, Commands }, reader, ProjectSerializer.ParseWeightedCommands, ref lineNumber))
                {
                    project.Warnings.Add(string.Format("Line {0}: The Random command is not closed correctly.", lineNumber));
                }
            }
            else
            {
                project.Warnings.Add(string.Format("Line {0}: The Random command must have no arguments.", lineNumber));
            }
        }
    }
        public override void LoadCommand(Project project, System.IO.TextReader reader, string line, ref int lineNumber)
        {
            base.LoadCommand(project, reader, line, ref lineNumber);

            List <string> parts = ProjectSerializer.ReadTokens(line);

            if (parts.Count == 2 && parts[1] == "{")
            {
                if (ProjectSerializer.ReadLines(project, reader, ReadTranslation, ref lineNumber))
                {
                    project.Warnings.Add(string.Format("Line {0}: The Translate command is not closed correctly.", lineNumber));
                }
            }
            else
            {
                project.Warnings.Add(string.Format("Line {0}: The Translate command requires a {{} at the end of the line.", lineNumber));
            }
        }
示例#3
0
        public override void LoadCommand(Project project, System.IO.TextReader reader, string line, ref int lineNumber)
        {
            base.LoadCommand(project, reader, line, ref lineNumber);

            List <string> parts = ProjectSerializer.ReadTokens(line);

            if (parts[parts.Count - 1] != "{")
            {
                project.Warnings.Add(string.Format("Line {0}: The Loop command requires a {{ at the end of the line.", lineNumber));
            }
            else
            {
                parts.RemoveAt(0);
                parts.RemoveAt(parts.Count - 1);

                if (parts.Count > 0)
                {
                    int reps;
                    foreach (string rep in parts)
                    {
                        if (int.TryParse(rep, out reps))
                        {
                            Repetitions.Add(reps);
                        }
                        else
                        {
                            project.Warnings.Add(string.Format("Line {0}: The loop command requires all arguments to be numeric. '{1}' is not.", lineNumber, rep));
                        }
                    }

                    if (ProjectSerializer.ReadLines(new object[] { project, Commands }, reader, ProjectSerializer.ParseCommands, ref lineNumber))
                    {
                        project.Warnings.Add(string.Format("Line {0}: The loop command is not closed correctly.", lineNumber));
                    }
                }
                else
                {
                    project.Warnings.Add(string.Format("Line {0}: The loop command must have one or more numeric arguments.", lineNumber));
                }
            }
        }