/**
 * 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 Bools : TBase
  {
    private bool _im_true;
    private bool _im_false;

    [DataMember(Order = 0)]
    public bool Im_true
    {
      get
      {
        return _im_true;
      }
      set
      {
        __isset.im_true = true;
        this._im_true = value;
      }
    }

    [DataMember(Order = 0)]
    public bool Im_false
    {
      get
      {
        return _im_false;
      }
      set
      {
        __isset.im_false = true;
        this._im_false = value;
      }
    }


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

    #region XmlSerializer support

    public bool ShouldSerializeIm_true()
    {
      return __isset.im_true;
    }

    public bool ShouldSerializeIm_false()
    {
      return __isset.im_false;
    }

    #endregion XmlSerializer support

    public Bools()
    {
    }

    public Bools DeepCopy()
    {
      var tmp2 = new Bools();
      if(__isset.im_true)
      {
        tmp2.Im_true = this.Im_true;
      }
      tmp2.__isset.im_true = this.__isset.im_true;
      if(__isset.im_false)
      {
        tmp2.Im_false = this.Im_false;
      }
      tmp2.__isset.im_false = this.__isset.im_false;
      return tmp2;
    }

    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.Bool)
              {
                Im_true = await iprot.ReadBoolAsync(cancellationToken);
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 2:
              if (field.Type == TType.Bool)
              {
                Im_false = await iprot.ReadBoolAsync(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("Bools");
        await oprot.WriteStructBeginAsync(struc, cancellationToken);
        var field = new TField();
        if(__isset.im_true)
        {
          field.Name = "im_true";
          field.Type = TType.Bool;
          field.ID = 1;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          await oprot.WriteBoolAsync(Im_true, cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if(__isset.im_false)
        {
          field.Name = "im_false";
          field.Type = TType.Bool;
          field.ID = 2;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          await oprot.WriteBoolAsync(Im_false, 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 Bools other)) return false;
      if (ReferenceEquals(this, other)) return true;
      return ((__isset.im_true == other.__isset.im_true) && ((!__isset.im_true) || (System.Object.Equals(Im_true, other.Im_true))))
        && ((__isset.im_false == other.__isset.im_false) && ((!__isset.im_false) || (System.Object.Equals(Im_false, other.Im_false))));
    }

    public override int GetHashCode() {
      int hashcode = 157;
      unchecked {
        if(__isset.im_true)
        {
          hashcode = (hashcode * 397) + Im_true.GetHashCode();
        }
        if(__isset.im_false)
        {
          hashcode = (hashcode * 397) + Im_false.GetHashCode();
        }
      }
      return hashcode;
    }

    public override string ToString()
    {
      var sb = new StringBuilder("Bools(");
      int tmp3 = 0;
      if(__isset.im_true)
      {
        if(0 < tmp3++) { sb.Append(", "); }
        sb.Append("Im_true: ");
        Im_true.ToString(sb);
      }
      if(__isset.im_false)
      {
        if(0 < tmp3++) { sb.Append(", "); }
        sb.Append("Im_false: ");
        Im_false.ToString(sb);
      }
      sb.Append(')');
      return sb.ToString();
    }
  }

}
