...

Text file src/github.com/google/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/UnionInNestedNS.cs

Documentation: github.com/google/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB

     1// <auto-generated>
     2//  automatically generated by the FlatBuffers compiler, do not modify
     3// </auto-generated>
     4
     5namespace NamespaceA.NamespaceB
     6{
     7
     8[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
     9public enum UnionInNestedNS : byte
    10{
    11  NONE = 0,
    12  TableInNestedNS = 1,
    13};
    14
    15public 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(Google.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
    37
    38static public class UnionInNestedNSVerify
    39{
    40  static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
    41  {
    42    bool result = true;
    43    switch((UnionInNestedNS)typeId)
    44    {
    45      case UnionInNestedNS.TableInNestedNS:
    46        result = NamespaceA.NamespaceB.TableInNestedNSVerify.Verify(verifier, tablePos);
    47        break;
    48      default: result = true;
    49        break;
    50    }
    51    return result;
    52  }
    53}
    54
    55public class UnionInNestedNSUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
    56  public override bool CanConvert(System.Type objectType) {
    57    return objectType == typeof(UnionInNestedNSUnion) || objectType == typeof(System.Collections.Generic.List<UnionInNestedNSUnion>);
    58  }
    59  public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer) {
    60    var _olist = value as System.Collections.Generic.List<UnionInNestedNSUnion>;
    61    if (_olist != null) {
    62      writer.WriteStartArray();
    63      foreach (var _o in _olist) { this.WriteJson(writer, _o, serializer); }
    64      writer.WriteEndArray();
    65    } else {
    66      this.WriteJson(writer, value as UnionInNestedNSUnion, serializer);
    67    }
    68  }
    69  public void WriteJson(Newtonsoft.Json.JsonWriter writer, UnionInNestedNSUnion _o, Newtonsoft.Json.JsonSerializer serializer) {
    70    if (_o == null) return;
    71    serializer.Serialize(writer, _o.Value);
    72  }
    73  public override object ReadJson(Newtonsoft.Json.JsonReader reader, System.Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer) {
    74    var _olist = existingValue as System.Collections.Generic.List<UnionInNestedNSUnion>;
    75    if (_olist != null) {
    76      for (var _j = 0; _j < _olist.Count; ++_j) {
    77        reader.Read();
    78        _olist[_j] = this.ReadJson(reader, _olist[_j], serializer);
    79      }
    80      reader.Read();
    81      return _olist;
    82    } else {
    83      return this.ReadJson(reader, existingValue as UnionInNestedNSUnion, serializer);
    84    }
    85  }
    86  public UnionInNestedNSUnion ReadJson(Newtonsoft.Json.JsonReader reader, UnionInNestedNSUnion _o, Newtonsoft.Json.JsonSerializer serializer) {
    87    if (_o == null) return null;
    88    switch (_o.Type) {
    89      default: break;
    90      case UnionInNestedNS.TableInNestedNS: _o.Value = serializer.Deserialize<NamespaceA.NamespaceB.TableInNestedNST>(reader); break;
    91    }
    92    return _o;
    93  }
    94}
    95
    96
    97}

View as plain text