namespace Easychart.Finance.DataProvider { using System; using System.Collections; public class MemoryDataManager : DataManagerBase { private static Hashtable htHistorical = new Hashtable(); private static Hashtable htStreaming = new Hashtable(); private DataManagerBase InnerDataManager; public MemoryDataManager(DataManagerBase InnerDataManager) { this.InnerDataManager = InnerDataManager; } public void AddNewPacket(DataPacket dp) { string symbol = dp.Symbol; if (symbol.EndsWith("=X")) { symbol = symbol.Substring(0, symbol.Length - 2); } CommonDataProvider empty = htStreaming[symbol] as CommonDataProvider; if (empty == null) { empty = CommonDataProvider.Empty; htStreaming[symbol] = empty; } empty.Merge(dp); } public override IDataProvider GetData(string Code, int Count) { CommonDataProvider empty = (CommonDataProvider) htHistorical[Code]; if (empty == null) { if (this.InnerDataManager != null) { this.InnerDataManager.StartTime = base.StartTime; this.InnerDataManager.EndTime = base.EndTime; empty = this.InnerDataManager[Code, Count] as CommonDataProvider; empty.DataManager = this; } else { empty = CommonDataProvider.Empty; } htHistorical[Code] = empty; } CommonDataProvider cdp = (CommonDataProvider) htStreaming[Code]; if (cdp != null) { empty.Merge(cdp); cdp.ClearData(); } empty.SetStringData("Code", Code); return empty; } public void RemoveSymbol(string Symbol) { htHistorical.Remove(Symbol); htStreaming.Remove(Symbol); } } }