// TODO: 遇到 recpath 重复的,是否抛出异常? public void Add(BiblioStore biblio) { if (this._recPathTable.ContainsKey(biblio.RecPath) == true) { throw new ArgumentException("路径为 '" + biblio.RecPath + "' 的书目记录不能重复添加"); } this._lines.Add(biblio); this._recPathTable[biblio.RecPath] = biblio; }
// 根据 BiblioStore 对象拆分出 OrderListItem 对象数组 public static List <OrderListItem> SplitOrderListItems(BiblioStore biblio) { List <OrderListItem> results = new List <OrderListItem>(); List <OrderStore> orders = new List <OrderStore>(); // orders.AddRange(biblio.Orders); foreach (OrderStore order in biblio.Orders) { if (order.Type == "deleted") { continue; } if (string.IsNullOrEmpty(order.GetFieldValue("state"))) { orders.Add(order); } } while (orders.Count > 0) { OrderListItem item = new OrderListItem(); OrderStore start = orders[0]; item.Merge(start); orders.RemoveAt(0); for (int i = 0; i < orders.Count; i++) { OrderStore order = orders[i]; if (Compare(start, order) == true) { item.Merge(order); orders.RemoveAt(i); i--; } } results.Add(item); } return(results); }
public bool Remove(BiblioStore biblio) { this._recPathTable.Remove(biblio.RecPath); return(this._lines.Remove(biblio)); }