1 // <auto-generated>
2 //  automatically generated by the FlatBuffers compiler, do not modify
3 // </auto-generated>
4 
5 using global::System;
6 using global::System.Collections.Generic;
7 using global::FlatBuffers;
8 
9 public struct Movie : IFlatbufferObject
10 {
11   private Table __p;
12   public ByteBuffer ByteBuffer { get { return __p.bb; } }
ValidateVersionMovie13   public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_1_12_0(); }
GetRootAsMovieMovie14   public static Movie GetRootAsMovie(ByteBuffer _bb) { return GetRootAsMovie(_bb, new Movie()); }
GetRootAsMovieMovie15   public static Movie GetRootAsMovie(ByteBuffer _bb, Movie obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
MovieBufferHasIdentifierMovie16   public static bool MovieBufferHasIdentifier(ByteBuffer _bb) { return Table.__has_identifier(_bb, "MOVI"); }
__initMovie17   public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
__assignMovie18   public Movie __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
19 
20   public Character MainCharacterType { get { int o = __p.__offset(4); return o != 0 ? (Character)__p.bb.Get(o + __p.bb_pos) : Character.NONE; } }
21   public TTable? MainCharacter<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(6); return o != 0 ? (TTable?)__p.__union<TTable>(o + __p.bb_pos) : null; }
MainCharacterAsStringMovie22   public string MainCharacterAsString() { int o = __p.__offset(6); return o != 0 ? __p.__string(o + __p.bb_pos) : null; }
CharactersTypeMovie23   public Character CharactersType(int j) { int o = __p.__offset(8); return o != 0 ? (Character)__p.bb.Get(__p.__vector(o) + j * 1) : (Character)0; }
24   public int CharactersTypeLength { get { int o = __p.__offset(8); return o != 0 ? __p.__vector_len(o) : 0; } }
25 #if ENABLE_SPAN_T
GetCharactersTypeBytesMovie26   public Span<Character> GetCharactersTypeBytes() { return __p.__vector_as_span<Character>(8, 1); }
27 #else
GetCharactersTypeBytesMovie28   public ArraySegment<byte>? GetCharactersTypeBytes() { return __p.__vector_as_arraysegment(8); }
29 #endif
GetCharactersTypeArrayMovie30   public Character[] GetCharactersTypeArray() { int o = __p.__offset(8); if (o == 0) return null; int p = __p.__vector(o); int l = __p.__vector_len(o); Character[] a = new Character[l]; for (int i = 0; i < l; i++) { a[i] = (Character)__p.bb.Get(p + i * 1); } return a; }
31   public TTable? Characters<TTable>(int j) where TTable : struct, IFlatbufferObject { int o = __p.__offset(10); return o != 0 ? (TTable?)__p.__union<TTable>(__p.__vector(o) + j * 4) : null; }
CharactersAsStringMovie32   public string CharactersAsString(int j) { int o = __p.__offset(10); return o != 0 ? __p.__string(__p.__vector(o) + j * 4) : null; }
33   public int CharactersLength { get { int o = __p.__offset(10); return o != 0 ? __p.__vector_len(o) : 0; } }
34 
CreateMovieMovie35   public static Offset<Movie> CreateMovie(FlatBufferBuilder builder,
36       Character main_character_type = Character.NONE,
37       int main_characterOffset = 0,
38       VectorOffset characters_typeOffset = default(VectorOffset),
39       VectorOffset charactersOffset = default(VectorOffset)) {
40     builder.StartTable(4);
41     Movie.AddCharacters(builder, charactersOffset);
42     Movie.AddCharactersType(builder, characters_typeOffset);
43     Movie.AddMainCharacter(builder, main_characterOffset);
44     Movie.AddMainCharacterType(builder, main_character_type);
45     return Movie.EndMovie(builder);
46   }
47 
StartMovieMovie48   public static void StartMovie(FlatBufferBuilder builder) { builder.StartTable(4); }
AddMainCharacterTypeMovie49   public static void AddMainCharacterType(FlatBufferBuilder builder, Character mainCharacterType) { builder.AddByte(0, (byte)mainCharacterType, 0); }
AddMainCharacterMovie50   public static void AddMainCharacter(FlatBufferBuilder builder, int mainCharacterOffset) { builder.AddOffset(1, mainCharacterOffset, 0); }
AddCharactersTypeMovie51   public static void AddCharactersType(FlatBufferBuilder builder, VectorOffset charactersTypeOffset) { builder.AddOffset(2, charactersTypeOffset.Value, 0); }
CreateCharactersTypeVectorMovie52   public static VectorOffset CreateCharactersTypeVector(FlatBufferBuilder builder, Character[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddByte((byte)data[i]); return builder.EndVector(); }
CreateCharactersTypeVectorBlockMovie53   public static VectorOffset CreateCharactersTypeVectorBlock(FlatBufferBuilder builder, Character[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); return builder.EndVector(); }
StartCharactersTypeVectorMovie54   public static void StartCharactersTypeVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); }
AddCharactersMovie55   public static void AddCharacters(FlatBufferBuilder builder, VectorOffset charactersOffset) { builder.AddOffset(3, charactersOffset.Value, 0); }
CreateCharactersVectorMovie56   public static VectorOffset CreateCharactersVector(FlatBufferBuilder builder, int[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i]); return builder.EndVector(); }
CreateCharactersVectorBlockMovie57   public static VectorOffset CreateCharactersVectorBlock(FlatBufferBuilder builder, int[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
StartCharactersVectorMovie58   public static void StartCharactersVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
EndMovieMovie59   public static Offset<Movie> EndMovie(FlatBufferBuilder builder) {
60     int o = builder.EndTable();
61     return new Offset<Movie>(o);
62   }
FinishMovieBufferMovie63   public static void FinishMovieBuffer(FlatBufferBuilder builder, Offset<Movie> offset) { builder.Finish(offset.Value, "MOVI"); }
FinishSizePrefixedMovieBufferMovie64   public static void FinishSizePrefixedMovieBuffer(FlatBufferBuilder builder, Offset<Movie> offset) { builder.FinishSizePrefixed(offset.Value, "MOVI"); }
UnPackMovie65   public MovieT UnPack() {
66     var _o = new MovieT();
67     this.UnPackTo(_o);
68     return _o;
69   }
UnPackToMovie70   public void UnPackTo(MovieT _o) {
71     _o.MainCharacter = new CharacterUnion();
72     _o.MainCharacter.Type = this.MainCharacterType;
73     switch (this.MainCharacterType) {
74       default: break;
75       case Character.MuLan:
76         _o.MainCharacter.Value = this.MainCharacter<Attacker>().HasValue ? this.MainCharacter<Attacker>().Value.UnPack() : null;
77         break;
78       case Character.Rapunzel:
79         _o.MainCharacter.Value = this.MainCharacter<Rapunzel>().HasValue ? this.MainCharacter<Rapunzel>().Value.UnPack() : null;
80         break;
81       case Character.Belle:
82         _o.MainCharacter.Value = this.MainCharacter<BookReader>().HasValue ? this.MainCharacter<BookReader>().Value.UnPack() : null;
83         break;
84       case Character.BookFan:
85         _o.MainCharacter.Value = this.MainCharacter<BookReader>().HasValue ? this.MainCharacter<BookReader>().Value.UnPack() : null;
86         break;
87       case Character.Other:
88         _o.MainCharacter.Value = this.MainCharacterAsString();
89         break;
90       case Character.Unused:
91         _o.MainCharacter.Value = this.MainCharacterAsString();
92         break;
93     }
94     _o.Characters = new List<CharacterUnion>();
95     for (var _j = 0; _j < this.CharactersLength; ++_j) {
96       var _o_Characters = new CharacterUnion();
97       _o_Characters.Type = this.CharactersType(_j);
98       switch (this.CharactersType(_j)) {
99         default: break;
100         case Character.MuLan:
101           _o_Characters.Value = this.Characters<Attacker>(_j).HasValue ? this.Characters<Attacker>(_j).Value.UnPack() : null;
102           break;
103         case Character.Rapunzel:
104           _o_Characters.Value = this.Characters<Rapunzel>(_j).HasValue ? this.Characters<Rapunzel>(_j).Value.UnPack() : null;
105           break;
106         case Character.Belle:
107           _o_Characters.Value = this.Characters<BookReader>(_j).HasValue ? this.Characters<BookReader>(_j).Value.UnPack() : null;
108           break;
109         case Character.BookFan:
110           _o_Characters.Value = this.Characters<BookReader>(_j).HasValue ? this.Characters<BookReader>(_j).Value.UnPack() : null;
111           break;
112         case Character.Other:
113           _o_Characters.Value = this.CharactersAsString(_j);
114           break;
115         case Character.Unused:
116           _o_Characters.Value = this.CharactersAsString(_j);
117           break;
118       }
119       _o.Characters.Add(_o_Characters);
120     }
121   }
PackMovie122   public static Offset<Movie> Pack(FlatBufferBuilder builder, MovieT _o) {
123     if (_o == null) return default(Offset<Movie>);
124     var _main_character_type = _o.MainCharacter == null ? Character.NONE : _o.MainCharacter.Type;
125     var _main_character = _o.MainCharacter == null ? 0 : CharacterUnion.Pack(builder, _o.MainCharacter);
126     var _characters_type = default(VectorOffset);
127     if (_o.Characters != null) {
128       var __characters_type = new Character[_o.Characters.Count];
129       for (var _j = 0; _j < __characters_type.Length; ++_j) { __characters_type[_j] = _o.Characters[_j].Type; }
130       _characters_type = CreateCharactersTypeVector(builder, __characters_type);
131     }
132     var _characters = default(VectorOffset);
133     if (_o.Characters != null) {
134       var __characters = new int[_o.Characters.Count];
135       for (var _j = 0; _j < __characters.Length; ++_j) { __characters[_j] = CharacterUnion.Pack(builder,  _o.Characters[_j]); }
136       _characters = CreateCharactersVector(builder, __characters);
137     }
138     return CreateMovie(
139       builder,
140       _main_character_type,
141       _main_character,
142       _characters_type,
143       _characters);
144   }
145 };
146 
147 public class MovieT
148 {
149   [Newtonsoft.Json.JsonProperty("main_character_type")]
150   private Character MainCharacterType {
151     get {
152       return this.MainCharacter != null ? this.MainCharacter.Type : Character.NONE;
153     }
154     set {
155       this.MainCharacter = new CharacterUnion();
156       this.MainCharacter.Type = value;
157     }
158   }
159   [Newtonsoft.Json.JsonProperty("main_character")]
160   [Newtonsoft.Json.JsonConverter(typeof(CharacterUnion_JsonConverter))]
161   public CharacterUnion MainCharacter { get; set; }
162   [Newtonsoft.Json.JsonProperty("characters_type")]
163   private Character[] CharactersType {
164     get {
165       if (this.Characters == null) return null;
166       var _o = new Character[this.Characters.Count];
167       for (var _j = 0; _j < _o.Length; ++_j) { _o[_j] = this.Characters[_j].Type; }
168       return _o;
169     }
170     set {
171       this.Characters = new List<CharacterUnion>();
172       for (var _j = 0; _j < value.Length; ++_j) {
173         var _o = new CharacterUnion();
174         _o.Type = value[_j];
175         this.Characters.Add(_o);
176       }
177     }
178   }
179   [Newtonsoft.Json.JsonProperty("characters")]
180   [Newtonsoft.Json.JsonConverter(typeof(CharacterUnion_JsonConverter))]
181   public List<CharacterUnion> Characters { get; set; }
182 
MovieT()183   public MovieT() {
184     this.MainCharacter = null;
185     this.Characters = null;
186   }
187 
DeserializeFromJson(string jsonText)188   public static MovieT DeserializeFromJson(string jsonText) {
189     return Newtonsoft.Json.JsonConvert.DeserializeObject<MovieT>(jsonText);
190   }
SerializeToJson()191   public string SerializeToJson() {
192     return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
193   }
DeserializeFromBinary(byte[] fbBuffer)194   public static MovieT DeserializeFromBinary(byte[] fbBuffer) {
195     return Movie.GetRootAsMovie(new ByteBuffer(fbBuffer)).UnPack();
196   }
SerializeToBinary()197   public byte[] SerializeToBinary() {
198     var fbb = new FlatBufferBuilder(0x10000);
199     fbb.Finish(Movie.Pack(fbb, this).Value);
200     return fbb.DataBuffer.ToSizedArray();
201   }
202 }
203 
204