/// <summary> /// Opens the contents of a single file by its key, if the revision is specified, need to return the /// details of the file for that specific revision, otherwise just return the most recent /// </summary> /// <param name="token">The connection token for the provider</param> /// <param name="fileKey">The file identifier</param> /// <param name="branchKey">The name of the branch</param> /// <param name="revisionKey">The revision identifier (optional)</param> /// <returns></returns> public VersionControlFileStream OpenFile(object token, string fileKey, string revisionKey, string branchKey) { /* * TODO: Replace with a real implementation that is appropriate for the provider */ //Verify the token AuthenticationToken authToken = InternalFunctions.VerifyToken(token); //For this dummy provider we just need to create a new in-memory stream, one for latest revision //and one for a specific one string dummyText = ""; if (revisionKey == "") { dummyText = "Latest Revision"; } else { dummyText = "Specific Revision"; } byte[] buffer = ASCIIEncoding.UTF8.GetBytes(dummyText); MemoryStream memoryStream = new MemoryStream(buffer); VersionControlFileStream versionControlFileStream = new VersionControlFileStream(); versionControlFileStream.FileKey = fileKey; versionControlFileStream.RevisionKey = revisionKey; versionControlFileStream.LocalPath = ""; //Not used by this provider since memory stream versionControlFileStream.DataStream = memoryStream; return(versionControlFileStream); }
/// <summary> /// Closes the data stream provided by OpenFile. Clients must NOT CLOSE THE STREAM DIRECTLY /// </summary> /// <param name="versionControlFileStream">The stream to be closed</param> public void CloseFile(VersionControlFileStream versionControlFileStream) { /* * TODO: Make sure that any temporary resources associated with the stream are released. * Also if this is a file stream from a temporary file location, should clean up the temporary files */ versionControlFileStream.DataStream.Close(); }