// // automatically generated by the FlatBuffers compiler, do not modify // [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public enum Character : byte { NONE = 0, MuLan = 1, Rapunzel = 2, Belle = 3, BookFan = 4, Other = 5, Unused = 6, }; public class CharacterUnion { public Character Type { get; set; } public object Value { get; set; } public CharacterUnion() { this.Type = Character.NONE; this.Value = null; } public T As() where T : class { return this.Value as T; } public AttackerT AsMuLan() { return this.As(); } public RapunzelT AsRapunzel() { return this.As(); } public BookReaderT AsBelle() { return this.As(); } public BookReaderT AsBookFan() { return this.As(); } public string AsOther() { return this.As(); } public string AsUnused() { return this.As(); } public static int Pack(FlatBuffers.FlatBufferBuilder builder, CharacterUnion _o) { switch (_o.Type) { default: return 0; case Character.MuLan: return Attacker.Pack(builder, _o.AsMuLan()).Value; case Character.Rapunzel: return Rapunzel.Pack(builder, _o.AsRapunzel()).Value; case Character.Belle: return BookReader.Pack(builder, _o.AsBelle()).Value; case Character.BookFan: return BookReader.Pack(builder, _o.AsBookFan()).Value; case Character.Other: return builder.CreateString(_o.AsOther()).Value; case Character.Unused: return builder.CreateString(_o.AsUnused()).Value; } } } public class CharacterUnion_JsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) { return objectType == typeof(CharacterUnion) || objectType == typeof(System.Collections.Generic.List); } public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer) { var _olist = value as System.Collections.Generic.List; if (_olist != null) { writer.WriteStartArray(); foreach (var _o in _olist) { this.WriteJson(writer, _o, serializer); } writer.WriteEndArray(); } else { this.WriteJson(writer, value as CharacterUnion, serializer); } } public void WriteJson(Newtonsoft.Json.JsonWriter writer, CharacterUnion _o, Newtonsoft.Json.JsonSerializer serializer) { if (_o == null) return; serializer.Serialize(writer, _o.Value); } public override object ReadJson(Newtonsoft.Json.JsonReader reader, System.Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer) { var _olist = existingValue as System.Collections.Generic.List; if (_olist != null) { for (var _j = 0; _j < _olist.Count; ++_j) { reader.Read(); _olist[_j] = this.ReadJson(reader, _olist[_j], serializer); } reader.Read(); return _olist; } else { return this.ReadJson(reader, existingValue as CharacterUnion, serializer); } } public CharacterUnion ReadJson(Newtonsoft.Json.JsonReader reader, CharacterUnion _o, Newtonsoft.Json.JsonSerializer serializer) { if (_o == null) return null; switch (_o.Type) { default: break; case Character.MuLan: _o.Value = serializer.Deserialize(reader); break; case Character.Rapunzel: _o.Value = serializer.Deserialize(reader); break; case Character.Belle: _o.Value = serializer.Deserialize(reader); break; case Character.BookFan: _o.Value = serializer.Deserialize(reader); break; case Character.Other: _o.Value = serializer.Deserialize(reader); break; case Character.Unused: _o.Value = serializer.Deserialize(reader); break; } return _o; } }