当前位置: 首页>>代码示例>>C#>>正文


C# IDirectory.EnumerateDirectories方法代码示例

本文整理汇总了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);
			}
		}
开发者ID:artikh,项目名称:CouchDude.SchemeManager,代码行数:29,代码来源:DesignDocumentAssembler.cs

示例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);
			}
		}
开发者ID:artikh,项目名称:CouchDude.SchemeManager,代码行数:10,代码来源:DesignDocumentAssembler.cs

示例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);
     }
 }
开发者ID:modulexcite,项目名称:Batman,代码行数:36,代码来源:AssetManager.cs

示例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));
		}
开发者ID:artikh,项目名称:CouchDude.SchemeManager,代码行数:17,代码来源:DesignDocumentAssembler.cs


注:本文中的IDirectory.EnumerateDirectories方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。