Example #1
0
        public void WriteLayersDeep(int depth)
        {
            List <(string key, object value)> kvps;

            using (var writer = new ManagedBinaryWriter(_memoryStream, Symbols.EmptySymbolTablesArray))
            {
                writer.StepIn(IonType.Struct);
                for (var i = 0; i < depth - 1; i++)
                {
                    writer.SetFieldName($"layer{i}");
                    writer.StepIn(IonType.Struct);
                }

                kvps = WriteFlat(writer);

                for (var i = 0; i < depth; i++)
                {
                    writer.StepOut();
                }

                writer.Flush();
            }

            var reader = new UserBinaryReader(new MemoryStream(_memoryStream.GetWrittenBuffer()));

            for (var i = 0; i < depth - 1; i++)
            {
                Console.WriteLine(i);
                Assert.AreEqual(IonType.Struct, reader.MoveNext());
                Console.WriteLine(reader.CurrentFieldName);
                reader.StepIn();
            }

            ReadUtils.AssertFlatStruct(reader, kvps);
        }
Example #2
0
        public void WriteFlatStruct()
        {
            List <(string key, object value)> kvps;

            using (var writer = new ManagedBinaryWriter(_memoryStream, Symbols.EmptySymbolTablesArray))
            {
                writer.StepIn(IonType.Struct);

                kvps = WriteFlat(writer);

                writer.StepOut();
                writer.Flush();
            }

            var reader = new UserBinaryReader(new MemoryStream(_memoryStream.GetWrittenBuffer()));

            ReadUtils.AssertFlatStruct(reader, kvps);
        }
Example #3
0
        public void WriteFlatStruct()
        {
            using (var stream = new MemoryStream())
            {
                List <(string key, object value)> kvps;
                IIonWriter writer;
                using (writer = new ManagedBinaryWriter(BinaryConstants.EmptySymbolTablesArray))
                {
                    writer.StepIn(IonType.Struct);

                    kvps = WriteFlat(writer);

                    writer.StepOut();
                    writer.Flush(stream);
                }

                var reader = new UserBinaryReader(new MemoryStream(stream.ToArray()));
                ReadUtils.AssertFlatStruct(reader, kvps);
            }
        }