using System; using System.Collections.Generic; #if false namespace Sog { public abstract class Cfg1KeyMgrTemplate : Singleton, IConfigManager where TManager : class, new() where TItem : ITabItemWith1Key, new() { protected SortedList m_ItemTable = new SortedList(); protected int m_ErrorCount = 0; public virtual SortedList ItemTable { get { return m_ItemTable; } } public virtual void ReadComplete() { } public void SetReadKeyOnlyInit(bool readKeyOnly) { // 为了减少内存占用, 手机上运行时, 没用到的数据不读入内存, 服务器不需要这个功能 //m_readKeyOnly = readKeyOnly; } public virtual bool Init(string fileName, string fileContent) { m_ItemTable.Clear(); TabTextFile tf = new TabTextFile(fileName, fileContent); while (tf.Next()) { TItem item = new TItem(); if (item.ReadItem(tf) == false) { TraceLog.Error("Failed to init TabManager:{0}, read line error, line:{1}", this.ToString(), tf.CurrentLine); m_ErrorCount++; continue; } if (m_ItemTable.ContainsKey(item.GetKey1())) { TraceLog.Error("Failed to init TabManager:{0}, multi key:{1}, line:{2}", this.ToString(), item.GetKey1(), tf.CurrentLine); m_ErrorCount++; continue; } m_ItemTable.Add(item.GetKey1(), item); } return true; } public virtual TItem GetConfig(TKey key) { if (m_ItemTable.ContainsKey(key)) { return m_ItemTable[key]; } return default(TItem); } public virtual bool Has(TKey key) { return m_ItemTable.ContainsKey(key); } public virtual TItem this[TKey key] { get { return GetConfig(key); } } public virtual int GetErrorCount() { return m_ErrorCount; } } } #endif