• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 AnyUniqueAliases : byte
10 {
11   NONE = 0,
12   M = 1,
13   TS = 2,
14   M2 = 3,
15 };
16 
17 public class AnyUniqueAliasesUnion {
18   public AnyUniqueAliases Type { get; set; }
19   public object Value { get; set; }
20 
AnyUniqueAliasesUnion()21   public AnyUniqueAliasesUnion() {
22     this.Type = AnyUniqueAliases.NONE;
23     this.Value = null;
24   }
25 
26   public T As<T>() where T : class { return this.Value as T; }
AsM()27   public MyGame.Example.MonsterT AsM() { return this.As<MyGame.Example.MonsterT>(); }
AsTS()28   internal MyGame.Example.TestSimpleTableWithEnumT AsTS() { return this.As<MyGame.Example.TestSimpleTableWithEnumT>(); }
AsM2()29   public MyGame.Example2.MonsterT AsM2() { return this.As<MyGame.Example2.MonsterT>(); }
30 
Pack(FlatBuffers.FlatBufferBuilder builder, AnyUniqueAliasesUnion _o)31   public static int Pack(FlatBuffers.FlatBufferBuilder builder, AnyUniqueAliasesUnion _o) {
32     switch (_o.Type) {
33       default: return 0;
34       case AnyUniqueAliases.M: return MyGame.Example.Monster.Pack(builder, _o.AsM()).Value;
35       case AnyUniqueAliases.TS: return MyGame.Example.TestSimpleTableWithEnum.Pack(builder, _o.AsTS()).Value;
36       case AnyUniqueAliases.M2: return MyGame.Example2.Monster.Pack(builder, _o.AsM2()).Value;
37     }
38   }
39 }
40 
41 public class AnyUniqueAliasesUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
CanConvert(System.Type objectType)42   public override bool CanConvert(System.Type objectType) {
43     return objectType == typeof(AnyUniqueAliasesUnion) || objectType == typeof(System.Collections.Generic.List<AnyUniqueAliasesUnion>);
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<AnyUniqueAliasesUnion>;
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 AnyUniqueAliasesUnion, serializer);
53     }
54   }
WriteJson(Newtonsoft.Json.JsonWriter writer, AnyUniqueAliasesUnion _o, Newtonsoft.Json.JsonSerializer serializer)55   public void WriteJson(Newtonsoft.Json.JsonWriter writer, AnyUniqueAliasesUnion _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<AnyUniqueAliasesUnion>;
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 AnyUniqueAliasesUnion, serializer);
70     }
71   }
ReadJson(Newtonsoft.Json.JsonReader reader, AnyUniqueAliasesUnion _o, Newtonsoft.Json.JsonSerializer serializer)72   public AnyUniqueAliasesUnion ReadJson(Newtonsoft.Json.JsonReader reader, AnyUniqueAliasesUnion _o, Newtonsoft.Json.JsonSerializer serializer) {
73     if (_o == null) return null;
74     switch (_o.Type) {
75       default: break;
76       case AnyUniqueAliases.M: _o.Value = serializer.Deserialize<MyGame.Example.MonsterT>(reader); break;
77       case AnyUniqueAliases.TS: _o.Value = serializer.Deserialize<MyGame.Example.TestSimpleTableWithEnumT>(reader); break;
78       case AnyUniqueAliases.M2: _o.Value = serializer.Deserialize<MyGame.Example2.MonsterT>(reader); break;
79     }
80     return _o;
81   }
82 }
83 
84 
85 }
86