Ejemplo n.º 1
0
    /// <summary>
    /// 测试方法
    /// </summary>
    private void Test()
    {
        // 显示所有数据(以调试格式显示)
        Debug.Log(_table.ToString());

        // 显示所有数据(以存储格式显示)
        _display.text = _table.GetContent();

        // 拿到某一数据
        _display.text += "\n" + "1001的年龄: " + _table["1001"]["年龄"];
        // 拿到数据对象
        _display.text += "\n" + "1002的数据: " + _table["1002"].ToString();
        // 修改某一数据
        _table["1003"]["年龄"] = "10000";
        _display.text       += "\n" + "1003新的年龄: " + _table["1003"]["年龄"];

        // 添加一条数据
        CSVDataObject data = new CSVDataObject("1005",
                                               new Dictionary <string, string>()
        {
            { "姓名", "hahaha" },
            { "年龄", "250" },
            { "性别", "随便吧" },
        },
                                               new string[] { "编号", "姓名", "年龄", "性别" });

        _table[data.ID] = data;
        _display.text  += "\n" + "新添加的1005的数据: " + _table["1005"].ToString();

        // 删除数据
        _table.DeleteDataObject("1001");
        _table.DeleteDataObject("1002");
        _display.text += "\n" + "删了两个之后:" + "\n" + _table.GetContent();

        // 删除所有数据
        _table.DeleteAllDataObject();
        _display.text += "\n" + "还剩下:" + "\n" + _table.GetContent();
    }