/// <summary> /// Removes the item. /// </summary> /// <param name="filename">The filename.</param> /// <returns> /// <c>true</c> if item was removed; otherwise, <c>false</c>. /// </returns> /// <externalUnit/> /// <revision revisor="dev13" date="11/18/2009" version="1.1.3.6"> /// Added documentation header /// </revision> public bool RemoveItem(string filename) { bool removed = false; FileManifestItem manifestItem = null; foreach (var item in this.ItemList) { if (item.FileName.Equals( filename, StringComparison.CurrentCultureIgnoreCase)) { manifestItem = item; // found it, so stop looking break; } } if (manifestItem != null) { removed = this.ItemList.Remove(manifestItem); } else { // not there so removal succeeds ok. removed = true; } return(removed); }
/// <summary> /// Add a file to the manifest, in lexical ordered position by /// filename, updating its entry if it's already there. We use this /// ordering to avoid giving away voter order in the tabulator /// artifact manifest. /// </summary> /// <param name="fileName">Relative filename</param> /// <returns> /// <c>true</c> if updated; otherwise, <c>false</c>. /// </returns> /// <externalUnit/> /// <revision revisor="dev05" date="03/25/09" version="1.0.9.9"> /// Method created. /// </revision> /// <revision revisor="dev06" date="4/22/09" version="1.0.11.10"> /// Method updated to return bool for success.. /// </revision> public bool SortedUpdateFile(string fileName) { bool updated = false; try { // New manifest item for this file. var newItem = new FileManifestItem(this.dataPath, fileName); // Index of first entry whose filename is greater than or // equal to the current filename. int index = this.ItemList.FindIndex( delegate(FileManifestItem item) { return(String.Compare(item.FileName, fileName) >= 0); }); if (index >= 0) { // Remove entry if we already have it. if (this.ItemList[index].FileName == fileName) { this.ItemList.RemoveAt(index); } this.ItemList.Insert(index, newItem); } else { // Add new item to end. this.ItemList.Add(newItem); } updated = true; } catch (Exception) { updated = false; } return(updated); }