Beispiel #1
0
        public bool Read()
        {
            string line = BaseReader.ReadLine();

            if (line == null)
            {
                return(false);
            }

            // This removes preceeding whitespace on continued lines
            line = line.Trim();

            // Skip blank lines
            while (line.Length == 0)
            {
                line = BaseReader.ReadLine();
                if (line == null)
                {
                    return(false);
                }
                line = line.Trim();
            }

            // This is a category line
            if (line.StartsWith("[", StringComparison.Ordinal))
            {
                if (line.EndsWith("]", StringComparison.Ordinal))
                {
                    EnterCategory(line);
                }
                else
                {
                    throw RuntimeFailure.PropertiesCategoryMissingBrackets();
                }
            }
            else
            {
                // Either pick this as a comment or a property
                if (line[0] == ';' || line[0] == '!' || line[0] == '#')
                {
                    EnterComment(line);
                }
                else
                {
                    StringBuilder buffer = new StringBuilder();
                    // Deal with line continuations \
                    // New to 1.3: assume that if a equals sign is missing, it is part
                    // of the previous line

                    while (line != null && line.EndsWith("\\", StringComparison.Ordinal))
                    {
                        buffer.Append(line, 0, line.Length - 1);
                        line = this.BaseReader.ReadLine();

                        if (line != null)
                        {
                            line = line.Trim();
                        }
                    }
                    if (line != null)
                    {
                        buffer.AppendLine(line);
                    }
                    EnterText(buffer.ToString());
                }
            }

            return(true);
        }