static void Main(string[] args) { using (FileStream fd = File.OpenRead("E:\\out.hmf")) { System.Console.WriteLine(fd.Position); int len = (int)fd.Length; byte[] bs = new byte[len]; fd.Read(bs, 0, len); System.Console.WriteLine("eee " + bs[0]); Hmf h = new Hmf(); MemoryStream st = new MemoryStream(bs); st.Seek(0, SeekOrigin.Begin); System.Console.WriteLine(st.Position); System.Console.WriteLine(DateTime.Now.Second + " " + DateTime.Now.Millisecond); Dictionary<object, object> d = (Dictionary<object, object>)h.ReadObject(st); System.Console.WriteLine(d.Count); System.Console.WriteLine(DateTime.Now.Second + " " + DateTime.Now.Millisecond); } System.Console.WriteLine("hello world"); Thread.Sleep(10000); }
public void LoadConfig(int index) { Clear(); if (!m_mapOfStoryMap.ContainsKey(index)) { var path = string.Concat(SystemConfig.CONFIG_SUB_FOLDER, config_xml + index.ToString(), SystemConfig.CONFIG_FILE_EXTENSION); LoggerHelper.Warning("Load Story: " + path); if (SystemSwitch.UseHmf) { byte[] bs = XMLParser.LoadBytes(path); System.IO.MemoryStream stream = new MemoryStream(bs); stream.Seek(0, SeekOrigin.Begin); Hmf h = new Hmf(); Dictionary<object, object> map = (Dictionary<object, object>)h.ReadObject(stream); Dictionary<int, String> m_storyMap = new Dictionary<int, String>(); foreach (var node in map) { Dictionary<object, object> m = (Dictionary<object, object>)node.Value; m_storyMap.Add(int.Parse((string)node.Key), m[(object)"storyText"].ToString()); } #if UNITY_IPHONE m_mapOfStoryMap[index] = m_storyMap.SortByKey(); #else m_mapOfStoryMap[index] = m_storyMap.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); #endif } else { var xml = XMLParser.Load(path); if (xml != null) { var map = XMLParser.LoadIntMap(xml, config_xml); Dictionary<int, String> m_storyMap = new Dictionary<int, String>(); foreach (var node in map) { m_storyMap.Add(node.Key, node.Value["storyText"]); } m_mapOfStoryMap[index] = m_storyMap; } } } }