/**
 * 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 VersioningTestV1 : TBase
{
  private int _begin_in_both;
  private string _old_string;
  private int _end_in_both;

  [DataMember(Order = 0)]
  public int Begin_in_both
  {
    get
    {
      return _begin_in_both;
    }
    set
    {
      __isset.begin_in_both = true;
      this._begin_in_both = value;
    }
  }

  [DataMember(Order = 0)]
  public string Old_string
  {
    get
    {
      return _old_string;
    }
    set
    {
      __isset.old_string = true;
      this._old_string = value;
    }
  }

  [DataMember(Order = 0)]
  public int End_in_both
  {
    get
    {
      return _end_in_both;
    }
    set
    {
      __isset.end_in_both = true;
      this._end_in_both = value;
    }
  }


  [DataMember(Order = 1)]
  public Isset __isset;
  [DataContract]
  public struct Isset
  {
    [DataMember]
    public bool begin_in_both;
    [DataMember]
    public bool old_string;
    [DataMember]
    public bool end_in_both;
  }

  #region XmlSerializer support

  public bool ShouldSerializeBegin_in_both()
  {
    return __isset.begin_in_both;
  }

  public bool ShouldSerializeOld_string()
  {
    return __isset.old_string;
  }

  public bool ShouldSerializeEnd_in_both()
  {
    return __isset.end_in_both;
  }

  #endregion XmlSerializer support

  public VersioningTestV1()
  {
  }

  public VersioningTestV1 DeepCopy()
  {
    var tmp71 = new VersioningTestV1();
    if(__isset.begin_in_both)
    {
      tmp71.Begin_in_both = this.Begin_in_both;
    }
    tmp71.__isset.begin_in_both = this.__isset.begin_in_both;
    if((Old_string != null) && __isset.old_string)
    {
      tmp71.Old_string = this.Old_string;
    }
    tmp71.__isset.old_string = this.__isset.old_string;
    if(__isset.end_in_both)
    {
      tmp71.End_in_both = this.End_in_both;
    }
    tmp71.__isset.end_in_both = this.__isset.end_in_both;
    return tmp71;
  }

  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.I32)
            {
              Begin_in_both = await iprot.ReadI32Async(cancellationToken);
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 3:
            if (field.Type == TType.String)
            {
              Old_string = await iprot.ReadStringAsync(cancellationToken);
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 12:
            if (field.Type == TType.I32)
            {
              End_in_both = await iprot.ReadI32Async(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("VersioningTestV1");
      await oprot.WriteStructBeginAsync(struc, cancellationToken);
      var field = new TField();
      if(__isset.begin_in_both)
      {
        field.Name = "begin_in_both";
        field.Type = TType.I32;
        field.ID = 1;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await oprot.WriteI32Async(Begin_in_both, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if((Old_string != null) && __isset.old_string)
      {
        field.Name = "old_string";
        field.Type = TType.String;
        field.ID = 3;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await oprot.WriteStringAsync(Old_string, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if(__isset.end_in_both)
      {
        field.Name = "end_in_both";
        field.Type = TType.I32;
        field.ID = 12;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await oprot.WriteI32Async(End_in_both, 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 VersioningTestV1 other)) return false;
    if (ReferenceEquals(this, other)) return true;
    return ((__isset.begin_in_both == other.__isset.begin_in_both) && ((!__isset.begin_in_both) || (System.Object.Equals(Begin_in_both, other.Begin_in_both))))
      && ((__isset.old_string == other.__isset.old_string) && ((!__isset.old_string) || (System.Object.Equals(Old_string, other.Old_string))))
      && ((__isset.end_in_both == other.__isset.end_in_both) && ((!__isset.end_in_both) || (System.Object.Equals(End_in_both, other.End_in_both))));
  }

  public override int GetHashCode() {
    int hashcode = 157;
    unchecked {
      if(__isset.begin_in_both)
      {
        hashcode = (hashcode * 397) + Begin_in_both.GetHashCode();
      }
      if((Old_string != null) && __isset.old_string)
      {
        hashcode = (hashcode * 397) + Old_string.GetHashCode();
      }
      if(__isset.end_in_both)
      {
        hashcode = (hashcode * 397) + End_in_both.GetHashCode();
      }
    }
    return hashcode;
  }

  public override string ToString()
  {
    var sb = new StringBuilder("VersioningTestV1(");
    int tmp72 = 0;
    if(__isset.begin_in_both)
    {
      if(0 < tmp72++) { sb.Append(", "); }
      sb.Append("Begin_in_both: ");
      Begin_in_both.ToString(sb);
    }
    if((Old_string != null) && __isset.old_string)
    {
      if(0 < tmp72++) { sb.Append(", "); }
      sb.Append("Old_string: ");
      Old_string.ToString(sb);
    }
    if(__isset.end_in_both)
    {
      if(0 < tmp72++) { sb.Append(", "); }
      sb.Append("End_in_both: ");
      End_in_both.ToString(sb);
    }
    sb.Append(')');
    return sb.ToString();
  }
}

}
