public static Offset <SyncIDList> CreateSyncIDList(FlatBufferBuilder builder, ushort length = 0, VectorOffset listOffset = default(VectorOffset)) { builder.StartObject(2); SyncIDList.AddList(builder, listOffset); SyncIDList.AddLength(builder, length); return(SyncIDList.EndSyncIDList(builder)); }
public static byte[] SerializeSyncIDList(List <string> syncObjects) { var builder = new FlatBufferBuilder(1); int length = syncObjects.Count; StringOffset[] names = new StringOffset[length]; for (int index = 0; index < length; index++) { names[index] = builder.CreateString(syncObjects[index]); } Offset <SyncObjectID>[] off = new Offset <SyncObjectID> [length]; for (int index = 0; index < length; index++) { SyncObjectID.StartSyncObjectID(builder); SyncObjectID.AddId(builder, (ushort)index); SyncObjectID.AddName(builder, names[index]); off[index] = SyncObjectID.EndSyncObjectID(builder); } var ids = SyncIDList.CreateListVector(builder, off); SyncIDList.StartSyncIDList(builder); SyncIDList.AddLength(builder, (ushort)length); SyncIDList.AddList(builder, ids); var list = SyncIDList.EndSyncIDList(builder); SyncIDList.FinishSyncIDListBuffer(builder, list); using (var ms = new MemoryStream(builder.DataBuffer.Data, builder.DataBuffer.Position, builder.Offset)) { var data = ms.ToArray(); return(data); } }