Akka.Configuration.Hocon.HoconTokenizer.PullNext C# (CSharp) Метод

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

Retrieves the next token from the string.
/// This exception is thrown when an unknown token is encountered. ///
public PullNext ( ) : Akka.Configuration.Hocon.Token
Результат Akka.Configuration.Hocon.Token
        public Token PullNext()
        {
            PullWhitespaceAndComments();
            if (IsDot())
            {
                return PullDot();
            }
            if (IsObjectStart())
            {
                return PullStartOfObject();
            }
            if (IsEndOfObject())
            {
                return PullEndOfObject();
            }
            if (IsAssignment())
            {
                return PullAssignment();
            }
            if (IsInclude())
            {
                return PullInclude();
            }
            if (IsStartOfQuotedKey())
            {
                return PullQuotedKey();
            }
            if (IsUnquotedKeyStart())
            {
                return PullUnquotedKey();
            }
            if (IsArrayStart())
            {
                return PullArrayStart();
            }
            if (IsArrayEnd())
            {
                return PullArrayEnd();
            }
            if (EoF)
            {
                return new Token(TokenType.EoF);
            }
            throw new FormatException("unknown token");
        }

Usage Example

Пример #1
0
        private void ParseObject(HoconValue owner, bool root, string currentPath)
        {
            if (owner.IsObject())
            {
                //the value of this KVP is already an object
            }
            else
            {
                //the value of this KVP is not an object, thus, we should add a new
                owner.NewValue(new HoconObject());
            }

            HoconObject currentObject = owner.GetObject();

            while (!_reader.EoF)
            {
                Token t = _reader.PullNext();
                switch (t.Type)
                {
                case TokenType.Include:
                    var included      = _includeCallback(t.Value);
                    var substitutions = included.Substitutions;
                    foreach (var substitution in substitutions)
                    {
                        //fixup the substitution, add the current path as a prefix to the substitution path
                        substitution.Path = currentPath + "." + substitution.Path;
                    }
                    _substitutions.AddRange(substitutions);
                    var otherObj = included.Value.GetObject();
                    owner.GetObject().Merge(otherObj);

                    break;

                case TokenType.EoF:
                    break;

                case TokenType.Key:
                    HoconValue value    = currentObject.GetOrCreateKey(t.Value);
                    var        nextPath = currentPath == "" ? t.Value : currentPath + "." + t.Value;
                    ParseKeyContent(value, nextPath);
                    if (!root)
                    {
                        return;
                    }
                    break;

                case TokenType.ObjectEnd:
                    return;
                }
            }
        }
All Usage Examples Of Akka.Configuration.Hocon.HoconTokenizer::PullNext