WriteTag() public method

public WriteTag ( ITag value ) : void
value ITag
return void
    public void WriteEmptyByteArrayTest()
    {
      // arrange
      ITagWriter target;
      NbtDocument expected;
      MemoryStream stream;
      ITagReader reader;

      expected = new NbtDocument();
      expected.DocumentRoot.Name = "WriteEmptyByteArrayTest";
      expected.DocumentRoot.Value.Add("ByteArray", new byte[0]);
      expected.DocumentRoot.Value.Add("Byte", 255);

      stream = new MemoryStream();

      target = new BinaryTagWriter(stream);

      // act
      target.WriteTag(expected.DocumentRoot, WriteTagOptions.None);

      // assert
      stream.Seek(0, SeekOrigin.Begin);
      reader = new BinaryTagReader(stream);
      this.CompareTags(expected.DocumentRoot, reader.ReadTag());
    }
Example #2
0
    public virtual byte[] GetValue()
    {
      byte[] result;

      using (MemoryStream stream = new MemoryStream())
      {
        ITagWriter writer;

        writer = new BinaryTagWriter(stream);
        writer.WriteTag(this, WriteTagOptions.None);

        result = stream.ToArray();
      }

      return result;
    }