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