コード例 #1
0
        internal ISupportingFile UpdateFile(VersionedSupportingFile file, Stream newContents, string fileName)
        {
            //update the file contents
            string newStoragePath = _fileService.FileStorage.CreateFile(fileName);

            using (Stream outStream = new FileStream(newStoragePath, FileMode.OpenOrCreate, FileAccess.Write))
                StreamHelper.Transfer(newContents, outStream);

            //if the filename is changing, assign the file a new unique filename token
            string fileNameUniqueToken = fileName == file.FileName
                                                        ? file.FileNameUniqueToken
                                                        : _fileService.CreateUniqueFileNameToken(fileName);

            //Clone the file so that its old version can still be referenced by its old URL.
            //Note: this is required since editor undo operations may allow the post to rollback
            //to referencing the old version of the file.
            VersionedSupportingFile newFile = new VersionedSupportingFile(this, _nextVersion++, new Uri(UrlHelper.CreateUrlFromPath(newStoragePath)), fileName, fileNameUniqueToken, true, (BlogPostSettingsBag)file.Settings.Clone());;

            newFile.StoragePath = newStoragePath;

            RegisterSupportingFile(newFile);
            return(newFile);
        }
コード例 #2
0
 private void Delete(VersionedSupportingFile file)
 {
     _fileService.DeregisterSupportingFile(file);
     _versionTable.Remove(file.FileVersion);
 }
コード例 #3
0
 private ISupportingFile RegisterSupportingFile(VersionedSupportingFile file)
 {
     _versionTable[file.FileVersion] = file;
     _fileService.RegisterSupportingFile(file);
     return(file);
 }
コード例 #4
0
 private void Delete(VersionedSupportingFile file)
 {
     _fileService.DeregisterSupportingFile(file);
     _versionTable.Remove(file.FileVersion);
 }
コード例 #5
0
        internal ISupportingFile UpdateFile(VersionedSupportingFile file, Stream newContents, string fileName)
        {
            //update the file contents
            string newStoragePath = _fileService.FileStorage.CreateFile(fileName);
            using (Stream outStream = new FileStream(newStoragePath, FileMode.OpenOrCreate, FileAccess.Write))
                StreamHelper.Transfer(newContents, outStream);

            //if the filename is changing, assign the file a new unique filename token
            string fileNameUniqueToken = fileName == file.FileName
                                             ? file.FileNameUniqueToken
                                             : _fileService.CreateUniqueFileNameToken(fileName);

            //Clone the file so that its old version can still be referenced by its old URL.
            //Note: this is required since editor undo operations may allow the post to rollback
            //to referencing the old version of the file.
            VersionedSupportingFile newFile = new VersionedSupportingFile(this, _nextVersion++, new Uri(UrlHelper.CreateUrlFromPath(newStoragePath)), fileName, fileNameUniqueToken, true, (BlogPostSettingsBag)file.Settings.Clone()); ;
            newFile.StoragePath = newStoragePath;

            RegisterSupportingFile(newFile);
            return newFile;
        }
コード例 #6
0
 private ISupportingFile RegisterSupportingFile(VersionedSupportingFile file)
 {
     _versionTable[file.FileVersion] = file;
     _fileService.RegisterSupportingFile(file);
     return file;
 }