1 // <auto-generated> 2 // automatically generated by the FlatBuffers compiler, do not modify 3 // </auto-generated> 4 5 [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] 6 public enum Character : byte 7 { 8 NONE = 0, 9 MuLan = 1, 10 Rapunzel = 2, 11 Belle = 3, 12 BookFan = 4, 13 Other = 5, 14 Unused = 6, 15 }; 16 17 public class CharacterUnion { 18 public Character Type { get; set; } 19 public object Value { get; set; } 20 CharacterUnion()21 public CharacterUnion() { 22 this.Type = Character.NONE; 23 this.Value = null; 24 } 25 26 public T As<T>() where T : class { return this.Value as T; } AsMuLan()27 public AttackerT AsMuLan() { return this.As<AttackerT>(); } AsRapunzel()28 public RapunzelT AsRapunzel() { return this.As<RapunzelT>(); } AsBelle()29 public BookReaderT AsBelle() { return this.As<BookReaderT>(); } AsBookFan()30 public BookReaderT AsBookFan() { return this.As<BookReaderT>(); } AsOther()31 public string AsOther() { return this.As<string>(); } AsUnused()32 public string AsUnused() { return this.As<string>(); } 33 Pack(FlatBuffers.FlatBufferBuilder builder, CharacterUnion _o)34 public static int Pack(FlatBuffers.FlatBufferBuilder builder, CharacterUnion _o) { 35 switch (_o.Type) { 36 default: return 0; 37 case Character.MuLan: return Attacker.Pack(builder, _o.AsMuLan()).Value; 38 case Character.Rapunzel: return Rapunzel.Pack(builder, _o.AsRapunzel()).Value; 39 case Character.Belle: return BookReader.Pack(builder, _o.AsBelle()).Value; 40 case Character.BookFan: return BookReader.Pack(builder, _o.AsBookFan()).Value; 41 case Character.Other: return builder.CreateString(_o.AsOther()).Value; 42 case Character.Unused: return builder.CreateString(_o.AsUnused()).Value; 43 } 44 } 45 } 46 47 public class CharacterUnion_JsonConverter : Newtonsoft.Json.JsonConverter { CanConvert(System.Type objectType)48 public override bool CanConvert(System.Type objectType) { 49 return objectType == typeof(CharacterUnion) || objectType == typeof(System.Collections.Generic.List<CharacterUnion>); 50 } WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)51 public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer) { 52 var _olist = value as System.Collections.Generic.List<CharacterUnion>; 53 if (_olist != null) { 54 writer.WriteStartArray(); 55 foreach (var _o in _olist) { this.WriteJson(writer, _o, serializer); } 56 writer.WriteEndArray(); 57 } else { 58 this.WriteJson(writer, value as CharacterUnion, serializer); 59 } 60 } WriteJson(Newtonsoft.Json.JsonWriter writer, CharacterUnion _o, Newtonsoft.Json.JsonSerializer serializer)61 public void WriteJson(Newtonsoft.Json.JsonWriter writer, CharacterUnion _o, Newtonsoft.Json.JsonSerializer serializer) { 62 if (_o == null) return; 63 serializer.Serialize(writer, _o.Value); 64 } ReadJson(Newtonsoft.Json.JsonReader reader, System.Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)65 public override object ReadJson(Newtonsoft.Json.JsonReader reader, System.Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer) { 66 var _olist = existingValue as System.Collections.Generic.List<CharacterUnion>; 67 if (_olist != null) { 68 for (var _j = 0; _j < _olist.Count; ++_j) { 69 reader.Read(); 70 _olist[_j] = this.ReadJson(reader, _olist[_j], serializer); 71 } 72 reader.Read(); 73 return _olist; 74 } else { 75 return this.ReadJson(reader, existingValue as CharacterUnion, serializer); 76 } 77 } ReadJson(Newtonsoft.Json.JsonReader reader, CharacterUnion _o, Newtonsoft.Json.JsonSerializer serializer)78 public CharacterUnion ReadJson(Newtonsoft.Json.JsonReader reader, CharacterUnion _o, Newtonsoft.Json.JsonSerializer serializer) { 79 if (_o == null) return null; 80 switch (_o.Type) { 81 default: break; 82 case Character.MuLan: _o.Value = serializer.Deserialize<AttackerT>(reader); break; 83 case Character.Rapunzel: _o.Value = serializer.Deserialize<RapunzelT>(reader); break; 84 case Character.Belle: _o.Value = serializer.Deserialize<BookReaderT>(reader); break; 85 case Character.BookFan: _o.Value = serializer.Deserialize<BookReaderT>(reader); break; 86 case Character.Other: _o.Value = serializer.Deserialize<string>(reader); break; 87 case Character.Unused: _o.Value = serializer.Deserialize<string>(reader); break; 88 } 89 return _o; 90 } 91 } 92 93