/// <summary> /// 释放所有注册的group,关闭流; /// </summary> /// <returns></returns> private void UnRegisterFromDatabase() { if (mGroups.Keys.Count == 0) { return; } List <string> keys = new List <string>(mGroups.Keys); GameConfigTypeStreamData data = null; for (int i = 0, imax = keys.Count; i < imax; i++) { data = null; if (!mGroups.TryGetValue(keys[i], out data)) { continue; } Stream fs = null; switch (data.GetGameConfigType()) { case GameConfigType.GameConfig_Xml: fs = XmlDatabase.Instance.RemoveFromDatabase(keys[i]); break; case GameConfigType.GameConfig_XmlSheet: fs = SheetDatabase.Instance.RemoveFromDatabase(keys[i]); break; } if (fs != null) { fs.Close(); } mGroups.Remove(keys[i]); } }
private Dictionary <string, GameConfigTypeStreamData> mGroups = new Dictionary <string, GameConfigTypeStreamData>(); // 缓存信息,清除时使用; /// <summary> /// 通过groupName释放流; /// </summary> /// <param name="groupName">group名称</param> private void UnRegisterFromDatabaseByGroupName(string groupName) { GameConfigTypeStreamData data = null; if (!mGroups.TryGetValue(groupName, out data)) { return; } Stream fs = null; switch (data.GetGameConfigType()) { case GameConfigType.GameConfig_Xml: fs = XmlDatabase.Instance.RemoveFromDatabase(groupName); break; case GameConfigType.GameConfig_XmlSheet: fs = SheetDatabase.Instance.RemoveFromDatabase(groupName); break; } if (fs != null) { fs.Close(); } mGroups.Remove(groupName); }
// 从.dat文件中读取配置数据; private void RegisterToDatabaseFromDat() { GameConfigTypeStreamData data = null; if (xmlList != null && xmlList.Count > 0) { for (int i = 0; i < xmlList.Count; i++) { string path = GetConfPath(xmlList[i]); FileStream fs = File.OpenRead(path); data = new GameConfigTypeStreamData(GameConfigType.GameConfig_Xml, fs); string temp = XmlDatabase.Instance.AddToDatabase(fs); // Debug.LogError("xml temp:"+temp); if (!mGroups.ContainsKey(temp)) { mGroups.Add(temp, data); } else { Debug.LogError("fail to add same path >>" + temp); } } } if (xmlSheetList != null && xmlSheetList.Count > 0) { for (int i = 0; i < xmlSheetList.Count; i++) { string path = GetConfPath(xmlSheetList[i]); FileStream fs = File.OpenRead(path); data = new GameConfigTypeStreamData(GameConfigType.GameConfig_XmlSheet, fs); string temp = SheetDatabase.Instance.AddToDatabase(fs); // Debug.LogError("sheet temp:" + temp); if (!mGroups.ContainsKey(temp)) { mGroups.Add(temp, data); } else { Debug.LogError("fail to add same path >>" + temp); } } } }