/**
 * <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 AtlasMap : TBase
  {
    private Dictionary<string, string> _sprites;
    private Dictionary<string, string> _names;

    [DataMember(Order = 0)]
    public Dictionary<string, string> Sprites
    {
      get
      {
        return _sprites;
      }
      set
      {
        __isset.@sprites = true;
        this._sprites = value;
      }
    }

    [DataMember(Order = 0)]
    public Dictionary<string, string> Names
    {
      get
      {
        return _names;
      }
      set
      {
        __isset.@names = true;
        this._names = value;
      }
    }


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

    #region XmlSerializer support

    public bool ShouldSerializeSprites()
    {
      return __isset.@sprites;
    }

    public bool ShouldSerializeNames()
    {
      return __isset.@names;
    }

    #endregion XmlSerializer support

    public AtlasMap()
    {
    }

    public AtlasMap DeepCopy()
    {
      var tmp0 = new AtlasMap();
      if((Sprites != null) && __isset.@sprites)
      {
        tmp0.Sprites = this.Sprites.DeepCopy();
      }
      tmp0.__isset.@sprites = this.__isset.@sprites;
      if((Names != null) && __isset.@names)
      {
        tmp0.Names = this.Names.DeepCopy();
      }
      tmp0.__isset.@names = this.__isset.@names;
      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.Map)
              {
                {
                  var _map1 = await iprot.ReadMapBeginAsync(cancellationToken);
                  Sprites = new Dictionary<string, string>(_map1.Count);
                  for(int _i2 = 0; _i2 < _map1.Count; ++_i2)
                  {
                    string _key3;
                    string _val4;
                    _key3 = await iprot.ReadStringAsync(cancellationToken);
                    _val4 = await iprot.ReadStringAsync(cancellationToken);
                    Sprites[_key3] = _val4;
                  }
                  await iprot.ReadMapEndAsync(cancellationToken);
                }
              }
              else
              {
                await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
              }
              break;
            case 2:
              if (field.Type == TType.Map)
              {
                {
                  var _map5 = await iprot.ReadMapBeginAsync(cancellationToken);
                  Names = new Dictionary<string, string>(_map5.Count);
                  for(int _i6 = 0; _i6 < _map5.Count; ++_i6)
                  {
                    string _key7;
                    string _val8;
                    _key7 = await iprot.ReadStringAsync(cancellationToken);
                    _val8 = await iprot.ReadStringAsync(cancellationToken);
                    Names[_key7] = _val8;
                  }
                  await iprot.ReadMapEndAsync(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 tmp9 = new TStruct("AtlasMap");
        await oprot.WriteStructBeginAsync(tmp9, cancellationToken);
        var tmp10 = new TField();
        if((Sprites != null) && __isset.@sprites)
        {
          tmp10.Name = "sprites";
          tmp10.Type = TType.Map;
          tmp10.ID = 1;
          await oprot.WriteFieldBeginAsync(tmp10, cancellationToken);
          await oprot.WriteMapBeginAsync(new TMap(TType.String, TType.String, Sprites.Count), cancellationToken);
          foreach (string _iter11 in Sprites.Keys)
          {
            await oprot.WriteStringAsync(_iter11, cancellationToken);
            await oprot.WriteStringAsync(Sprites[_iter11], cancellationToken);
          }
          await oprot.WriteMapEndAsync(cancellationToken);
          await oprot.WriteFieldEndAsync(cancellationToken);
        }
        if((Names != null) && __isset.@names)
        {
          tmp10.Name = "names";
          tmp10.Type = TType.Map;
          tmp10.ID = 2;
          await oprot.WriteFieldBeginAsync(tmp10, cancellationToken);
          await oprot.WriteMapBeginAsync(new TMap(TType.String, TType.String, Names.Count), cancellationToken);
          foreach (string _iter12 in Names.Keys)
          {
            await oprot.WriteStringAsync(_iter12, cancellationToken);
            await oprot.WriteStringAsync(Names[_iter12], cancellationToken);
          }
          await oprot.WriteMapEndAsync(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 AtlasMap other)) return false;
      if (ReferenceEquals(this, other)) return true;
      return ((__isset.@sprites == other.__isset.@sprites) && ((!__isset.@sprites) || (TCollections.Equals(Sprites, other.Sprites))))
        && ((__isset.@names == other.__isset.@names) && ((!__isset.@names) || (TCollections.Equals(Names, other.Names))));
    }

    public override int GetHashCode() {
      int hashcode = 157;
      unchecked {
        if((Sprites != null) && __isset.@sprites)
        {
          hashcode = (hashcode * 397) + TCollections.GetHashCode(Sprites);
        }
        if((Names != null) && __isset.@names)
        {
          hashcode = (hashcode * 397) + TCollections.GetHashCode(Names);
        }
      }
      return hashcode;
    }

    public override string ToString()
    {
      var tmp13 = new StringBuilder("AtlasMap(");
      int tmp14 = 0;
      if((Sprites != null) && __isset.@sprites)
      {
        if(0 < tmp14++) { tmp13.Append(", "); }
        tmp13.Append("Sprites: ");
        Sprites.ToString(tmp13);
      }
      if((Names != null) && __isset.@names)
      {
        if(0 < tmp14++) { tmp13.Append(", "); }
        tmp13.Append("Names: ");
        Names.ToString(tmp13);
      }
      tmp13.Append(')');
      return tmp13.ToString();
    }
  }

}
