/**
 * 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 Thrift5320.exceptions
{

  public partial class Task : TException, TBase
  {
    private global::Thrift5320.exceptions.Task _left;
    private global::Thrift5320.exceptions.Task _right;

    [DataMember(Order = 0)]
    public global::Thrift5320.exceptions.Task Left
    {
      get
      {
        return _left;
      }
      set
      {
        __isset.left = true;
        this._left = value;
      }
    }

    [DataMember(Order = 0)]
    public global::Thrift5320.exceptions.Task Right
    {
      get
      {
        return _right;
      }
      set
      {
        __isset.right = true;
        this._right = value;
      }
    }


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

    #region XmlSerializer support

    public bool ShouldSerializeLeft()
    {
      return __isset.left;
    }

    public bool ShouldSerializeRight()
    {
      return __isset.right;
    }

    #endregion XmlSerializer support

    public Task()
    {
    }

    public Task DeepCopy()
    {
      var tmp0 = new Task();
      if((Left != null) && __isset.left)
      {
        tmp0.Left = (global::Thrift5320.exceptions.Task)this.Left.DeepCopy();
      }
      tmp0.__isset.left = this.__isset.left;
      if((Right != null) && __isset.right)
      {
        tmp0.Right = (global::Thrift5320.exceptions.Task)this.Right.DeepCopy();
      }
      tmp0.__isset.right = this.__isset.right;
      return tmp0;
    }

    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.Struct)
              {
                Left = new global::Thrift5320.exceptions.Task();
                await Left.ReadAsync(iprot, cancellationToken);
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 2:
              if (field.Type == TType.Struct)
              {
                Right = new global::Thrift5320.exceptions.Task();
                await Right.ReadAsync(iprot, 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("Task");
        await oprot.WriteStructBeginAsync(struc, cancellationToken);
        var field = new TField();
        if((Left != null) && __isset.left)
        {
          field.Name = "left";
          field.Type = TType.Struct;
          field.ID = 1;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          await Left.WriteAsync(oprot, cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((Right != null) && __isset.right)
        {
          field.Name = "right";
          field.Type = TType.Struct;
          field.ID = 2;
          await oprot.WriteFieldBeginAsync(field, cancellationToken);
          await Right.WriteAsync(oprot, 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 Task other)) return false;
      if (ReferenceEquals(this, other)) return true;
      return ((__isset.left == other.__isset.left) && ((!__isset.left) || (System.Object.Equals(Left, other.Left))))
        && ((__isset.right == other.__isset.right) && ((!__isset.right) || (System.Object.Equals(Right, other.Right))));
    }

    public override int GetHashCode() {
      int hashcode = 157;
      unchecked {
        if((Left != null) && __isset.left)
        {
          hashcode = (hashcode * 397) + Left.GetHashCode();
        }
        if((Right != null) && __isset.right)
        {
          hashcode = (hashcode * 397) + Right.GetHashCode();
        }
      }
      return hashcode;
    }

    public override string ToString()
    {
      var sb = new StringBuilder("Task(");
      int tmp1 = 0;
      if((Left != null) && __isset.left)
      {
        if(0 < tmp1++) { sb.Append(", "); }
        sb.Append("Left: ");
        Left.ToString(sb);
      }
      if((Right != null) && __isset.right)
      {
        if(0 < tmp1++) { sb.Append(", "); }
        sb.Append("Right: ");
        Right.ToString(sb);
      }
      sb.Append(')');
      return sb.ToString();
    }
  }


  [DataContract]
  public partial class TaskFault
  {
    private global::Thrift5320.exceptions.Task _left;
    private global::Thrift5320.exceptions.Task _right;

    [DataMember(Order = 0)]
    public global::Thrift5320.exceptions.Task Left
    {
      get
      {
        return _left;
      }
      set
      {
        this._left = value;
      }
    }

    [DataMember(Order = 0)]
    public global::Thrift5320.exceptions.Task Right
    {
      get
      {
        return _right;
      }
      set
      {
        this._right = value;
      }
    }

  }

}
