/// <summary> /// 解析文件 /// </summary> /// <param name="path"></param> /// <returns></returns> public static InstantValueStorage Load(string path) { var storage = new InstantValueStorage(); using (StreamReader r = new StreamReader(path)) { string line = null; while ((line = r.ReadLine()) != null) { if (String.IsNullOrWhiteSpace(line)) { continue; } var divideLen = line.IndexOf(':'); var name = line.Substring(0, divideLen); var content = line.Substring(divideLen + 1); var times = content.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (!storage.Contains(name)) { storage[name] = new BaseList <Time>(); } var list = storage[name]; foreach (var timeStr in times) { var time = Time.ParseTimeOfDayWithTagString(timeStr); list.Add(time); } } } return(storage); }
/// <summary> /// 截取自列表 /// </summary> /// <param name="indexFrom"></param> /// <param name="count"></param> /// <returns></returns> public IListClass <TValue> GetSubList(int indexFrom, int count) { var newList = new BaseList <TValue>("SubOf" + Name); for (int i = 0; i < count && indexFrom + i < Count; i++) { newList.Add(this[indexFrom + i]); } return(newList); }