本文整理汇总了C#中IDirectory.GetDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# IDirectory.GetDirectory方法的具体用法?C# IDirectory.GetDirectory怎么用?C# IDirectory.GetDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectory
的用法示例。
在下文中一共展示了IDirectory.GetDirectory方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContentLocator
//todo: Link content to a content cache similar to openwraps package cache. Use same mechanism?
public ContentLocator()
{
var environment = ServiceLocator.GetService<IEnvironment>();
var packageManager = ServiceLocator.GetService<IPackageManager>();
var baseDirectory = LocalFileSystem.Instance.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory);
contentRoot = baseDirectory.GetDirectory("Content");
contentRoot.MustExist();
foreach (var scopedDescriptor in environment.ScopedDescriptors)
{
var files = packageManager.GetProjectExports<ContentFolderExport>(scopedDescriptor.Value.Value,
environment.ProjectRepository,
environment.ExecutionEnvironment);
contentPathSources = files.SelectMany(x => x).Distinct().Select(x => x.Directory).ToList();
foreach (
var pathSource in
contentPathSources.SelectMany(contentPathSource => contentPathSource.Directories()))
{
pathSource.LinkTo(contentRoot.GetDirectory(pathSource.Name).MustExist().Path.FullPath);
}
}
}
示例2: msbuild_emitter
public msbuild_emitter()
{
_fileSystem = new InMemoryFileSystem();
_emitter = new MSBuildInstructionEmitter(_fileSystem);
RootDirectory = _fileSystem.CreateTempDirectory();
_emitter.RootPath = RootDirectory.Path;
ProjectDirectory = RootDirectory.GetDirectory("src").GetDirectory("Project");
ProjectFile = ProjectDirectory.GetFile("Project.csproj");
BinDirectory
= _fileSystem.CreateTempDirectory();
GacDirectory = _fileSystem.CreateTempDirectory();
TempDirectory = _fileSystem.CreateTempDirectory();
BinPath = new OpenFileSystem.IO.Path(System.IO.Path.Combine(_emitter.RootPath, "bin"));
}
示例3: FolderRepository
public FolderRepository(IDirectory packageBasePath, bool anchorsEnabled)
{
if (packageBasePath == null) throw new ArgumentNullException("packageBasePath");
BasePath = packageBasePath;
_anchorsEnabled = anchorsEnabled;
_rootCacheDirectory = BasePath.GetOrCreateDirectory("_cache");
Packages = (from wrapFile in BasePath.Files("*.wrap")
let packageFullName = wrapFile.NameWithoutExtension
let packageVersion = WrapNameUtility.GetVersion(packageFullName)
where packageVersion != null
let cacheDirectory = _rootCacheDirectory.GetDirectory(packageFullName)
select cacheDirectory.Exists
? (IPackageInfo)new UncompressedPackage(this, wrapFile, cacheDirectory, ExportBuilders.All, _anchorsEnabled)
: (IPackageInfo)new ZipPackage(this, wrapFile, cacheDirectory, ExportBuilders.All, _anchorsEnabled)).ToList();
}
示例4: DirectoryEqual
public static void DirectoryEqual(IDirectory expected, IDirectory actual)
{
Assert.Equal(expected.Path, actual.Path);
Assert.Equal(expected.Name, actual.Name);
Assert.Equal(expected.Directories.Count(), actual.Directories.Count());
Assert.Equal(expected.Files.Count(), actual.Files.Count());
foreach (var directory in expected.Directories)
{
Assert.True(actual.DirectoryExists(directory.Name));
DirectoryEqual(directory, actual.GetDirectory(directory.Name));
}
foreach (var file in expected.Files)
{
Assert.True(actual.FileExists(file.Name));
FileEqual(file, actual.GetFile(file.Name));
}
}
示例5: Anchor
public override bool? Anchor(IDirectory packagesDirectory, IDirectory packageDirectory, string anchorName)
{
var anchoredDirectory = packagesDirectory.GetDirectory(anchorName);
if (anchoredDirectory.Exists && anchoredDirectory.IsHardLink && !SafeDelete(anchoredDirectory))
return false;
anchoredDirectory = packagesDirectory.GetDirectory(anchorName);
if (anchoredDirectory.Exists)
{
var anchorFile = anchoredDirectory.GetFile(".anchored");
if (anchorFile.Exists && anchorFile.ReadString() == packageDirectory.Name) return null;
if (!SafeDelete(anchoredDirectory)) return false;
}
packageDirectory.CopyTo(anchoredDirectory);
anchoredDirectory.GetFile(".anchored").WriteString(packageDirectory.Name);
return true;
}
示例6: CopyOpenWrap
IEnumerable<ICommandOutput> CopyOpenWrap(PackageDescriptor projectDescriptor, IDirectory projectDirectory)
{
var packageManager = ServiceLocator.GetService<IPackageManager>();
var repositoryOptions = FolderRepositoryOptions.AnchoringEnabled;
if (projectDescriptor.UseSymLinks)
repositoryOptions |= FolderRepositoryOptions.UseSymLinks;
if (projectDescriptor.StorePackages)
repositoryOptions |= FolderRepositoryOptions.PersistPackages;
var projectRepository = new FolderRepository(projectDirectory.GetDirectory("wraps"), repositoryOptions)
{
Name = "Project repository"
};
packageManager.AddProjectPackage(PackageRequest.Any("openwrap"),
new[] { Environment.SystemRepository },
projectDescriptor,
projectRepository,
PackageAddOptions.Default | PackageAddOptions.Anchor | PackageAddOptions.Content).ToList();
yield return new Info("Project repository initialized.");
}
示例7: AddIgnores
void AddIgnores(IDirectory projectDirectory)
{
if (IgnoreFileName == null) return;
if (Hg)
{
// mercurial is a bit special when it comes to ignores
projectDirectory.GetFile(IgnoreFileName).WriteString("syntax: glob\r\nwraps/_cache");
}
else
{
projectDirectory.GetDirectory("wraps").GetFile(IgnoreFileName).WriteString("_cache\r\n_cache\\*");
}
}
示例8: AddPackageFolders
static void AddPackageFolders(IDirectory projectDirectory)
{
projectDirectory.GetDirectory("src").MustExist();
projectDirectory.GetDirectory("wraps").GetDirectory("_cache").MustExist();
}
示例9: CopyOpenWrap
IEnumerable<ICommandOutput> CopyOpenWrap(IDirectory projectDirectory)
{
var packageManager = Services.Services.GetService<IPackageResolver>();
var initialDescriptor = new PackageDescriptor
{
Name = "openwrap",
Dependencies =
{
new PackageDependency
{
Name = "OpenWrap",
VersionVertices = { new AnyVersionVertex() }
}
}
};
DependencyResolutionResult openwrapPackage = packageManager.TryResolveDependencies(initialDescriptor, new[] { Environment.SystemRepository });
var folderRepository = new FolderRepository(projectDirectory.GetDirectory("wraps"))
{
EnableAnchoring = true,
Name = "Project repository"
};
foreach (ICommandOutput msg in packageManager.CopyPackagesToRepositories(
openwrapPackage,
Environment.SystemRepository,
folderRepository))
yield return msg;
folderRepository.Refresh();
folderRepository.VerifyAnchors(new[] { folderRepository.PackagesByName["openwrap"].First() });
}
示例10: AddIgnores
void AddIgnores(IDirectory projectDirectory)
{
if (IgnoreFileName == null) return;
projectDirectory.GetDirectory("wraps").GetFile(IgnoreFileName).WriteString("_cache\r\n_cache\\*");
}
示例11: CopyOpenWrap
IEnumerable<ICommandOutput> CopyOpenWrap(PackageDescriptor projectDescriptor, IDirectory projectDirectory)
{
var packageManager = Services.Services.GetService<IPackageManager>();
var projectRepository = new FolderRepository(projectDirectory.GetDirectory("wraps"))
{
EnableAnchoring = true,
Name = "Project repository"
};
packageManager.AddProjectPackage(PackageRequest.Any("openwrap"),
new[] { Environment.SystemRepository },
projectDescriptor,
projectRepository,
PackageAddOptions.Default | PackageAddOptions.Anchor | PackageAddOptions.Content).ToList();
yield return new GenericMessage("Project repository initialized.");
}
示例12: CopyOpenWrap
IEnumerable<ICommandOutput> CopyOpenWrap(IDirectory projectDirectory)
{
var packageManager = Services.Services.GetService<IPackageManager>();
var openwrapPackage = packageManager.TryResolveDependencies(new PackageDescriptor { Name = "openwrap" }, new[] { Environment.SystemRepository });
foreach(var msg in packageManager.CopyPackagesToRepositories(openwrapPackage, new FolderRepository(projectDirectory.GetDirectory("wraps"))))
yield return msg;
}
示例13: AddPackageFolders
void AddPackageFolders(IDirectory projectDirectory, List<IFileSystemItem> items)
{
items.AddRange(new IFileSystemItem[]
{
projectDirectory.GetDirectory("src"),
projectDirectory.GetDirectory("wraps")
});
}
示例14: Scaffold
public void Scaffold(IDirectory directory)
{
// Add info page
IFile aboutFile = directory.GetFile("about.md");
aboutFile.WriteAllText(@"Title: About Me
---
I'm awesome!");
// Add post page
IDirectory postsDirectory = directory.GetDirectory("posts");
IFile postFile = postsDirectory.GetFile("first-post.md");
postFile.WriteAllText(@"Title: First Post
Published: 1/1/2016
Tags: Introduction
---
This is my first post!");
}