/// <summary> /// Tests if a shell object represents a cloud storage folder. /// </summary> /// <param name="shellObject">The <see cref="IShellObject"/> to examine.</param> /// <returns><c>true</c> when the shell object is a cloud storage folder; otherwise <c>false</c>.</returns> private bool IsCloudStorageFolder(IShellObject shellObject) { if (shellObject is CustomShellObject && IsCloudStorageParsingName(shellObject.ParsingName)) { return(true); } return(false); }
/// <summary> /// Returns the full path of the specified <see cref="IShellObject"/>. /// </summary> /// <param name="shellObject">The <see cref="IShellObject"/> to examine.</param> /// <param name="pathSeparator">The path separator.</param> /// <returns>The full path of the specified <see cref="IShellObject"/>.</returns> public override string GetFullPath(IShellObject shellObject, string pathSeparator) { if (IsCloudStorageFolder(shellObject)) { // The full path should be all of the relative parsing names separated by the given path separator var relativeParsingNames = SplitCloudStorageParsingName(shellObject.ParsingName); return(string.Join(pathSeparator, relativeParsingNames)); } return(base.GetFullPath(shellObject, pathSeparator)); }
///////////////////////////////////////////////////////////////////////////////////////////////////// // PUBLIC PROCEDURES ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Creates the child <see cref="IShellObject"/> collection for the specified parent <see cref="IShellObject"/>. /// </summary> /// <param name="parentShellObject">The parent <see cref="IShellObject"/> to examine.</param> /// <returns>The child <see cref="IShellObject"/> collection for the specified parent <see cref="IShellObject"/>.</returns> public override IList <IShellObject> CreateObjectChildren(IShellObject parentShellObject) { var results = base.CreateObjectChildren(parentShellObject); // Remove any results that are special folders for (var index = results.Count - 1; index >= 0; index--) { if (results[index].SpecialFolderKind != SpecialFolderKind.None) { results.RemoveAt(index); } } if (parentShellObject.SpecialFolderKind == SpecialFolderKind.Computer) { // Add a root folder results.Add(this.CreateObjectForParsingName(CloudStorageParsingNameRoot)); } else if (IsCloudStorageFolder(parentShellObject)) { var relativeParsingNames = SplitCloudStorageParsingName(parentShellObject.ParsingName); if (relativeParsingNames.Count == 1) { // Add additional child folders below the root cloud folder (e.g. cloud:\NewFolder) foreach (string folderName in new string[] { "Private", "Public" }) { results.Add(this.CreateObjectForParsingName(CombineCloudStorageParsingNames(parentShellObject.ParsingName, folderName))); } } else if (relativeParsingNames.Count == 2) { // Add additional child folders below the first level cloud folders (e.g. cloud:\FirstLevel\NewFolder) for (int i = 0; i < 10; i++) { results.Add(this.CreateObjectForParsingName(CombineCloudStorageParsingNames(parentShellObject.ParsingName, "Folder" + i))); } } } return(results); }