/// <summary> /// Retrieves the parent folder of the passed-in file /// </summary> /// <param name="token">The connection token for the provider</param> /// <param name="fileKey">The file identifier</param> /// <returns>Single version control folder</returns> public VersionControlFolder RetrieveFolderByFile(object token, string fileKey) { /* * TODO: Replace with a real implementation that is appropriate for the provider */ //Verify the token AuthenticationToken authToken = InternalFunctions.VerifyToken(token); //We just get the file path and remove the last part (the file node) Uri uri = new Uri(fileKey); VersionControlFolder versionControlFolder = new VersionControlFolder(); if (uri.Segments.Length < 2) { versionControlFolder.Name = "Root Folder"; versionControlFolder.FolderKey = "test://"; } else { versionControlFolder.Name = uri.Segments[uri.Segments.Length - 2].Replace("/", ""); string folderKey = ""; for (int i = 0; i < uri.Segments.Length - 1; i++) { folderKey += uri.Segments[i]; } versionControlFolder.FolderKey = folderKey; } return(versionControlFolder); }
/// <summary> /// Retrieves a single folder by its unique key /// </summary> /// <param name="token">The connection token for the provider</param> /// <param name="folderKey">The folder identifier</param> /// <param name="branchKey">The name of the branch</param> /// <returns>Single version control folder</returns> public VersionControlFolder RetrieveFolder(object token, string folderKey, string branchKey) { /* * TODO: Replace with a real implementation that is appropriate for the provider */ //Verify the token AuthenticationToken authToken = InternalFunctions.VerifyToken(token); try { //Just strip of the last part of the fake URI Uri uri = new Uri(folderKey); VersionControlFolder versionControlFolder = new VersionControlFolder(); versionControlFolder.FolderKey = folderKey; versionControlFolder.Name = uri.Segments[uri.Segments.Length - 1]; return(versionControlFolder); } catch (Exception exception) { //Throw an unable to get artifact exception throw new VersionControlArtifactNotFoundException("Unable to retrieve folder '" + folderKey + "'", exception); } }