/**
 * 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 ListTypeVersioningV2 : TBase
{
  private List<string> _strings;
  private string _hello;

  [DataMember(Order = 0)]
  public List<string> Strings
  {
    get
    {
      return _strings;
    }
    set
    {
      __isset.strings = true;
      this._strings = 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 strings;
    [DataMember]
    public bool hello;
  }

  #region XmlSerializer support

  public bool ShouldSerializeStrings()
  {
    return __isset.strings;
  }

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

  #endregion XmlSerializer support

  public ListTypeVersioningV2()
  {
  }

  public ListTypeVersioningV2 DeepCopy()
  {
    var tmp94 = new ListTypeVersioningV2();
    if((Strings != null) && __isset.strings)
    {
      tmp94.Strings = this.Strings.DeepCopy();
    }
    tmp94.__isset.strings = this.__isset.strings;
    if((Hello != null) && __isset.hello)
    {
      tmp94.Hello = this.Hello;
    }
    tmp94.__isset.hello = this.__isset.hello;
    return tmp94;
  }

  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 _list95 = await iprot.ReadListBeginAsync(cancellationToken);
                Strings = new List<string>(_list95.Count);
                for(int _i96 = 0; _i96 < _list95.Count; ++_i96)
                {
                  string _elem97;
                  _elem97 = await iprot.ReadStringAsync(cancellationToken);
                  Strings.Add(_elem97);
                }
                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("ListTypeVersioningV2");
      await oprot.WriteStructBeginAsync(struc, cancellationToken);
      var field = new TField();
      if((Strings != null) && __isset.strings)
      {
        field.Name = "strings";
        field.Type = TType.List;
        field.ID = 1;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        {
          await oprot.WriteListBeginAsync(new TList(TType.String, Strings.Count), cancellationToken);
          foreach (string _iter98 in Strings)
          {
            await oprot.WriteStringAsync(_iter98, 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 ListTypeVersioningV2 other)) return false;
    if (ReferenceEquals(this, other)) return true;
    return ((__isset.strings == other.__isset.strings) && ((!__isset.strings) || (TCollections.Equals(Strings, other.Strings))))
      && ((__isset.hello == other.__isset.hello) && ((!__isset.hello) || (System.Object.Equals(Hello, other.Hello))));
  }

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

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

}
