using System.Collections.Generic;
using LitJson;


public class #TableName#Cfg : BaseCfg
{

    Dictionary<#KeyType#, #TableName#Item> dict = new Dictionary<#KeyType#, #TableName#Item>();

    public #TableName#Cfg()
    {
        LoadData();
    }

    void LoadData()
    {
        string cfgName = "#TableName#";
        string text = ResourceManager.LoadConfigText(cfgName);
        JsonData json = JsonMapper.ToObject(text);
        JsonData list = json["datalist"];
        for(int i = 0; i < list.Count; i++)
        {
            #TableName#Item item = new #TableName#Item();
           //Automatic generation of assignment code start

          //Automatic generation of assignment code end
            dict[item.keyname] = item;
        }
    }

    public #TableName#Item GetValue(#KeyType# key)
    {
        if (dict.TryGetValue(key, out #TableName#Item val))
            return val;
        else
            return null;
    }

    public List<#TableName#Item> GetValueList()
    {
        List<#TableName#Item> lst = new List<#TableName#Item>();
        foreach (KeyValuePair<#KeyType#, #TableName#Item> kvp in dict)
            lst.Add(kvp.Value);
        return lst;
    }

    public bool HasKey(#KeyType# key)
    {
        return dict.ContainsKey(key);
    }

    public int GetLength()
    {
        return size;
    }

    class DataList
    {
        public List<#TableName#Item> datalist = new List<#TableName#Item>();
    }
}

public class #TableName#Item
{
    //Automatically generate attribute codes start

     //Automatically generate attribute codes end
    public #KeyType# keyname;
}