/**
 * <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>
  /// 美术资源总配置
  /// 包含所有表数据 + manifest信息（预加载配置）
  /// </summary>
  [DataContract(Namespace="")]
  public partial class ArtResourceConfig : TBase
  {
    private List<int> _preloadTableIds;
    private string _generateTime;

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

    [DataMember(Order = 0)]
    public List<int> PreloadTableIds
    {
      get
      {
        return _preloadTableIds;
      }
      set
      {
        __isset.preloadTableIds = true;
        this._preloadTableIds = value;
      }
    }

    [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 preloadTableIds;
      [DataMember]
      public bool generateTime;
    }

    #region XmlSerializer support

    public bool ShouldSerializePreloadTableIds()
    {
      return __isset.preloadTableIds;
    }

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

    #endregion XmlSerializer support

    public ArtResourceConfig()
    {
    }

    public ArtResourceConfig(List<global::Byway.Thrift.Data.ArtTable> @tables, long @version) : this()
    {
      this.Tables = @tables;
      this.Version = @version;
    }

    public ArtResourceConfig DeepCopy()
    {
      var tmp14 = new ArtResourceConfig();
      if((Tables != null))
      {
        tmp14.Tables = this.Tables.DeepCopy();
      }
      if((PreloadTableIds != null) && __isset.preloadTableIds)
      {
        tmp14.PreloadTableIds = this.PreloadTableIds.DeepCopy();
      }
      tmp14.__isset.preloadTableIds = this.__isset.preloadTableIds;
      tmp14.Version = this.Version;
      if((GenerateTime != null) && __isset.generateTime)
      {
        tmp14.GenerateTime = this.GenerateTime;
      }
      tmp14.__isset.generateTime = this.__isset.generateTime;
      return tmp14;
    }

    public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
    {
      iprot.IncrementRecursionDepth();
      try
      {
        bool isset_tables = 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 _list15 = await iprot.ReadListBeginAsync(cancellationToken);
                  Tables = new List<global::Byway.Thrift.Data.ArtTable>(_list15.Count);
                  for(int _i16 = 0; _i16 < _list15.Count; ++_i16)
                  {
                    global::Byway.Thrift.Data.ArtTable _elem17;
                    _elem17 = new global::Byway.Thrift.Data.ArtTable();
                    await _elem17.ReadAsync(iprot, cancellationToken);
                    Tables.Add(_elem17);
                  }
                  await iprot.ReadListEndAsync(cancellationToken);
                }
                isset_tables = true;
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 2:
              if (field.Type == TType.List)
              {
                {
                  var _list18 = await iprot.ReadListBeginAsync(cancellationToken);
                  PreloadTableIds = new List<int>(_list18.Count);
                  for(int _i19 = 0; _i19 < _list18.Count; ++_i19)
                  {
                    int _elem20;
                    _elem20 = await iprot.ReadI32Async(cancellationToken);
                    PreloadTableIds.Add(_elem20);
                  }
                  await iprot.ReadListEndAsync(cancellationToken);
                }
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 3:
              if (field.Type == TType.I64)
              {
                Version = await iprot.ReadI64Async(cancellationToken);
                isset_version = true;
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 4:
              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_tables)
        {
          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 tmp21 = new TStruct("ArtResourceConfig");
        await oprot.WriteStructBeginAsync(tmp21, cancellationToken);
        var tmp22 = new TField();
        if((Tables != null))
        {
          tmp22.Name = "tables";
          tmp22.Type = TType.List;
          tmp22.ID = 1;
          await oprot.WriteFieldBeginAsync(tmp22, cancellationToken);
          await oprot.WriteListBeginAsync(new TList(TType.Struct, Tables.Count), cancellationToken);
          foreach (global::Byway.Thrift.Data.ArtTable _iter23 in Tables)
          {
            await _iter23.WriteAsync(oprot, cancellationToken);
          }
          await oprot.WriteListEndAsync(cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((PreloadTableIds != null) && __isset.preloadTableIds)
        {
          tmp22.Name = "preloadTableIds";
          tmp22.Type = TType.List;
          tmp22.ID = 2;
          await oprot.WriteFieldBeginAsync(tmp22, cancellationToken);
          await oprot.WriteListBeginAsync(new TList(TType.I32, PreloadTableIds.Count), cancellationToken);
          foreach (int _iter24 in PreloadTableIds)
          {
            await oprot.WriteI32Async(_iter24, cancellationToken);
          }
          await oprot.WriteListEndAsync(cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        tmp22.Name = "version";
        tmp22.Type = TType.I64;
        tmp22.ID = 3;
        await oprot.WriteFieldBeginAsync(tmp22, cancellationToken);
        await oprot.WriteI64Async(Version, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
        if((GenerateTime != null) && __isset.generateTime)
        {
          tmp22.Name = "generateTime";
          tmp22.Type = TType.String;
          tmp22.ID = 4;
          await oprot.WriteFieldBeginAsync(tmp22, 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 ArtResourceConfig other)) return false;
      if (ReferenceEquals(this, other)) return true;
      return TCollections.Equals(Tables, other.Tables)
        && ((__isset.preloadTableIds == other.__isset.preloadTableIds) && ((!__isset.preloadTableIds) || (TCollections.Equals(PreloadTableIds, other.PreloadTableIds))))
        && 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((Tables != null))
        {
          hashcode = (hashcode * 397) + TCollections.GetHashCode(Tables);
        }
        if((PreloadTableIds != null) && __isset.preloadTableIds)
        {
          hashcode = (hashcode * 397) + TCollections.GetHashCode(PreloadTableIds);
        }
        hashcode = (hashcode * 397) + Version.GetHashCode();
        if((GenerateTime != null) && __isset.generateTime)
        {
          hashcode = (hashcode * 397) + GenerateTime.GetHashCode();
        }
      }
      return hashcode;
    }

    public override string ToString()
    {
      var tmp25 = new StringBuilder("ArtResourceConfig(");
      if((Tables != null))
      {
        tmp25.Append(", Tables: ");
        Tables.ToString(tmp25);
      }
      if((PreloadTableIds != null) && __isset.preloadTableIds)
      {
        tmp25.Append(", PreloadTableIds: ");
        PreloadTableIds.ToString(tmp25);
      }
      tmp25.Append(", Version: ");
      Version.ToString(tmp25);
      if((GenerateTime != null) && __isset.generateTime)
      {
        tmp25.Append(", GenerateTime: ");
        GenerateTime.ToString(tmp25);
      }
      tmp25.Append(')');
      return tmp25.ToString();
    }
  }

}
