本文整理汇总了C#中IDirectory.EnumerateDirectories方法的典型用法代码示例。如果您正苦于以下问题:C# IDirectory.EnumerateDirectories方法的具体用法?C# IDirectory.EnumerateDirectories怎么用?C# IDirectory.EnumerateDirectories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectory
的用法示例。
在下文中一共展示了IDirectory.EnumerateDirectories方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapPropertiesRecursive
private static void MapPropertiesRecursive(JsonObject jObject, IDirectory directory)
{
foreach (var file in directory.EnumerateFiles())
{
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.Name);
if (fileNameWithoutExtension == null || fileNameWithoutExtension == IdPropertyName)
continue;
if (ReservedPropertyNames.Contains(fileNameWithoutExtension))
throw new DesignDocumentAssemblerException("File name {0} is reserved.", file);
if (jObject.ContainsKey(fileNameWithoutExtension))
throw CreateClashingFilesException(directory, fileNameWithoutExtension);
jObject[fileNameWithoutExtension] = ReadFile(file);
}
foreach (var subDirectory in directory.EnumerateDirectories())
{
var subDirectoryName = subDirectory.Name;
if (ReservedPropertyNames.Contains(subDirectoryName))
throw new DesignDocumentAssemblerException("Directory name {0} is reserved.", subDirectoryName);
if (jObject.ContainsKey(subDirectoryName))
throw CreateClashingFilesException(directory, subDirectoryName);
var subObject = new JsonObject();
jObject[subDirectoryName] = subObject;
MapPropertiesRecursive(subObject, subDirectory);
}
}
示例2: GenerateInternal
private static IEnumerable<DesignDocument> GenerateInternal(IDirectory directory)
{
foreach (var subDirectory in directory.EnumerateDirectories())
{
var id = GetId(subDirectory);
var designDocument = new JsonObject(new KeyValuePair<string, JsonValue>(IdPropertyName, id));
MapPropertiesRecursive(designDocument, subDirectory);
yield return new DesignDocument(designDocument);
}
}
示例3: CreateBundles
/// <summary>
/// Auto creates the bundles for the given directory
/// </summary>
/// <param name="Directory">Directory to create bundles from</param>
private void CreateBundles(IDirectory Directory)
{
if (!Directory.Exists)
return;
string BundleDirectory = Directory.FullName.Replace(FileManager.Directory("~/").FullName, "~/").Replace("\\", "/");
StyleBundle Bundle = new StyleBundle(BundleDirectory + "/bundle/css");
Bundle.Transforms.Clear();
Bundle.Transforms.Add(new Transformer());
if (Directory.Exists)
{
foreach (string Value in FileTypes[AssetType.CSS])
{
Bundle.IncludeDirectory(BundleDirectory, "*." + Value, true);
}
}
ScriptBundle Bundle2 = new ScriptBundle(BundleDirectory + "/bundle/js");
Bundle2.Transforms.Clear();
Bundle2.Transforms.Add(new Transformer());
if (Directory.Exists)
{
foreach (string Value in FileTypes[AssetType.Javascript])
{
Bundle2.IncludeDirectory(BundleDirectory, "*." + Value, true);
}
}
BundleTable.Bundles.Add(Bundle);
BundleTable.Bundles.Add(Bundle2);
foreach (IDirectory SubDirectory in Directory.EnumerateDirectories("*", SearchOption.TopDirectoryOnly))
{
CreateBundles(SubDirectory);
}
}
示例4: CreateClashingFilesException
CreateClashingFilesException(IDirectory directory, string clashingName)
{
var clushingFileNames = directory
.EnumerateFiles()
.Where(f => Path.GetFileNameWithoutExtension(f.Name) == clashingName)
.Select(f => f.Name);
var clushingSubDirectoryNames = directory
.EnumerateDirectories()
.Where(d => d.Name == clashingName)
.Select(d => d.Name);
var clashingDirectoriesAndFiles =
clushingFileNames.Union(clushingSubDirectoryNames).ToArray();
return new DesignDocumentAssemblerException(
"Files and subdirectories with same name and different extensions detected: {0}",
string.Join(", ", clashingDirectoriesAndFiles));
}