/**
 * Autogenerated by Thrift Compiler (0.14.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Thrift;
using Thrift.Collections;
using System.ServiceModel;
using System.Runtime.Serialization;

using Thrift.Protocol;
using Thrift.Protocol.Entities;
using Thrift.Protocol.Utilities;
using Thrift.Transport;
using Thrift.Transport.Client;
using Thrift.Transport.Server;
using Thrift.Processor;


#pragma warning disable IDE0079  // remove unnecessary pragmas
#pragma warning disable IDE1006  // parts of the code use IDL spelling

namespace ThriftTest
{

[DataContract(Namespace="")]
public partial class ListTypeVersioningV1 : TBase
{
  private List<int> _myints;
  private string _hello;

  [DataMember(Order = 0)]
  public List<int> Myints
  {
    get
    {
      return _myints;
    }
    set
    {
      __isset.myints = true;
      this._myints = value;
    }
  }

  [DataMember(Order = 0)]
  public string Hello
  {
    get
    {
      return _hello;
    }
    set
    {
      __isset.hello = true;
      this._hello = value;
    }
  }


  [DataMember(Order = 1)]
  public Isset __isset;
  [DataContract]
  public struct Isset
  {
    [DataMember]
    public bool myints;
    [DataMember]
    public bool hello;
  }

  #region XmlSerializer support

  public bool ShouldSerializeMyints()
  {
    return __isset.myints;
  }

  public bool ShouldSerializeHello()
  {
    return __isset.hello;
  }

  #endregion XmlSerializer support

  public ListTypeVersioningV1()
  {
  }

  public ListTypeVersioningV1 DeepCopy()
  {
    var tmp88 = new ListTypeVersioningV1();
    if((Myints != null) && __isset.myints)
    {
      tmp88.Myints = this.Myints.DeepCopy();
    }
    tmp88.__isset.myints = this.__isset.myints;
    if((Hello != null) && __isset.hello)
    {
      tmp88.Hello = this.Hello;
    }
    tmp88.__isset.hello = this.__isset.hello;
    return tmp88;
  }

  public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
  {
    iprot.IncrementRecursionDepth();
    try
    {
      TField field;
      await iprot.ReadStructBeginAsync(cancellationToken);
      while (true)
      {
        field = await iprot.ReadFieldBeginAsync(cancellationToken);
        if (field.Type == TType.Stop)
        {
          break;
        }

        switch (field.ID)
        {
          case 1:
            if (field.Type == TType.List)
            {
              {
                TList _list89 = await iprot.ReadListBeginAsync(cancellationToken);
                Myints = new List<int>(_list89.Count);
                for(int _i90 = 0; _i90 < _list89.Count; ++_i90)
                {
                  int _elem91;
                  _elem91 = await iprot.ReadI32Async(cancellationToken);
                  Myints.Add(_elem91);
                }
                await iprot.ReadListEndAsync(cancellationToken);
              }
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 2:
            if (field.Type == TType.String)
            {
              Hello = await iprot.ReadStringAsync(cancellationToken);
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          default: 
            await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            break;
        }

        await iprot.ReadFieldEndAsync(cancellationToken);
      }

      await iprot.ReadStructEndAsync(cancellationToken);
    }
    finally
    {
      iprot.DecrementRecursionDepth();
    }
  }

  public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
  {
    oprot.IncrementRecursionDepth();
    try
    {
      var struc = new TStruct("ListTypeVersioningV1");
      await oprot.WriteStructBeginAsync(struc, cancellationToken);
      var field = new TField();
      if((Myints != null) && __isset.myints)
      {
        field.Name = "myints";
        field.Type = TType.List;
        field.ID = 1;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        {
          await oprot.WriteListBeginAsync(new TList(TType.I32, Myints.Count), cancellationToken);
          foreach (int _iter92 in Myints)
          {
            await oprot.WriteI32Async(_iter92, cancellationToken);
          }
          await oprot.WriteListEndAsync(cancellationToken);
        }
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if((Hello != null) && __isset.hello)
      {
        field.Name = "hello";
        field.Type = TType.String;
        field.ID = 2;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await oprot.WriteStringAsync(Hello, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      await oprot.WriteFieldStopAsync(cancellationToken);
      await oprot.WriteStructEndAsync(cancellationToken);
    }
    finally
    {
      oprot.DecrementRecursionDepth();
    }
  }

  public override bool Equals(object that)
  {
    if (!(that is ListTypeVersioningV1 other)) return false;
    if (ReferenceEquals(this, other)) return true;
    return ((__isset.myints == other.__isset.myints) && ((!__isset.myints) || (TCollections.Equals(Myints, other.Myints))))
      && ((__isset.hello == other.__isset.hello) && ((!__isset.hello) || (System.Object.Equals(Hello, other.Hello))));
  }

  public override int GetHashCode() {
    int hashcode = 157;
    unchecked {
      if((Myints != null) && __isset.myints)
      {
        hashcode = (hashcode * 397) + TCollections.GetHashCode(Myints);
      }
      if((Hello != null) && __isset.hello)
      {
        hashcode = (hashcode * 397) + Hello.GetHashCode();
      }
    }
    return hashcode;
  }

  public override string ToString()
  {
    var sb = new StringBuilder("ListTypeVersioningV1(");
    int tmp93 = 0;
    if((Myints != null) && __isset.myints)
    {
      if(0 < tmp93++) { sb.Append(", "); }
      sb.Append("Myints: ");
      Myints.ToString(sb);
    }
    if((Hello != null) && __isset.hello)
    {
      if(0 < tmp93++) { sb.Append(", "); }
      sb.Append("Hello: ");
      Hello.ToString(sb);
    }
    sb.Append(')');
    return sb.ToString();
  }
}

}
