本文整理汇总了C#中FileSet类的典型用法代码示例。如果您正苦于以下问题:C# FileSet类的具体用法?C# FileSet怎么用?C# FileSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileSet类属于命名空间,在下文中一共展示了FileSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateMatchingFiles
public void PopulateMatchingFiles()
{
const string filePattern = "*.txt";
var fileSet = new FileSet(TargetDirectory, _imageProviderFactory, filePattern);
var expected = TargetDirectory.GetFiles(filePattern).Select(f => new FileNode(f, fileSet, BrowserResources.Properties.Resources.Image_File, _imageProviderFactory));
CollectionAssert.AreEquivalent(expected, fileSet);
}
示例2: FileNode
public FileNode(FileInfo file, FileSet parent, Image defaultImage, IImageProviderFactory factory)
{
_factory = factory;
Done = false;
File = file;
ParentNode = parent;
Image = defaultImage;
}
示例3: ShouldAddMultipleFiles
public void ShouldAddMultipleFiles()
{
var fileset = new FileSet();
fileset.Add(new List<File>
{
new File(@"M:\Shows\Lost\101.avi"),
new File(@"M:\Shows\Lost\102.avi"),
});
Assert.NotNull(fileset.Files.SingleOrDefault(f => f.Path == @"M:\Shows\Lost\101.avi"));
Assert.NotNull(fileset.Files.SingleOrDefault(f => f.Path == @"M:\Shows\Lost\102.avi"));
}
示例4: FileSetTester
public FileSetTester()
{
_testDirectory = new TestDirectory();
_testDirectory.ChangeDirectory();
if (Directory.Exists("target"))
{
Directory.Delete("target", true);
}
Directory.CreateDirectory("target");
theFileSet = new FileSet();
}
示例5: ShouldNotAddIgnoredFiles
public void ShouldNotAddIgnoredFiles()
{
var fileset = new FileSet();
fileset.Add(new List<File>
{
new File(@"M:\Shows\Lost\lost.nfo"),
new File(@"M:\Shows\Lost\101.avi"),
new File(@"M:\Shows\Lost\cast.jpeg"),
});
Assert.AreEqual(1, fileset.Files.Count());
Assert.NotNull(fileset.Files.SingleOrDefault(f => f.Path == @"M:\Shows\Lost\101.avi"));
}
示例6: ShouldFindFileWhenProvidingFullPath
public void ShouldFindFileWhenProvidingFullPath()
{
var fileset = new FileSet();
fileset.Add(new List<File>
{
new File(@"M:\Shows\Lost\101.avi"),
new File(@"M:\Shows\Lost\102.avi"),
});
var matches = fileset.Find(@"M:\Shows\Lost\101.avi");
Assert.AreEqual(1, matches.Count());
Assert.NotNull(matches.SingleOrDefault(f => f.Path == @"M:\Shows\Lost\101.avi"));
}
示例7: ShouldFindAllFilesThatMatchStars
public void ShouldFindAllFilesThatMatchStars()
{
var fileset = new FileSet();
fileset.Add(new List<File>
{
new File(@"M:\Shows\Lost\101.avi"),
new File(@"M:\Shows\Lost\102.avi"),
new File(@"M:\Shows\Dexter\121.avi"),
});
var matches = fileset.Find(@"1*1");
Assert.AreEqual(2, matches.Count());
Assert.NotNull(matches.SingleOrDefault(f => f.Path == @"M:\Shows\Lost\101.avi"));
Assert.NotNull(matches.SingleOrDefault(f => f.Path == @"M:\Shows\Dexter\121.avi"));
}
示例8: Scan
private void Scan(string root, string directory, FileSet fileSet, Action<FileFound> onFound, IEnumerable<string> excludes)
{
if (AlreadyScannedOrNonexistent(directory)) { return; }
scannedDirectories.Add(directory);
fileSystem.ChildDirectoriesFor(directory)
.ForEach(dir => Scan(root, dir, fileSet, onFound, excludes));
var included = fileSet.IncludedFilesFor(directory).ToList();
var excluded = included.Where(x => excludes.Any(x.Contains));
var files = included.Except(excluded).ToList();
files.ForEach(file => onFound(new FileFound(file, root, directory)));
}
示例9: find_does_not_wig_out_when_the_exclude_pattern_is_an_invalid_directory
public void find_does_not_wig_out_when_the_exclude_pattern_is_an_invalid_directory()
{
writeFile("config/a.config");
writeFile("config/b.config");
writeFile("config/zeppelin.yaml");
writeFile("hitchhiker.config");
new FileSystem().DeleteDirectory("data");
theFileSet = new FileSet()
{
Include = "*.as*x;*.master;Content{0}*.*;*.config".ToFormat(Path.DirectorySeparatorChar),
Exclude = "data/*"
};
includedFiles().ShouldHaveTheSameElementsAs("a.config", "b.config", "hitchhiker.config");
}
示例10: Test_SharedMetadataReferencesWithAliases
public void Test_SharedMetadataReferencesWithAliases()
{
var projPath1 = @"CSharpProject\CSharpProject_ExternAlias.csproj";
var projPath2 = @"CSharpProject\CSharpProject_ExternAlias2.csproj";
var files = new FileSet(new Dictionary<string, object>
{
{ projPath1, GetResourceText("CSharpProject_CSharpProject_ExternAlias.csproj") },
{ projPath2, GetResourceText("CSharpProject_CSharpProject_ExternAlias2.csproj") },
{ @"CSharpProject\CSharpExternAlias.cs", GetResourceText("CSharpProject_CSharpExternAlias.cs") },
});
CreateFiles(files);
var fullPath1 = Path.Combine(this.SolutionDirectory.Path, projPath1);
var fullPath2 = Path.Combine(this.SolutionDirectory.Path, projPath2);
using (var ws = MSBuildWorkspace.Create())
{
var proj1 = ws.OpenProjectAsync(fullPath1).Result;
var proj2 = ws.OpenProjectAsync(fullPath2).Result;
var p1Sys1 = GetMetadataReferenceByAlias(proj1, "Sys1");
var p1Sys2 = GetMetadataReferenceByAlias(proj1, "Sys2");
var p2Sys1 = GetMetadataReferenceByAlias(proj2, "Sys1");
var p2Sys3 = GetMetadataReferenceByAlias(proj2, "Sys3");
Assert.NotNull(p1Sys1);
Assert.NotNull(p1Sys2);
Assert.NotNull(p2Sys1);
Assert.NotNull(p2Sys3);
// same filepath but different alias so they are not the same instance
Assert.NotSame(p1Sys1, p1Sys2);
Assert.NotSame(p2Sys1, p2Sys3);
// same filepath and alias so they are the same instance
Assert.Same(p1Sys1, p2Sys1);
var mdp1Sys1 = GetMetadata(p1Sys1);
var mdp1Sys2 = GetMetadata(p1Sys2);
var mdp2Sys1 = GetMetadata(p2Sys1);
var mdp2Sys3 = GetMetadata(p2Sys1);
Assert.NotNull(mdp1Sys1);
Assert.NotNull(mdp1Sys2);
Assert.NotNull(mdp2Sys1);
Assert.NotNull(mdp2Sys3);
// all references to System.dll share the same metadata bytes
Assert.Same(mdp1Sys1.Id, mdp1Sys2.Id);
Assert.Same(mdp1Sys1.Id, mdp2Sys1.Id);
Assert.Same(mdp1Sys1.Id, mdp2Sys3.Id);
}
}
示例11: GetFileListFromFileSet
public static List<string> GetFileListFromFileSet(FileSet fileSet)
{
List<string> files = new List<string>();
foreach (FileItem file in fileSet.FileItems)
{
files.Add(file.FileName);
}
return files;
}
示例12: MSBuildProjectShouldHandleCodePageProperty
public void MSBuildProjectShouldHandleCodePageProperty()
{
var files = new FileSet(new Dictionary<string, object>
{
{ "Encoding.csproj", GetResourceText("Encoding.csproj").Replace("<CodePage>ReplaceMe</CodePage>", "<CodePage>1254</CodePage>") },
{ "class1.cs", "//\u201C" }
});
CreateFiles(files);
var projPath = Path.Combine(this.SolutionDirectory.Path, "Encoding.csproj");
var project = MSBuildWorkspace.Create().OpenProjectAsync(projPath).Result;
var text = project.Documents.First(d => d.Name == "class1.cs").GetTextAsync().Result;
Assert.Equal(Encoding.GetEncoding(1254), text.Encoding);
// The smart quote (“) in class1.cs shows up as "“" in codepage 1254. Do a sanity
// check here to make sure this file hasn't been corrupted in a way that would
// impact subsequent asserts.
Assert.Equal("//\u00E2\u20AC\u0153".Length, 5);
Assert.Equal("//\u00E2\u20AC\u0153".Length, text.Length);
}
示例13: TestOpenSolution_SolutionFileHasMissingEndProject
public void TestOpenSolution_SolutionFileHasMissingEndProject()
{
var files = new FileSet(new Dictionary<string, object>
{
{ @"TestSolution1.sln", GetResourceText("TestSolution_MissingEndProject1.sln") },
{ @"TestSolution2.sln", GetResourceText("TestSolution_MissingEndProject2.sln") },
{ @"TestSolution3.sln", GetResourceText("TestSolution_MissingEndProject3.sln") }
});
CreateFiles(files);
var solution1 = MSBuildWorkspace.Create().OpenSolutionAsync(GetSolutionFileName("TestSolution1.sln")).Result;
var solution2 = MSBuildWorkspace.Create().OpenSolutionAsync(GetSolutionFileName("TestSolution2.sln")).Result;
var solution3 = MSBuildWorkspace.Create().OpenSolutionAsync(GetSolutionFileName("TestSolution3.sln")).Result;
}
示例14: TestOpenSolution_SolutionFileHasEmptyLinesAndWhitespaceOnlyLines
public void TestOpenSolution_SolutionFileHasEmptyLinesAndWhitespaceOnlyLines()
{
var files = new FileSet(new Dictionary<string, object>
{
{ @"TestSolution.sln", GetResourceText("TestSolution_CSharp_EmptyLines.sln") },
{ @"CSharpProject\CSharpProject.csproj", GetResourceText("CSharpProject_CSharpProject.csproj") },
{ @"CSharpProject\CSharpClass.cs", GetResourceText("CSharpProject_CSharpClass.cs") },
{ @"CSharpProject\Properties\AssemblyInfo.cs", GetResourceText("CSharpProject_AssemblyInfo.cs") }
});
CreateFiles(files);
var solution = MSBuildWorkspace.Create().OpenSolutionAsync(GetSolutionFileName("TestSolution.sln")).Result;
var project = solution.Projects.First();
}
示例15: AssertFileSetFilesAndDirectories
private FileSet AssertFileSetFilesAndDirectories(string baseDir, ArrayList includes, ArrayList excludes,
ArrayList expectedFiles, ArrayList expectedDirectories)
{
excludes.Add("**/.svn/**");
expectedFiles = PrepareExpected(expectedFiles);
expectedDirectories = PrepareExpected(expectedDirectories);
FileSet fs = new FileSet(baseDir);
fs.Includes = includes;
fs.Excludes = excludes;
fs.Load();
Compare(expectedFiles, fs.Files);
Compare(expectedDirectories, fs.Directories);
return fs;
}