ReadLine() публичный Метод

Reads the next line of input from the YAML source.
public ReadLine ( ) : string
Результат string
Пример #1
0
        /// <summary>
        /// Attempts to parse the YAML file contents of templateFile into a YAML
        /// Node object.
        /// </summary>
        /// <returns>A YAML Node object to the root node if parsing is
        /// successful.
        /// </returns>
        public Node ParseFile(string fileName, Dictionary <string, object> variables)
        {
            // Create root node
            _stack.Clear();
            NodeLevel context = new NodeLevel()
            {
                Node = new Node(), Indentation = -2
            };

            _stack.Push(context);

            using (_preprocessor = new Preprocessor(fileName, variables))
            {
                string line;

                // Process each line of the file
                do
                {
                    line = _preprocessor.ReadLine();
                    if (line == null)
                    {
                        continue;
                    }

                    if (line.Trim().Length > 0 && !line.Trim().StartsWith("#"))
                    {
                        // First line determines type of parent collection
                        try
                        {
                            ProcessLine(line, variables);
                        }
                        catch (ParseException)
                        {
                            throw;
                        }
                        catch (Exception ex)
                        {
                            throw new ParseException("An exception occurred",
                                                     ex, _preprocessor.File, _preprocessor.Line);
                        }
                    }
                }while (line != null);
            }

            // Get root object to return; this is at the bottom of the stack
            do
            {
                context = _stack.Pop();
            }while (_stack.Count > 0);

            return(context.Node);
        }
Пример #2
0
        /// <summary>
        /// Attempts to parse the YAML file contents of templateFile into a YAML
        /// Node object.
        /// </summary>
        /// <returns>A YAML Node object to the root node if parsing is
        /// successful.
        /// </returns>
        public Node ParseFile(string fileName, Dictionary<string, object> variables)
        {
            // Create root node
            _stack.Clear();
            NodeLevel context = new NodeLevel() { Node = new Node(), Indentation = -2 };
            _stack.Push(context);

            using(_preprocessor = new Preprocessor(fileName, variables))
            {
                string line;

                // Process each line of the file
                do {
                    line = _preprocessor.ReadLine();
                    if(line == null) { continue; }

                    if(line.Trim().Length > 0 && !line.Trim().StartsWith("#")) {
                        // First line determines type of parent collection
                        try {
                            ProcessLine(line);
                        }
                        catch(ParseException) {
                            throw;
                        }
                        catch(Exception ex) {
                            throw new ParseException("An exception occurred",
                                ex, _preprocessor.File, _preprocessor.Line);
                        }
                    }
                }
                while(line != null);
            }

            // Get root object to return; this is at the bottom of the stack
            do {
                context = _stack.Pop();
            }
            while (_stack.Count > 0);

            return context.Node;
        }