本文整理汇总了C#中IDirectory.Files方法的典型用法代码示例。如果您正苦于以下问题:C# IDirectory.Files方法的具体用法?C# IDirectory.Files怎么用?C# IDirectory.Files使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectory
的用法示例。
在下文中一共展示了IDirectory.Files方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UncompressedPackage
public UncompressedPackage(IPackageRepository source,
IFile originalPackageFile,
IDirectory wrapCacheDirectory)
{
Check.NotNull(source, "source");
if (originalPackageFile == null || originalPackageFile.Exists == false)
{
IsValid = false;
return;
}
_originalPackageFile = originalPackageFile;
BaseDirectory = wrapCacheDirectory;
// get the descriptor file inside the package
Source = source;
var wrapDescriptor = wrapCacheDirectory.Files("*.wrapdesc").SingleOrDefault();
if (wrapDescriptor == null)
{
IsValid = false;
return;
}
var versionFile = wrapCacheDirectory.GetFile("version");
_descriptor = new PackageDescriptorReader().Read(wrapDescriptor);
_semver = _descriptor.SemanticVersion ?? _descriptor.Version.ToSemVer();
if (_semver == null)
_semver = versionFile.Exists ? versionFile.ReadString().ToSemVer() : null;
IsValid = string.IsNullOrEmpty(Name) == false && _semver != null;
if (IsValid)
Identifier = new PackageIdentifier(Name, _semver);
}
示例2: UncompressedPackage
public UncompressedPackage(IPackageRepository source,
IFile originalPackageFile,
IDirectory wrapCacheDirectory)
{
Check.NotNull(source, "source");
if (originalPackageFile == null || originalPackageFile.Exists == false)
{
IsValid = false;
return;
}
_originalPackageFile = originalPackageFile;
BaseDirectory = wrapCacheDirectory;
// get the descriptor file inside the package
Source = source;
var wrapDescriptor = wrapCacheDirectory.Files("*.wrapdesc").SingleOrDefault();
if (wrapDescriptor == null)
{
IsValid = false;
return;
}
var versionFile = wrapCacheDirectory.GetFile("version");
_descriptor = new PackageDescriptorReaderWriter().Read(wrapDescriptor);
PackageInfo = new DefaultPackageInfo(originalPackageFile.Name,
versionFile.Exists ? versionFile.Read(x => x.ReadString().ToVersion()) : null,
_descriptor);
Identifier = new PackageIdentifier(Name, Version);
IsValid = true;
}
示例3: GetFileSpecCore
private static IEnumerable<IFile> GetFileSpecCore(IDirectory directory, IList<string> segments, int position)
{
var segment = segments[position];
if (position == segments.Count - 1)
{
return directory.Files(segment);
}
if (segment == Subfolder)
{
var isNextToLastSegment = position + 1 == segments.Count - 1;
return isNextToLastSegment
? directory.Files(segments[position + 1], SearchScope.SubFolders)
: directory.Directories(segments[position + 1], SearchScope.SubFolders)
.SelectMany(x => GetFileSpecCore(x, segments, position + 2));
}
return directory.Directories(segment, SearchScope.CurrentOnly)
.SelectMany(x => GetFileSpecCore(x, segments, position + 1));
}
示例4: 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();
}
示例5: UncompressedPackage
public UncompressedPackage(IPackageRepository source,
IFile originalPackage,
IDirectory wrapCacheDirectory,
IEnumerable<IExportBuilder> exporters)
{
_originalWrapFile = originalPackage;
_exporters = exporters;
BaseDirectory = wrapCacheDirectory;
// get the descriptor file inside the package
var descriptorName = originalPackage.NameWithoutExtension;
Source = source;
var wrapDescriptor = wrapCacheDirectory.Files("*.wrapdesc").SingleOrDefault();
if (wrapDescriptor == null)
throw new InvalidOperationException("Could not find descriptor in wrap cache directory, or there are multiple .wrapdesc files in the package.");
var versionFile = wrapCacheDirectory.GetFile("version");
Descriptor = new DefaultPackageInfo(originalPackage.Name, versionFile.Exists ? versionFile.Read(x=>x.ReadString().ToVersion()) : null, new PackageDescriptorReaderWriter().Read(wrapDescriptor));
}
示例6: FolderNotEmptyAndMissingWraplist
static bool FolderNotEmptyAndMissingWraplist(Uri fileUri, IDirectory directory, IFile wrapList)
{
return fileUri.Scheme == "file" && wrapList.Exists == false && directory.Files().Where(_ => _.Name != "index.wraplist").Any();
}