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 UnionInNestedNSUnion()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; } AsTableInNestedNS()25 public NamespaceA.NamespaceB.TableInNestedNST AsTableInNestedNS() { return this.As<NamespaceA.NamespaceB.TableInNestedNST>(); } 26 Pack(FlatBuffers.FlatBufferBuilder builder, UnionInNestedNSUnion _o)27 public static int Pack(FlatBuffers.FlatBufferBuilder builder, UnionInNestedNSUnion _o) { 28 switch (_o.Type) { 29 default: return 0; 30 case UnionInNestedNS.TableInNestedNS: return NamespaceA.NamespaceB.TableInNestedNS.Pack(builder, _o.AsTableInNestedNS()).Value; 31 } 32 } 33 } 34 35 public class UnionInNestedNSUnion_JsonConverter : Newtonsoft.Json.JsonConverter { CanConvert(System.Type objectType)36 public override bool CanConvert(System.Type objectType) { 37 return objectType == typeof(UnionInNestedNSUnion) || objectType == typeof(System.Collections.Generic.List<UnionInNestedNSUnion>); 38 } WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)39 public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer) { 40 var _olist = value as System.Collections.Generic.List<UnionInNestedNSUnion>; 41 if (_olist != null) { 42 writer.WriteStartArray(); 43 foreach (var _o in _olist) { this.WriteJson(writer, _o, serializer); } 44 writer.WriteEndArray(); 45 } else { 46 this.WriteJson(writer, value as UnionInNestedNSUnion, serializer); 47 } 48 } WriteJson(Newtonsoft.Json.JsonWriter writer, UnionInNestedNSUnion _o, Newtonsoft.Json.JsonSerializer serializer)49 public void WriteJson(Newtonsoft.Json.JsonWriter writer, UnionInNestedNSUnion _o, Newtonsoft.Json.JsonSerializer serializer) { 50 if (_o == null) return; 51 serializer.Serialize(writer, _o.Value); 52 } ReadJson(Newtonsoft.Json.JsonReader reader, System.Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)53 public override object ReadJson(Newtonsoft.Json.JsonReader reader, System.Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer) { 54 var _olist = existingValue as System.Collections.Generic.List<UnionInNestedNSUnion>; 55 if (_olist != null) { 56 for (var _j = 0; _j < _olist.Count; ++_j) { 57 reader.Read(); 58 _olist[_j] = this.ReadJson(reader, _olist[_j], serializer); 59 } 60 reader.Read(); 61 return _olist; 62 } else { 63 return this.ReadJson(reader, existingValue as UnionInNestedNSUnion, serializer); 64 } 65 } ReadJson(Newtonsoft.Json.JsonReader reader, UnionInNestedNSUnion _o, Newtonsoft.Json.JsonSerializer serializer)66 public UnionInNestedNSUnion ReadJson(Newtonsoft.Json.JsonReader reader, UnionInNestedNSUnion _o, Newtonsoft.Json.JsonSerializer serializer) { 67 if (_o == null) return null; 68 switch (_o.Type) { 69 default: break; 70 case UnionInNestedNS.TableInNestedNS: _o.Value = serializer.Deserialize<NamespaceA.NamespaceB.TableInNestedNST>(reader); break; 71 } 72 return _o; 73 } 74 } 75 76 77 } 78