示例#1
0
        private VObject ReadObject(VdfReader reader)
        {
            VObject result = new VObject();

            if (!reader.ReadToken())
            {
                throw new VdfException("Incomplete VDF data.");
            }

            while (!(reader.CurrentState == VdfReader.State.Object && reader.Value == VdfStructure.ObjectEnd.ToString()))
            {
                if (reader.CurrentState == VdfReader.State.Comment)
                {
                    result.Add(VValue.CreateComment(reader.Value));
                }
                else
                {
                    result.Add(ReadProperty(reader));
                }

                if (!reader.ReadToken())
                {
                    throw new VdfException("Incomplete VDF data.");
                }
            }

            return(result);
        }
示例#2
0
        private VProperty ReadProperty(VdfReader reader)
        {
            // Setting it to null is temporary, we'll set Value in just a second.
            VProperty result = new VProperty(reader.Value, null !);

            if (!reader.ReadToken())
            {
                throw new VdfException("Incomplete VDF data.");
            }

            // For now, we discard these comments.
            while (reader.CurrentState == VdfReader.State.Comment)
            {
                if (!reader.ReadToken())
                {
                    throw new VdfException("Incomplete VDF data.");
                }
            }

            if (reader.CurrentState == VdfReader.State.Property)
            {
                result.Value = new VValue(reader.Value);
            }
            else
            {
                result.Value = ReadObject(reader);
            }

            return(result);
        }
示例#3
0
        private VObject ReadObject(VdfReader reader)
        {
            VObject result = new VObject();

            reader.ReadToken();
            while (reader.CurrentState != EVdfReaderState.Object || reader.Value != VdfStructure.ObjectEnd.ToString())
            {
                result.Add(ReadProperty(reader));
                reader.ReadToken();
            }

            return result;
        }
示例#4
0
        private VProperty ReadProperty(VdfReader reader)
        {
            VProperty result = new VProperty();
            result.Key = reader.Value;

            reader.ReadToken();
            if (reader.CurrentState == EVdfReaderState.Property)
                result.Value = new VValue(reader.Value);
            else
                result.Value = ReadObject(reader);

            return result;
        }