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