本文整理汇总了C#中DotNetNuke.Services.FileSystem.FolderMappingInfo类的典型用法代码示例。如果您正苦于以下问题:C# FolderMappingInfo类的具体用法?C# FolderMappingInfo怎么用?C# FolderMappingInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FolderMappingInfo类属于DotNetNuke.Services.FileSystem命名空间,在下文中一共展示了FolderMappingInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyFile
/// <summary>
/// Copies the specified file to the destination folder.
/// </summary>
public virtual void CopyFile(string folderPath, string fileName, string newFolderPath, FolderMappingInfo folderMapping)
{
Requires.NotNull("folderPath", folderPath);
Requires.NotNullOrEmpty("fileName", fileName);
Requires.NotNull("newFolderPath", newFolderPath);
Requires.NotNull("folderMapping", folderMapping);
if (folderPath == newFolderPath) return;
var sourceFolder = new FolderInfo { FolderPath = folderPath, FolderMappingID = folderMapping.FolderMappingID, PortalID = folderMapping.PortalID };
var destinationFolder = new FolderInfo { FolderPath = newFolderPath, FolderMappingID = folderMapping.FolderMappingID, PortalID = folderMapping.PortalID };
using (var fileContent = GetFileStream(sourceFolder, fileName))
{
if (!fileContent.CanSeek)
{
using (var seekableStream = FileManager.Instance.GetSeekableStream(fileContent))
{
AddFile(destinationFolder, fileName, seekableStream);
}
}
else
{
AddFile(destinationFolder, fileName, fileContent);
}
}
}
示例2: CopyFile
public override void CopyFile(string folderPath, string fileName, string newFolderPath, FolderMappingInfo folderMapping)
{
Requires.NotNull("folderPath", folderPath);
Requires.NotNullOrEmpty("fileName", fileName);
Requires.NotNull("newFolderPath", newFolderPath);
Requires.NotNull("folderMapping", folderMapping);
if (folderPath == newFolderPath) return;
var filePath = GetActualPath(folderMapping, folderPath, fileName);
var newFilePath = GetActualPath(folderMapping, newFolderPath, fileName);
if (FileWrapper.Instance.Exists(filePath))
{
FileWrapper.Instance.Copy(filePath, newFilePath, true);
}
}
示例3: DeleteFile_Calls_FolderProviderDeleteFile
public void DeleteFile_Calls_FolderProviderDeleteFile()
{
//Arrange
var fileInfo = new FileInfoBuilder().Build();
_fileVersionController.Setup(fv => fv.DeleteAllUnpublishedVersions(fileInfo, false));
var folderMapping = new FolderMappingInfo { FolderProviderType = Constants.FOLDER_ValidFolderProviderType };
_folderMappingController.Setup(fmc => fmc.GetFolderMapping(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidFolderMappingID)).Returns(folderMapping);
_mockData.Setup(md => md.DeleteFile(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<int>()));
_mockFolderProvider.Setup(mf => mf.DeleteFile(fileInfo)).Verifiable();
string someString;
_mockFileLockingController.Setup(mflc => mflc.IsFileLocked(fileInfo, out someString)).Returns(false);
//Act
FileDeletionController.Instance.DeleteFile(fileInfo);
//Assert
_mockFolderProvider.Verify();
}
示例4: RenameFile_Calls_FolderProvider_RenameFile_When_FileNames_Are_Distinct_And_NewFileName_Does_Not_Exist
public void RenameFile_Calls_FolderProvider_RenameFile_When_FileNames_Are_Distinct_And_NewFileName_Does_Not_Exist()
{
_fileInfo.Setup(fi => fi.FileName).Returns(Constants.FOLDER_ValidFileName);
_fileInfo.Setup(fi => fi.PortalId).Returns(Constants.CONTENT_ValidPortalId);
_fileInfo.Setup(fi => fi.FolderId).Returns(Constants.FOLDER_ValidFolderId);
_fileInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID);
_folderManager.Setup(fm => fm.GetFolder(Constants.FOLDER_ValidFolderId)).Returns(_folderInfo.Object);
_mockFileManager.Setup(mfm => mfm.FileExists(_folderInfo.Object, Constants.FOLDER_OtherValidFileName, It.IsAny<bool>())).Returns(false);
_mockFileManager.Setup(mfm => mfm.UpdateFile(_fileInfo.Object));
var folderMapping = new FolderMappingInfo();
folderMapping.FolderProviderType = Constants.FOLDER_ValidFolderProviderType;
_folderMappingController.Setup(fmc => fmc.GetFolderMapping(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidFolderMappingID)).Returns(folderMapping);
_mockFileManager.Object.RenameFile(_fileInfo.Object, Constants.FOLDER_OtherValidFileName);
_mockFolder.Verify(mf => mf.RenameFile(_fileInfo.Object, Constants.FOLDER_OtherValidFileName), Times.Once());
}
示例5: RenameFile_Throws_When_FolderProvider_Throws
public void RenameFile_Throws_When_FolderProvider_Throws()
{
_fileInfo.Setup(fi => fi.FileName).Returns(Constants.FOLDER_ValidFileName);
_fileInfo.Setup(fi => fi.PortalId).Returns(Constants.CONTENT_ValidPortalId);
_fileInfo.Setup(fi => fi.FolderId).Returns(Constants.FOLDER_ValidFolderId);
_fileInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID);
_folderManager.Setup(fm => fm.GetFolder(Constants.FOLDER_ValidFolderId)).Returns(_folderInfo.Object);
_mockFileManager.Setup(mfm => mfm.FileExists(_folderInfo.Object, Constants.FOLDER_OtherValidFileName, It.IsAny<bool>())).Returns(false);
_mockFileManager.Setup(mfm => mfm.UpdateFile(_fileInfo.Object));
var folderMapping = new FolderMappingInfo();
folderMapping.FolderProviderType = Constants.FOLDER_ValidFolderProviderType;
_folderMappingController.Setup(fmc => fmc.GetFolderMapping(Constants.FOLDER_ValidFolderMappingID)).Returns(folderMapping);
_mockFolder.Setup(mf => mf.RenameFile(_fileInfo.Object, Constants.FOLDER_OtherValidFileName)).Throws<Exception>();
_mockFileManager.Object.RenameFile(_fileInfo.Object, Constants.FOLDER_OtherValidFileName);
}
示例6: GetFolderMappingViewModel
private FolderMappingViewModel GetFolderMappingViewModel(FolderMappingInfo folderMapping)
{
return new FolderMappingViewModel
{
Id = folderMapping.FolderMappingID,
FolderTypeName = folderMapping.FolderProviderType,
Name = folderMapping.MappingName
};
}
示例7: GetSubFolders
/// <summary>
/// Gets the list of subfolders for the specified folder.
/// </summary>
public abstract IEnumerable<string> GetSubFolders(string folderPath, FolderMappingInfo folderMapping);
示例8: GetActualPath
/// <summary>
/// Get actual path to a folder in the specified folder mapping
/// </summary>
/// <param name="folderMapping">The folder mapping</param>
/// <param name="folderPath">The folder path</param>
/// <returns>A windows supported path to the folder</returns>
protected virtual string GetActualPath(FolderMappingInfo folderMapping, string folderPath)
{
return PathUtils.Instance.GetPhysicalPath(folderMapping.PortalID, folderPath);
}
示例9: ExistsFolder_Throws_On_Null_FolderPath
public void ExistsFolder_Throws_On_Null_FolderPath()
{
var folderMapping = new FolderMappingInfo();
_sfp.FolderExists(null, folderMapping);
}
示例10: FolderExists
public override bool FolderExists(string folderPath, FolderMappingInfo folderMapping)
{
Requires.NotNull("folderPath", folderPath);
Requires.NotNull("folderMapping", folderMapping);
return DirectoryWrapper.Instance.Exists(GetActualPath(folderMapping, folderPath));
}
示例11: GetSubFolders_Throws_On_Null_FolderPath
public void GetSubFolders_Throws_On_Null_FolderPath()
{
var folderMapping = new FolderMappingInfo();
_sfp.GetSubFolders(null, folderMapping).ToList();
}
示例12: AddFile_Throws_When_Portal_Has_No_Space_Available
public void AddFile_Throws_When_Portal_Has_No_Space_Available()
{
_folderInfo.Setup(fi => fi.PortalID).Returns(Constants.CONTENT_ValidPortalId);
_folderInfo.Setup(fi => fi.PhysicalPath).Returns(Constants.FOLDER_ValidFolderPath);
_folderInfo.Setup(fi => fi.PhysicalPath).Returns(Constants.FOLDER_ValidFolderPath);
_folderInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID);
_mockData.Setup(c => c.GetProviderPath()).Returns(String.Empty);
var fileContent = new MemoryStream();
_globals.Setup(g => g.GetSubFolderPath(Constants.FOLDER_ValidFilePath, Constants.CONTENT_ValidPortalId)).Returns(Constants.FOLDER_ValidFolderRelativePath);
var folderMapping = new FolderMappingInfo { FolderProviderType = Constants.FOLDER_ValidFolderProviderType };
_folderMappingController.Setup(fmc => fmc.GetFolderMapping(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidFolderMappingID)).Returns(folderMapping);
_portalController.Setup(pc => pc.HasSpaceAvailable(Constants.CONTENT_ValidPortalId, fileContent.Length)).Returns(false);
_mockFileManager.Setup(fm => fm.CreateFileContentItem()).Returns(new ContentItem());
_mockFileManager.Object.AddFile(_folderInfo.Object, Constants.FOLDER_ValidFileName, fileContent, false, false, Constants.CONTENTTYPE_ValidContentType);
}
示例13: AddFile_Checks_Space_For_Stream_Length
public void AddFile_Checks_Space_For_Stream_Length()
{
//Arrange
_folderInfo.Setup(fi => fi.PortalID).Returns(Constants.CONTENT_ValidPortalId);
_folderInfo.Setup(fi => fi.FolderID).Returns(Constants.FOLDER_ValidFolderId);
_folderInfo.Setup(fi => fi.PhysicalPath).Returns(Constants.FOLDER_ValidFolderPath);
_folderInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID);
_folderInfo.Setup(fi => fi.WorkflowID).Returns(Null.NullInteger);
var fileContent = new MemoryStream(Encoding.ASCII.GetBytes("some data here"));
_portalController.Setup(pc => pc.HasSpaceAvailable(It.IsAny<int>(), It.IsAny<long>())).Returns(true);
_globals.Setup(g => g.GetSubFolderPath(Constants.FOLDER_ValidFilePath, Constants.CONTENT_ValidPortalId)).Returns(Constants.FOLDER_ValidFolderRelativePath);
var folderMapping = new FolderMappingInfo { FolderProviderType = Constants.FOLDER_ValidFolderProviderType };
_folderMappingController.Setup(fmc => fmc.GetFolderMapping(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidFolderMappingID)).Returns(folderMapping);
_mockFolder.Setup(mf => mf.FileExists(_folderInfo.Object, Constants.FOLDER_ValidFileName)).Returns(false);
_mockFolder.Setup(mf => mf.AddFile(_folderInfo.Object, Constants.FOLDER_ValidFileName, fileContent)).Verifiable();
_mockFileManager.Setup(mfm => mfm.IsAllowedExtension(Constants.FOLDER_ValidFileName)).Returns(true);
_mockFileManager.Setup(mfm => mfm.CreateFileContentItem()).Returns(new ContentItem());
_contentWorkflowController.Setup(wc => wc.GetWorkflowByID(It.IsAny<int>())).Returns((ContentWorkflow)null);
//Act
_mockFileManager.Object.AddFile(_folderInfo.Object, Constants.FOLDER_ValidFileName, fileContent, true, false, Constants.CONTENTTYPE_ValidContentType);
//Assert
_portalController.Verify(pc => pc.HasSpaceAvailable(Constants.CONTENT_ValidPortalId, fileContent.Length));
}
示例14: GetSubFolders_Returns_Valid_SubFolders_When_Folder_Is_Not_Empty
public void GetSubFolders_Returns_Valid_SubFolders_When_Folder_Is_Not_Empty()
{
var expectedSubFolders = new[] {
Constants.FOLDER_ValidSubFolderRelativePath,
Constants.FOLDER_OtherValidSubFolderRelativePath
};
var folderMapping = new FolderMappingInfo { PortalID = Constants.CONTENT_ValidPortalId };
_pathUtils.Setup(pu => pu.GetPhysicalPath(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidFolderRelativePath)).Returns(Constants.FOLDER_ValidFolderPath);
_pathUtils.Setup(pu => pu.GetRelativePath(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidSubFolderPath)).Returns(Constants.FOLDER_ValidSubFolderRelativePath);
_pathUtils.Setup(pu => pu.GetRelativePath(Constants.CONTENT_ValidPortalId, Constants.FOLDER_OtherValidSubFolderPath)).Returns(Constants.FOLDER_OtherValidSubFolderRelativePath);
var subFolders = new[] {
Constants.FOLDER_ValidSubFolderPath,
Constants.FOLDER_OtherValidSubFolderPath
};
_directoryWrapper.Setup(dw => dw.GetDirectories(Constants.FOLDER_ValidFolderPath)).Returns(subFolders);
var result = _sfp.GetSubFolders(Constants.FOLDER_ValidFolderRelativePath, folderMapping).ToList();
CollectionAssert.AreEqual(expectedSubFolders, result);
}
示例15: GetSubFolders_Count_Equals_DirectoryWrapper_GetDirectories_Count
public void GetSubFolders_Count_Equals_DirectoryWrapper_GetDirectories_Count()
{
var folderMapping = new FolderMappingInfo { PortalID = Constants.CONTENT_ValidPortalId };
_pathUtils.Setup(pu => pu.GetPhysicalPath(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidFolderRelativePath)).Returns(Constants.FOLDER_ValidFolderPath);
_pathUtils.Setup(pu => pu.GetRelativePath(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidSubFolderPath)).Returns(Constants.FOLDER_ValidSubFolderRelativePath);
_pathUtils.Setup(pu => pu.GetRelativePath(Constants.CONTENT_ValidPortalId, Constants.FOLDER_OtherValidSubFolderPath)).Returns(Constants.FOLDER_OtherValidSubFolderRelativePath);
var subFolders = new[] {
Constants.FOLDER_ValidSubFolderPath,
Constants.FOLDER_OtherValidSubFolderPath
};
_directoryWrapper.Setup(dw => dw.GetDirectories(Constants.FOLDER_ValidFolderPath)).Returns(subFolders);
var result = _sfp.GetSubFolders(Constants.FOLDER_ValidFolderRelativePath, folderMapping).ToList();
Assert.AreEqual(subFolders.Length, result.Count);
}