using System;
using System.Collections.Generic;
namespace Typhoon.Excel2Json.Export
{
///
/// 表格基类
///
[Serializable]
public abstract class Table : ITable where T : ITableValue
{
//数据
public T[] Data;
public Dictionary> IntKeys = new Dictionary>();
public Dictionary> StringKeys =
new Dictionary>();
///
/// 是否有条目
///
/// 列名
/// 匹配值
///
public bool Has(string column, string key)
{
if (!StringKeys.ContainsKey(column))
{
return false;
}
return StringKeys[column].ContainsKey(key);
}
///
/// 是否有条目
///
/// 列名
/// 匹配值
///
public bool Has(string column, int key)
{
if (!IntKeys.ContainsKey(column))
{
return false;
}
return IntKeys[column].ContainsKey(key);
}
///
/// 获取条目
///
/// 列名
/// 匹配值
///
public ITableValue Get(string column, string key)
{
return GetValue(column, key);
}
///
/// 获取条目
///
/// 列名
/// 匹配值
///
public ITableValue Get(string column, int key)
{
return GetValue(column, key);
}
///
/// 获取条目
///
/// 列名
/// 匹配值
///
public T GetValue(string column, string key)
{
var index = StringKeys[column][key];
return Data[index];
}
///
/// 获取条目
///
/// 列名
/// 匹配值
///
public T GetValue(string column, int key)
{
var index = IntKeys[column][key];
return Data[index];
}
}
}