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