Ejemplo n.º 1
0
        BookShelfFlat DataFlat(int nToCreate)
        {
            var builder = new FlatBufferBuilder(1024);

            Offset <BookFlat>[] books = new Offset <BookFlat> [nToCreate];

            for (int i = 1; i <= nToCreate; i++)
            {
                var title = builder.CreateString($"Book {i}");
                builder.StartVector(1, BookDataSize, 0);
                byte[] bytes = CreateAndFillByteBuffer();
                if (bytes.Length > 0)
                {
                    builder.Put(bytes);
                }
                VectorOffset bookbyteArrayOffset = builder.EndVector();
                var          bookOffset          = BookFlat.CreateBookFlat(builder, title, i, bookbyteArrayOffset);
                books[i - 1] = bookOffset;
            }

            var          secretOffset = builder.CreateString("private member value");
            VectorOffset booksVector  = builder.CreateVectorOfTables <BookFlat>(books);
            var          lret         = BookShelfFlat.CreateBookShelfFlat(builder, booksVector, secretOffset);

            builder.Finish(lret.Value);
            var bookshelf = BookShelfFlat.GetRootAsBookShelfFlat(builder.DataBuffer);

            return(bookshelf);
        }
Ejemplo n.º 2
0
        BookShelfFlat DataFlat(int nToCreate)
        {
            var builder = new FlatBufferBuilder(1024);

            Offset <BookFlat>[] books = new Offset <BookFlat> [nToCreate];

            for (int i = 1; i <= nToCreate; i++)
            {
                var title      = builder.CreateString($"Book {i}");
                var bookOffset = BookFlat.CreateBookFlat(builder, title, i);
                books[i - 1] = bookOffset;
            }

            var          secretOffset = builder.CreateString("private member value");
            VectorOffset booksVector  = builder.CreateVectorOfTables <BookFlat>(books);
            var          lret         = BookShelfFlat.CreateBookShelfFlat(builder, booksVector, secretOffset);

            builder.Finish(lret.Value);
            var bookshelf = BookShelfFlat.GetRootAsBookShelfFlat(builder.DataBuffer);

            return(bookshelf);
        }