...

Text file src/github.com/google/flatbuffers/tests/KeywordTest/KeywordsInUnion.cs

Documentation: github.com/google/flatbuffers/tests/KeywordTest

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

View as plain text