Esempio n. 1
0
        private void WriteObject(VpcObject obj)
        {
            if (obj.Any())
            {
                _writer.Write(' ');
                if (obj.IsArray)
                {
                    _writer.Write(_writer.NewLine);
                    WriteIndentation();
                    _writer.WriteLine("{");
                    _indentation++;

                    foreach (var item in obj)
                    {
                        WriteArrayValue(item);
                    }

                    _indentation--;
                    WriteIndentation();
                    _writer.Write("}");
                    _lastArrayTag = true;
                }
                else
                {
                    // write string value
                    _writer.Write($"\"{(string)obj.First().Value}\"");
                }
            }

            WriteConditions(obj.Conditions);
            _writer.Write(_writer.NewLine);
        }
Esempio n. 2
0
 internal VpcSerialiser(Stream stream, VpcObject obj)
 {
     _writer = new StreamWriter(stream, Encoding.UTF8, 1024, true)
     {
         NewLine = "\n"
     };
     _object = obj;
 }
Esempio n. 3
0
        private void WriteFullObject(VpcObject obj)
        {
            // Extra newline is placed for array closing tags.
            if (_lastArrayTag)
            {
                _writer.Write('\n');
                _lastArrayTag = false;
            }

            WriteIndentation();

            // Write type
            _writer.Write($"${obj.Type}");

            // Write key (if present)
            if (!string.IsNullOrEmpty(obj.Key))
            {
                _writer.Write($" \"{obj.Key}\"");
            }

            WriteObject(obj);
        }