/**
 * <auto-generated>
 * Autogenerated by Thrift Compiler (0.22.0)
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 * </auto-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 Thrift;
using Thrift.Collections;
using System.Runtime.Serialization;
using Thrift.Protocol;
using Thrift.Protocol.Entities;
using Thrift.Protocol.Utilities;
using Thrift.Transport;
using Thrift.Transport.Client;


#pragma warning disable IDE0079  // remove unnecessary pragmas
#pragma warning disable IDE0017  // object init can be simplified
#pragma warning disable IDE0028  // collection init can be simplified
#pragma warning disable IDE0305  // collection init can be simplified
#pragma warning disable IDE0034  // simplify default expression
#pragma warning disable IDE0066  // use switch expression
#pragma warning disable IDE0090  // simplify new expression
#pragma warning disable IDE0290  // use primary CTOR
#pragma warning disable IDE1006  // parts of the code use IDL spelling
#pragma warning disable CA1822   // empty DeepCopy() methods still non-static
#pragma warning disable IDE0083  // pattern matching "that is not SomeType" requires net5.0 but we still support earlier versions

namespace Byway.Thrift.Data
{

  [DataContract(Namespace="")]
  public partial class RegionDataItem : TBase
  {
    private int _Id;
    private string _EnglishName;
    private string _ChineseName;
    private string _CountryCode;
    private int _PhoneCode;

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

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

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

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

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


    [DataMember(Order = 1)]
    public Isset __isset;
    [DataContract]
    public struct Isset
    {
      [DataMember]
      public bool Id;
      [DataMember]
      public bool EnglishName;
      [DataMember]
      public bool ChineseName;
      [DataMember]
      public bool CountryCode;
      [DataMember]
      public bool PhoneCode;
    }

    #region XmlSerializer support

    public bool ShouldSerializeId()
    {
      return __isset.Id;
    }

    public bool ShouldSerializeEnglishName()
    {
      return __isset.EnglishName;
    }

    public bool ShouldSerializeChineseName()
    {
      return __isset.ChineseName;
    }

    public bool ShouldSerializeCountryCode()
    {
      return __isset.CountryCode;
    }

    public bool ShouldSerializePhoneCode()
    {
      return __isset.PhoneCode;
    }

    #endregion XmlSerializer support

    public RegionDataItem()
    {
    }

    public RegionDataItem DeepCopy()
    {
      var tmp0 = new RegionDataItem();
      if(__isset.Id)
      {
        tmp0.Id = this.Id;
      }
      tmp0.__isset.Id = this.__isset.Id;
      if((EnglishName != null) && __isset.EnglishName)
      {
        tmp0.EnglishName = this.EnglishName;
      }
      tmp0.__isset.EnglishName = this.__isset.EnglishName;
      if((ChineseName != null) && __isset.ChineseName)
      {
        tmp0.ChineseName = this.ChineseName;
      }
      tmp0.__isset.ChineseName = this.__isset.ChineseName;
      if((CountryCode != null) && __isset.CountryCode)
      {
        tmp0.CountryCode = this.CountryCode;
      }
      tmp0.__isset.CountryCode = this.__isset.CountryCode;
      if(__isset.PhoneCode)
      {
        tmp0.PhoneCode = this.PhoneCode;
      }
      tmp0.__isset.PhoneCode = this.__isset.PhoneCode;
      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.I32)
              {
                Id = await iprot.ReadI32Async(cancellationToken);
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 2:
              if (field.Type == TType.String)
              {
                EnglishName = await iprot.ReadStringAsync(cancellationToken);
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 3:
              if (field.Type == TType.String)
              {
                ChineseName = await iprot.ReadStringAsync(cancellationToken);
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 4:
              if (field.Type == TType.String)
              {
                CountryCode = await iprot.ReadStringAsync(cancellationToken);
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 5:
              if (field.Type == TType.I32)
              {
                PhoneCode = 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 tmp1 = new TStruct("RegionDataItem");
        await oprot.WriteStructBeginAsync(tmp1, cancellationToken);
        var tmp2 = new TField();
        if(__isset.Id)
        {
          tmp2.Name = "Id";
          tmp2.Type = TType.I32;
          tmp2.ID = 1;
          await oprot.WriteFieldBeginAsync(tmp2, cancellationToken);
          await oprot.WriteI32Async(Id, cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((EnglishName != null) && __isset.EnglishName)
        {
          tmp2.Name = "EnglishName";
          tmp2.Type = TType.String;
          tmp2.ID = 2;
          await oprot.WriteFieldBeginAsync(tmp2, cancellationToken);
          await oprot.WriteStringAsync(EnglishName, cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((ChineseName != null) && __isset.ChineseName)
        {
          tmp2.Name = "ChineseName";
          tmp2.Type = TType.String;
          tmp2.ID = 3;
          await oprot.WriteFieldBeginAsync(tmp2, cancellationToken);
          await oprot.WriteStringAsync(ChineseName, cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((CountryCode != null) && __isset.CountryCode)
        {
          tmp2.Name = "CountryCode";
          tmp2.Type = TType.String;
          tmp2.ID = 4;
          await oprot.WriteFieldBeginAsync(tmp2, cancellationToken);
          await oprot.WriteStringAsync(CountryCode, cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if(__isset.PhoneCode)
        {
          tmp2.Name = "PhoneCode";
          tmp2.Type = TType.I32;
          tmp2.ID = 5;
          await oprot.WriteFieldBeginAsync(tmp2, cancellationToken);
          await oprot.WriteI32Async(PhoneCode, 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 RegionDataItem other)) return false;
      if (ReferenceEquals(this, other)) return true;
      return ((__isset.Id == other.__isset.Id) && ((!__isset.Id) || (global::System.Object.Equals(Id, other.Id))))
        && ((__isset.EnglishName == other.__isset.EnglishName) && ((!__isset.EnglishName) || (global::System.Object.Equals(EnglishName, other.EnglishName))))
        && ((__isset.ChineseName == other.__isset.ChineseName) && ((!__isset.ChineseName) || (global::System.Object.Equals(ChineseName, other.ChineseName))))
        && ((__isset.CountryCode == other.__isset.CountryCode) && ((!__isset.CountryCode) || (global::System.Object.Equals(CountryCode, other.CountryCode))))
        && ((__isset.PhoneCode == other.__isset.PhoneCode) && ((!__isset.PhoneCode) || (global::System.Object.Equals(PhoneCode, other.PhoneCode))));
    }

    public override int GetHashCode() {
      int hashcode = 157;
      unchecked {
        if(__isset.Id)
        {
          hashcode = (hashcode * 397) + Id.GetHashCode();
        }
        if((EnglishName != null) && __isset.EnglishName)
        {
          hashcode = (hashcode * 397) + EnglishName.GetHashCode();
        }
        if((ChineseName != null) && __isset.ChineseName)
        {
          hashcode = (hashcode * 397) + ChineseName.GetHashCode();
        }
        if((CountryCode != null) && __isset.CountryCode)
        {
          hashcode = (hashcode * 397) + CountryCode.GetHashCode();
        }
        if(__isset.PhoneCode)
        {
          hashcode = (hashcode * 397) + PhoneCode.GetHashCode();
        }
      }
      return hashcode;
    }

    public override string ToString()
    {
      var tmp3 = new StringBuilder("RegionDataItem(");
      int tmp4 = 0;
      if(__isset.Id)
      {
        if(0 < tmp4++) { tmp3.Append(", "); }
        tmp3.Append("Id: ");
        Id.ToString(tmp3);
      }
      if((EnglishName != null) && __isset.EnglishName)
      {
        if(0 < tmp4++) { tmp3.Append(", "); }
        tmp3.Append("EnglishName: ");
        EnglishName.ToString(tmp3);
      }
      if((ChineseName != null) && __isset.ChineseName)
      {
        if(0 < tmp4++) { tmp3.Append(", "); }
        tmp3.Append("ChineseName: ");
        ChineseName.ToString(tmp3);
      }
      if((CountryCode != null) && __isset.CountryCode)
      {
        if(0 < tmp4++) { tmp3.Append(", "); }
        tmp3.Append("CountryCode: ");
        CountryCode.ToString(tmp3);
      }
      if(__isset.PhoneCode)
      {
        if(0 < tmp4++) { tmp3.Append(", "); }
        tmp3.Append("PhoneCode: ");
        PhoneCode.ToString(tmp3);
      }
      tmp3.Append(')');
      return tmp3.ToString();
    }
  }

}
