/// <summary> /// 添加 StatistTotalByDateTime,如果存在相同日期的事件,则累加该事件的 Total /// </summary> /// <param name="statist"></param> private void Add(StatistTotalByDateTime statist) { try { this._entries.Add(statist.DateTime, statist); } catch (ArgumentException) { this._entries[statist.DateTime].Total += statist.Total; } }
/// <summary> /// 该构造器接收一个字符串序列,把它转换成StatistTotalByDateTime链表,同时接收一个 DateMode 指示日期字符串的分割方式 /// </summary> /// <param name="lines">文本序列</param> /// <param name="dateMode">指示日期字符串的分割方式</param> public StatistTotalByDateTimeModel(IEnumerable <string> lines, DateMode dateMode) { foreach (var line in lines) { if (line != "" && line != "\r") // 忽略空行 { StatistTotalByDateTime statist = DatetimeParser.ParseExpressToStatistTotalByDateTime(line, dateMode); this.Add(statist); } } }
/// <summary> /// 添加一个条目 /// </summary> /// <param name="statistTotalByDateTime"></param> public void AddEntry(StatistTotalByDateTime statistTotalByDateTime) { this.Add(statistTotalByDateTime); }