//获取记录,如果不存在返回null public static DBTableDefineTemplate GetRecord(DBTableRecordIDType recordId, bool errorMsg = true) { if (instance == null) { Debug.LogError("表DBTableTemplate未加载"); return(null); } DBTableDefineTemplate record = null; if (recordDict.TryGetValue(recordId, out record)) { return(record); } if (errorMsg) { Debug.LogErrorFormat("表DBTableTemplate没有recordId = {0}的记录", recordId); } return(null); }
public void Init() { //如果recordDict不为null,说明已经初始化了 if (recordDict != null) { return; } recordDict = new Dictionary <DBTableRecordIDType, DBTableDefineTemplate>(); for (int i = 0; i < recordArray.Length; i++) { DBTableDefineTemplate record = recordArray[i]; if (!recordDict.ContainsKey(record.recordId)) { recordDict.Add(record.recordId, record); } else { Debug.LogErrorFormat("表DBTableTemplate有重复的记录,id = {0}", record.recordId); } } }