/// <summary> /// Deletes the items supplied in the <see cref="VirtualFileBaseCollection"/>. /// </summary> /// <param name="items">The items to delete.</param> public static void DeleteItems(VirtualFileBaseCollection items) { //Can only delete items inheriting from Unified[Directory/File] foreach (VirtualFileBase fileItem in items) { if (CanEdit(fileItem)) { UnifiedDirectory directory = fileItem as UnifiedDirectory; if (directory != null) { directory.Delete(); continue; } UnifiedFile file = fileItem as UnifiedFile; if (file != null) { file.Delete(); continue; } } else { //TODO: What do we do with delete operation on unknown items. // Throw exception? Silently ignore? Logging! } } }
/// <summary> /// Copies the items in the collection to a target collection. /// </summary> /// <param name="targetCollection">The target collection.</param> public void CopyTo(VirtualFileBaseCollection targetCollection) { foreach (VirtualFileBase fileItem in this) { targetCollection.Add(fileItem); } }
///<summary> /// Undo Check Out of all files that are checked out in the supplied <see cref="VirtualFileBaseCollection"/>. ///</summary> /// <param name="items">The items to perform undo checkout on.</param> /// <remarks>Files not implementing <see cref="IVersioningFile"/> in are ignored.</remarks> public static void UndoCheckoutItems(VirtualFileBaseCollection items) { foreach (VirtualFileBase fileItem in items) { if (CanUndoCheckOut(fileItem)) { ((IVersioningFile)fileItem).UndoCheckOut(); } } }
// TODO: For nice flexibility this should be a wrapper with plug-in provider support. // Since the base provider API doesn't support any modifications at all, we need custom implementations for every modification. // The UnifiedFile and UnifiedDirectory provides abstract API for modifications, but it's likely that the individual inheritors // are incompatible with each other. Meaning that moving a file between different providers are likely to fail. /// <summary> /// Pastes the files in the source collection to the supplied target directory. /// </summary> /// <param name="sourceItems">A collection of source items to paste.</param> /// <param name="targetDirectory">The destination directory.</param> /// <param name="pasteMode"> /// Determines how the source files are treated when the paste operation is performed. /// <list type="table"> /// <listheader> /// <term>pasteMode</term><description>Result</description> /// </listheader> /// <item> /// <term><see cref="PasteMode.Copy"/></term> /// <description>The source items are copied to the new location.</description> /// </item> /// <item> /// <term><see cref="PasteMode.Cut"/></term> /// <description>The source items are moved from their original location to the new location.</description> /// </item> /// </list> /// </param> public static void PasteFiles(VirtualFileBaseCollection sourceItems, UnifiedDirectory targetDirectory, PasteMode pasteMode) { // Have to assume unified file // The Versioning VPP has copy/move support built in, but only for operations inside the Versioning file systems. foreach (VirtualFileBase sourceItem in sourceItems) { try { if (pasteMode == PasteMode.Copy) { CopyItem(sourceItem, targetDirectory); } else if (pasteMode == PasteMode.Cut) { MoveItem(sourceItem, targetDirectory); } } catch (FileIsCheckedOutException) { continue; } } }