/**
 * <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
{

  /// <summary>
  /// 图集配置（Thrift序列化用）
  /// </summary>
  [DataContract(Namespace="")]
  public partial class ArtAtlasConfig : TBase
  {
    private string _generateTime;

    [DataMember(Order = 0)]
    public List<global::Byway.Thrift.Data.ArtAtlasInfo> Atlases { get; set; }

    [DataMember(Order = 0)]
    public long Version { get; set; }

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


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

    #region XmlSerializer support

    public bool ShouldSerializeGenerateTime()
    {
      return __isset.generateTime;
    }

    #endregion XmlSerializer support

    public ArtAtlasConfig()
    {
    }

    public ArtAtlasConfig(List<global::Byway.Thrift.Data.ArtAtlasInfo> @atlases, long @version) : this()
    {
      this.Atlases = @atlases;
      this.Version = @version;
    }

    public ArtAtlasConfig DeepCopy()
    {
      var tmp9 = new ArtAtlasConfig();
      if((Atlases != null))
      {
        tmp9.Atlases = this.Atlases.DeepCopy();
      }
      tmp9.Version = this.Version;
      if((GenerateTime != null) && __isset.generateTime)
      {
        tmp9.GenerateTime = this.GenerateTime;
      }
      tmp9.__isset.generateTime = this.__isset.generateTime;
      return tmp9;
    }

    public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
    {
      iprot.IncrementRecursionDepth();
      try
      {
        bool isset_atlases = false;
        bool isset_version = false;
        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)
              {
                {
                  var _list10 = await iprot.ReadListBeginAsync(cancellationToken);
                  Atlases = new List<global::Byway.Thrift.Data.ArtAtlasInfo>(_list10.Count);
                  for(int _i11 = 0; _i11 < _list10.Count; ++_i11)
                  {
                    global::Byway.Thrift.Data.ArtAtlasInfo _elem12;
                    _elem12 = new global::Byway.Thrift.Data.ArtAtlasInfo();
                    await _elem12.ReadAsync(iprot, cancellationToken);
                    Atlases.Add(_elem12);
                  }
                  await iprot.ReadListEndAsync(cancellationToken);
                }
                isset_atlases = true;
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 2:
              if (field.Type == TType.I64)
              {
                Version = await iprot.ReadI64Async(cancellationToken);
                isset_version = true;
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 3:
              if (field.Type == TType.String)
              {
                GenerateTime = 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);
        if (!isset_atlases)
        {
          throw new TProtocolException(TProtocolException.INVALID_DATA);
        }
        if (!isset_version)
        {
          throw new TProtocolException(TProtocolException.INVALID_DATA);
        }
      }
      finally
      {
        iprot.DecrementRecursionDepth();
      }
    }

    public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
    {
      oprot.IncrementRecursionDepth();
      try
      {
        var tmp13 = new TStruct("ArtAtlasConfig");
        await oprot.WriteStructBeginAsync(tmp13, cancellationToken);
        var tmp14 = new TField();
        if((Atlases != null))
        {
          tmp14.Name = "atlases";
          tmp14.Type = TType.List;
          tmp14.ID = 1;
          await oprot.WriteFieldBeginAsync(tmp14, cancellationToken);
          await oprot.WriteListBeginAsync(new TList(TType.Struct, Atlases.Count), cancellationToken);
          foreach (global::Byway.Thrift.Data.ArtAtlasInfo _iter15 in Atlases)
          {
            await _iter15.WriteAsync(oprot, cancellationToken);
          }
          await oprot.WriteListEndAsync(cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        tmp14.Name = "version";
        tmp14.Type = TType.I64;
        tmp14.ID = 2;
        await oprot.WriteFieldBeginAsync(tmp14, cancellationToken);
        await oprot.WriteI64Async(Version, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
        if((GenerateTime != null) && __isset.generateTime)
        {
          tmp14.Name = "generateTime";
          tmp14.Type = TType.String;
          tmp14.ID = 3;
          await oprot.WriteFieldBeginAsync(tmp14, cancellationToken);
          await oprot.WriteStringAsync(GenerateTime, 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 ArtAtlasConfig other)) return false;
      if (ReferenceEquals(this, other)) return true;
      return TCollections.Equals(Atlases, other.Atlases)
        && global::System.Object.Equals(Version, other.Version)
        && ((__isset.generateTime == other.__isset.generateTime) && ((!__isset.generateTime) || (global::System.Object.Equals(GenerateTime, other.GenerateTime))));
    }

    public override int GetHashCode() {
      int hashcode = 157;
      unchecked {
        if((Atlases != null))
        {
          hashcode = (hashcode * 397) + TCollections.GetHashCode(Atlases);
        }
        hashcode = (hashcode * 397) + Version.GetHashCode();
        if((GenerateTime != null) && __isset.generateTime)
        {
          hashcode = (hashcode * 397) + GenerateTime.GetHashCode();
        }
      }
      return hashcode;
    }

    public override string ToString()
    {
      var tmp16 = new StringBuilder("ArtAtlasConfig(");
      if((Atlases != null))
      {
        tmp16.Append(", Atlases: ");
        Atlases.ToString(tmp16);
      }
      tmp16.Append(", Version: ");
      Version.ToString(tmp16);
      if((GenerateTime != null) && __isset.generateTime)
      {
        tmp16.Append(", GenerateTime: ");
        GenerateTime.ToString(tmp16);
      }
      tmp16.Append(')');
      return tmp16.ToString();
    }
  }

}
