public bool LoadFromStream(Stream stream) { if (stream == null || !stream.CanRead) { return(false); } ConfigFileHeader header = new ConfigFileHeader(); header.SeekFileToHeader(stream); if (!header.LoadFromStream(stream) || !header.IsVaild) { return(false); } if (!header.IsSplitFile) { return(false); } // 索引偏移 stream.Seek(header.indexOffset, SeekOrigin.Begin); ConfigWrap.ConfigValueType valueType = (ConfigWrap.ConfigValueType)stream.ReadByte(); m_ValueType = valueType; switch (valueType) { case ConfigWrap.ConfigValueType.cvObject: LoadObjectIndex(header, stream); break; case ConfigWrap.ConfigValueType.cvList: LoadListIndex(header, stream); break; case ConfigWrap.ConfigValueType.cvMap: LoadMapIndex(header, stream); break; default: return(false); } return(true); }
private bool LoadDataFromStream(Stream stream) { if (m_IndexFile == null || stream == null || !stream.CanRead) { return(false); } long cntOffset = stream.Length - 4; if (cntOffset <= 0) { return(false); } stream.Seek(cntOffset, SeekOrigin.Begin); int cnt = FilePathMgr.GetInstance().ReadInt(stream); if (cnt <= 0) { return(false); } ConfigWrap.ConfigValueType valueType = this.ValueType; System.Type tt = typeof(K); stream.Seek(0, SeekOrigin.Begin); // int startIndex = FilePathMgr.GetInstance().ReadInt(stream); for (int i = 0; i < cnt; ++i) { System.Object key = FilePathMgr.GetInstance().ReadObject(stream, tt); K k = (K)key; V value = ReadItemValue(stream, k); if (m_DataMap == null) { m_DataMap = new Dictionary <K, V>(); } m_DataMap[k] = value; } return(true); }