
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using Luban;
using SimpleJSON;


namespace cfg
{
public sealed partial class Item : Luban.BeanBase
{
    public Item(JSONNode _buf) 
    {
        { if(!_buf["id"].IsNumber) { throw new SerializationException(); }  Id = _buf["id"]; }
        { if(!_buf["name"].IsString) { throw new SerializationException(); }  Name = _buf["name"]; }
        { if(!_buf["desc"].IsString) { throw new SerializationException(); }  Desc = _buf["desc"]; }
        { if(!_buf["price"].IsNumber) { throw new SerializationException(); }  Price = _buf["price"]; }
        { if(!_buf["upgrade_to_item_id"].IsNumber) { throw new SerializationException(); }  UpgradeToItemId = _buf["upgrade_to_item_id"]; }
        UpgradeToItemId_Ref = null;
        { var _j = _buf["expire_time"]; if (_j.Tag != JSONNodeType.None && _j.Tag != JSONNodeType.NullValue) { { if(!_j.IsNumber) { throw new SerializationException(); }  ExpireTime = _j; } } else { ExpireTime = null; } }
        { if(!_buf["batch_useable"].IsBoolean) { throw new SerializationException(); }  BatchUseable = _buf["batch_useable"]; }
        { if(!_buf["quality"].IsNumber) { throw new SerializationException(); }  Quality = (item.EQuality)_buf["quality"].AsInt; }
        { if(!_buf["exchange_stream"].IsObject) { throw new SerializationException(); }  ExchangeStream = item.ItemExchange.DeserializeItemExchange(_buf["exchange_stream"]);  }
        { var __json0 = _buf["exchange_list"]; if(!__json0.IsArray) { throw new SerializationException(); } ExchangeList = new System.Collections.Generic.List<item.ItemExchange>(__json0.Count); foreach(JSONNode __e0 in __json0.Children) { item.ItemExchange __v0;  { if(!__e0.IsObject) { throw new SerializationException(); }  __v0 = item.ItemExchange.DeserializeItemExchange(__e0);  }  ExchangeList.Add(__v0); }   }
        { if(!_buf["exchange_column"].IsObject) { throw new SerializationException(); }  ExchangeColumn = item.ItemExchange.DeserializeItemExchange(_buf["exchange_column"]);  }
    }

    public static Item DeserializeItem(JSONNode _buf)
    {
        return new Item(_buf);
    }

    /// <summary>
    /// 这是id
    /// </summary>
    public readonly int Id;
    /// <summary>
    /// 名字
    /// </summary>
    public readonly string Name;
    /// <summary>
    /// 描述
    /// </summary>
    public readonly string Desc;
    /// <summary>
    /// 价格
    /// </summary>
    public readonly int Price;
    /// <summary>
    /// 引用当前表
    /// </summary>
    public readonly int UpgradeToItemId;
    public Item UpgradeToItemId_Ref;
    /// <summary>
    /// 过期时间
    /// </summary>
    public readonly long? ExpireTime;
    /// <summary>
    /// 能否批量使用
    /// </summary>
    public readonly bool BatchUseable;
    /// <summary>
    /// 品质
    /// </summary>
    public readonly item.EQuality Quality;
    /// <summary>
    /// 道具兑换配置
    /// </summary>
    public readonly item.ItemExchange ExchangeStream;
    public readonly System.Collections.Generic.List<item.ItemExchange> ExchangeList;
    /// <summary>
    /// 道具兑换配置
    /// </summary>
    public readonly item.ItemExchange ExchangeColumn;
   
    public const int __ID__ = 2289459;
    public override int GetTypeId() => __ID__;

    public  void ResolveRef(Tables tables)
    {
        
        
        
        
        UpgradeToItemId_Ref = tables.TbItem.GetOrDefault(UpgradeToItemId);
        
        
        
        ExchangeStream?.ResolveRef(tables);
        foreach (var _e in ExchangeList) { _e?.ResolveRef(tables); }
        ExchangeColumn?.ResolveRef(tables);
    }

    public override string ToString()
    {
        return "{ "
        + "id:" + Id + ","
        + "name:" + Name + ","
        + "desc:" + Desc + ","
        + "price:" + Price + ","
        + "upgradeToItemId:" + UpgradeToItemId + ","
        + "expireTime:" + ExpireTime + ","
        + "batchUseable:" + BatchUseable + ","
        + "quality:" + Quality + ","
        + "exchangeStream:" + ExchangeStream + ","
        + "exchangeList:" + Luban.StringUtil.CollectionToString(ExchangeList) + ","
        + "exchangeColumn:" + ExchangeColumn + ","
        + "}";
    }
}

}
