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


C# String.SelectMany方法代码示例

本文整理汇总了C#中String.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# String.SelectMany方法的具体用法?C# String.SelectMany怎么用?C# String.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在String的用法示例。


在下文中一共展示了String.SelectMany方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDirectories

 /// <summary>
 ///     Returns an enumerable collection of directory names that match a search pattern in a specified @this.
 /// </summary>
 /// <param name="this">The directory to search.</param>
 /// <param name="searchPatterns">The search string to match against the names of directories in.</param>
 /// <returns>
 ///     An enumerable collection of the full names (including paths) for the directories in the directory specified by
 ///     <paramref
 ///         name="this" />
 ///     and that match the specified search pattern.
 /// </returns>
 /// ###
 /// <param name="searchPattern">
 ///     The search string to match against the names of directories in
 ///     <paramref name="this" />.
 /// </param>
 /// ###
 /// <exception cref="T:System.ArgumentException">
 ///     <paramref name="this " />is a zero-length string, contains only
 ///     white space, or contains invalid characters as defined by
 ///     <see
 ///         cref="M:System.IO.Path.GetInvalidPathChars" />
 ///     .- or -<paramref name="searchPattern" /> does not contain a valid pattern.
 /// </exception>
 /// ###
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="this" /> is null.-or-
 ///     <paramref name="searchPattern" /> is null.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.DirectoryNotFoundException">
 ///     <paramref name="this" /> is invalid, such as
 ///     referring to an unmapped drive.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.IOException">
 ///     <paramref name="this" /> is a file name.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.PathTooLongException">
 ///     The specified @this, file name, or combined exceed the
 ///     system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters
 ///     and file names must be less than 260 characters.
 /// </exception>
 /// ###
 /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// ###
 /// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
 public static DirectoryInfo[] GetDirectories(this DirectoryInfo @this, String[] searchPatterns)
 {
     return searchPatterns.SelectMany(x => @this.GetDirectories(x)).Distinct().ToArray();
 }
开发者ID:fqybzhangji,项目名称:Z.ExtensionMethods,代码行数:52,代码来源:DirectoryInfo.GetDirectories.cs

示例2: EnumerateFileSystemEntries


//.........这里部分代码省略.........
    ///               {
    ///                   // Type
    ///                   var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_EnumerateFileSystemEntries&quot;));
    ///                   Directory.CreateDirectory(root.FullName);
    /// 
    ///                   var file1 = new FileInfo(Path.Combine(root.FullName, &quot;test1.txt&quot;));
    ///                   file1.Create();
    ///                   root.CreateSubdirectory(&quot;test2&quot;);
    /// 
    ///                   // Exemples
    ///                   List&lt;string&gt; result = root.EnumerateFileSystemEntries().ToList();
    /// 
    ///                   // Unit Test
    ///                   Assert.AreEqual(2, result.Count);
    ///               }
    ///           }
    ///       }
    /// </code>
    /// </example>
    /// ###
    /// <param name="searchPattern">
    ///     The search string to match against the names of directories in
    ///     <paramref name="this" />.
    /// </param>
    /// ###
    /// <exception cref="T:System.ArgumentException">
    ///     <paramref name="this " />is a zero-length string, contains only
    ///     white space, or contains invalid characters as defined by
    ///     <see
    ///         cref="M:System.IO.Path.GetInvalidPathChars" />
    ///     .- or -<paramref name="searchPattern" /> does not contain a valid pattern.
    /// </exception>
    /// ###
    /// <exception cref="T:System.ArgumentNullException">
    ///     <paramref name="this" /> is null.-or-
    ///     <paramref name="searchPattern" /> is null.
    /// </exception>
    /// ###
    /// <exception cref="T:System.IO.DirectoryNotFoundException">
    ///     <paramref name="this" /> is invalid, such as
    ///     referring to an unmapped drive.
    /// </exception>
    /// ###
    /// <exception cref="T:System.IO.IOException">
    ///     <paramref name="this" /> is a file name.
    /// </exception>
    /// ###
    /// <exception cref="T:System.IO.PathTooLongException">
    ///     The specified @this, file name, or combined exceed the
    ///     system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters
    ///     and file names must be less than 260 characters.
    /// </exception>
    /// ###
    /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
    /// ###
    /// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
    /// <example>
    ///     <code>
    ///           using System;
    ///           using System.Collections.Generic;
    ///           using System.IO;
    ///           using System.Linq;
    ///           using Microsoft.VisualStudio.TestTools.UnitTesting;
    ///           using Z.ExtensionMethods;
    ///           
    ///           namespace ExtensionMethods.Examples
    ///           {
    ///               [TestClass]
    ///               public class System_IO_DirectoryInfo_EnumerateFileSystemEntries
    ///               {
    ///                   [TestMethod]
    ///                   public void EnumerateFileSystemEntries()
    ///                   {
    ///                       // Type
    ///                       var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_EnumerateFileSystemEntries&quot;));
    ///                       Directory.CreateDirectory(root.FullName);
    ///           
    ///                       var file1 = new FileInfo(Path.Combine(root.FullName, &quot;test1.txt&quot;));
    ///                       file1.Create();
    ///                       root.CreateSubdirectory(&quot;test2&quot;);
    ///           
    ///                       // Exemples
    ///                       List&lt;string&gt; result = root.EnumerateFileSystemEntries().ToList();
    ///           
    ///                       // Unit Test
    ///                       Assert.AreEqual(2, result.Count);
    ///                   }
    ///               }
    ///           }
    ///     </code>
    /// </example>
    public static IEnumerable<string> EnumerateFileSystemEntries(this DirectoryInfo @this, String[] searchPatterns)
    {
#if (NET35 || NET3 || NET2)
        return searchPatterns.SelectMany(x => Directory.GetFileSystemEntries(@this.FullName, x)).Distinct();
#else
        return searchPatterns.SelectMany(x => Directory.EnumerateFileSystemEntries(@this.FullName, x)).Distinct();
#endif

    }
开发者ID:Nucs,项目名称:nlib,代码行数:101,代码来源:DirectoryInfo.EnumerateFileSystemEntries.cs

示例3: EnumerateFiles


//.........这里部分代码省略.........
 ///           public class System_IO_DirectoryInfo_EnumerateFiles
 ///           {
 ///               [TestMethod]
 ///               public void EnumerateFiles()
 ///               {
 ///                   // Type
 ///                   var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_EnumerateFiles&quot;));
 ///                   Directory.CreateDirectory(root.FullName);
 /// 
 ///                   var file1 = new FileInfo(Path.Combine(root.FullName, &quot;test1.txt&quot;));
 ///                   var file2 = new FileInfo(Path.Combine(root.FullName, &quot;test2.txt&quot;));
 ///                   file1.Create();
 ///                   file2.Create();
 /// 
 ///                   // Exemples
 ///                   List&lt;FileInfo&gt; result = root.EnumerateFiles().ToList();
 /// 
 ///                   // Unit Test
 ///                   Assert.AreEqual(2, result.Count);
 ///               }
 ///           }
 ///       }
 /// </code>
 /// </example>
 /// ###
 /// <exception cref="T:System.ArgumentException">
 ///     <paramref name="this " />is a zero-length string, contains only
 ///     white space, or contains invalid characters as defined by
 ///     <see
 ///         cref="M:System.IO.Path.GetInvalidPathChars" />
 ///     .- or -<paramref name="searchPattern" /> does not contain a valid pattern.
 /// </exception>
 /// ###
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="this" /> is null.-or-
 ///     <paramref name="searchPattern" /> is null.
 /// </exception>
 /// ###
 /// <exception cref="T:System.ArgumentOutOfRangeException">
 ///     <paramref name="searchOption" /> is not a valid
 ///     <see cref="T:System.IO.SearchOption" /> value.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.DirectoryNotFoundException">
 ///     <paramref name="this" /> is invalid, such as
 ///     referring to an unmapped drive.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.IOException">
 ///     <paramref name="this" /> is a file name.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.PathTooLongException">
 ///     The specified @this, file name, or combined exceed the
 ///     system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters
 ///     and file names must be less than 260 characters.
 /// </exception>
 /// ###
 /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// ###
 /// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
 /// <example>
 ///     <code>
 ///           using System;
 ///           using System.Collections.Generic;
 ///           using System.IO;
 ///           using System.Linq;
 ///           using Microsoft.VisualStudio.TestTools.UnitTesting;
 ///           
 ///           namespace ExtensionMethods.Examples
 ///           {
 ///               [TestClass]
 ///               public class System_IO_DirectoryInfo_EnumerateFiles
 ///               {
 ///                   [TestMethod]
 ///                   public void EnumerateFiles()
 ///                   {
 ///                       // Type
 ///                       var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_EnumerateFiles&quot;));
 ///                       Directory.CreateDirectory(root.FullName);
 ///           
 ///                       var file1 = new FileInfo(Path.Combine(root.FullName, &quot;test1.txt&quot;));
 ///                       var file2 = new FileInfo(Path.Combine(root.FullName, &quot;test2.txt&quot;));
 ///                       file1.Create();
 ///                       file2.Create();
 ///           
 ///                       // Exemples
 ///                       List&lt;FileInfo&gt; result = root.EnumerateFiles().ToList();
 ///           
 ///                       // Unit Test
 ///                       Assert.AreEqual(2, result.Count);
 ///                   }
 ///               }
 ///           }
 ///     </code>
 /// </example>
 public static IEnumerable<FileInfo> EnumerateFiles(this DirectoryInfo @this, String[] searchPatterns, SearchOption searchOption)
 {
     return searchPatterns.SelectMany(x => @this.GetFiles(x, searchOption)).Distinct();
 }
开发者ID:Nucs,项目名称:nlib,代码行数:101,代码来源:DirectoryInfo.EnumerateFiles.cs

示例4: GetFilesWhere


//.........这里部分代码省略.........
 ///               public void GetFilesWhere()
 ///               {
 ///                   // Type
 ///                   var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_GetFilesWhere&quot;));
 ///                   Directory.CreateDirectory(root.FullName);
 /// 
 ///                   var file1 = new FileInfo(Path.Combine(root.FullName, &quot;test.txt&quot;));
 ///                   var file2 = new FileInfo(Path.Combine(root.FullName, &quot;test.cs&quot;));
 ///                   var file3 = new FileInfo(Path.Combine(root.FullName, &quot;test.asp&quot;));
 ///                   file1.Create();
 ///                   file2.Create();
 ///                   file3.Create();
 /// 
 ///                   // Exemples
 ///                   FileInfo[] result = root.GetFilesWhere(x =&gt; x.Extension == &quot;.txt&quot; || x.Extension == &quot;.cs&quot;);
 /// 
 ///                   // Unit Test
 ///                   Assert.AreEqual(2, result.Length);
 ///               }
 ///           }
 ///       }
 /// </code>
 /// </example>
 /// <example>
 ///     <code>
 ///       using System;
 ///       using System.IO;
 ///       using Microsoft.VisualStudio.TestTools.UnitTesting;
 ///       using Z.ExtensionMethods;
 /// 
 ///       namespace ExtensionMethods.Examples
 ///       {
 ///           [TestClass]
 ///           public class System_IO_DirectoryInfo_GetFilesWhere
 ///           {
 ///               [TestMethod]
 ///               public void GetFilesWhere()
 ///               {
 ///                   // Type
 ///                   var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_GetFilesWhere&quot;));
 ///                   Directory.CreateDirectory(root.FullName);
 /// 
 ///                   var file1 = new FileInfo(Path.Combine(root.FullName, &quot;test.txt&quot;));
 ///                   var file2 = new FileInfo(Path.Combine(root.FullName, &quot;test.cs&quot;));
 ///                   var file3 = new FileInfo(Path.Combine(root.FullName, &quot;test.asp&quot;));
 ///                   file1.Create();
 ///                   file2.Create();
 ///                   file3.Create();
 /// 
 ///                   // Exemples
 ///                   FileInfo[] result = root.GetFilesWhere(x =&gt; x.Extension == &quot;.txt&quot; || x.Extension == &quot;.cs&quot;);
 /// 
 ///                   // Unit Test
 ///                   Assert.AreEqual(2, result.Length);
 ///               }
 ///           }
 ///       }
 /// </code>
 /// </example>
 /// ###
 /// <exception cref="T:System.ArgumentException">
 ///     <paramref name="this " />is a zero-length string, contains only
 ///     white space, or contains invalid characters as defined by
 ///     <see
 ///         cref="M:System.IO.Path.GetInvalidPathChars" />
 ///     .- or -<paramref name="searchPattern" /> does not contain a valid pattern.
 /// </exception>
 /// ###
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="this" /> is null.-or-
 ///     <paramref name="searchPattern" /> is null.
 /// </exception>
 /// ###
 /// <exception cref="T:System.ArgumentOutOfRangeException">
 ///     <paramref name="searchOption" /> is not a valid
 ///     <see cref="T:System.IO.SearchOption" /> value.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.DirectoryNotFoundException">
 ///     <paramref name="this" /> is invalid, such as
 ///     referring to an unmapped drive.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.IOException">
 ///     <paramref name="this" /> is a file name.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.PathTooLongException">
 ///     The specified @this, file name, or combined exceed the
 ///     system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters
 ///     and file names must be less than 260 characters.
 /// </exception>
 /// ###
 /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// ###
 /// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
 public static FileInfo[] GetFilesWhere(this DirectoryInfo @this, String[] searchPatterns, SearchOption searchOption, Func<FileInfo, bool> predicate)
 {
     return searchPatterns.SelectMany(x => @this.GetFiles(x, searchOption)).Distinct().Where(x => predicate(x)).ToArray();
 }
开发者ID:fqybzhangji,项目名称:Z.ExtensionMethods,代码行数:101,代码来源:DirectoryInfo.GetFilesWhere.cs

示例5: EnumerateDirectories


//.........这里部分代码省略.........
 ///       using System.Linq;
 ///       using Microsoft.VisualStudio.TestTools.UnitTesting;
 /// 
 ///       namespace ExtensionMethods.Examples
 ///       {
 ///           [TestClass]
 ///           public class System_IO_DirectoryInfo_EnumerateDirectories
 ///           {
 ///               [TestMethod]
 ///               public void EnumerateDirectories()
 ///               {
 ///                   // Type
 ///                   var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_EnumerateDirectories&quot;));
 ///                   Directory.CreateDirectory(root.FullName);
 ///                   root.CreateSubdirectory(&quot;Directory1&quot;);
 ///                   root.CreateSubdirectory(&quot;Directory2&quot;);
 /// 
 ///                   // Exemples
 ///                   List&lt;DirectoryInfo&gt; result = root.EnumerateDirectories().ToList();
 /// 
 ///                   // Unit Test
 ///                   Assert.AreEqual(2, result.Count);
 ///               }
 ///           }
 ///       }
 /// </code>
 /// </example>
 /// ###
 /// <param name="searchPattern">
 ///     The search string to match against the names of directories in
 ///     <paramref name="this" />.
 /// </param>
 /// ###
 /// <exception cref="T:System.ArgumentException">
 ///     <paramref name="this " />is a zero-length string, contains only
 ///     white space, or contains invalid characters as defined by
 ///     <see
 ///         cref="M:System.IO.Path.GetInvalidPathChars" />
 ///     .- or -<paramref name="searchPattern" /> does not contain a valid pattern.
 /// </exception>
 /// ###
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="this" /> is null.-or-
 ///     <paramref name="searchPattern" /> is null.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.DirectoryNotFoundException">
 ///     <paramref name="this" /> is invalid, such as
 ///     referring to an unmapped drive.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.IOException">
 ///     <paramref name="this" /> is a file name.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.PathTooLongException">
 ///     The specified @this, file name, or combined exceed the
 ///     system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters
 ///     and file names must be less than 260 characters.
 /// </exception>
 /// ###
 /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// ###
 /// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
 /// <example>
 ///     <code>
 ///           using System;
 ///           using System.Collections.Generic;
 ///           using System.IO;
 ///           using System.Linq;
 ///           using Microsoft.VisualStudio.TestTools.UnitTesting;
 ///           
 ///           namespace ExtensionMethods.Examples
 ///           {
 ///               [TestClass]
 ///               public class System_IO_DirectoryInfo_EnumerateDirectories
 ///               {
 ///                   [TestMethod]
 ///                   public void EnumerateDirectories()
 ///                   {
 ///                       // Type
 ///                       var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_EnumerateDirectories&quot;));
 ///                       Directory.CreateDirectory(root.FullName);
 ///                       root.CreateSubdirectory(&quot;Directory1&quot;);
 ///                       root.CreateSubdirectory(&quot;Directory2&quot;);
 ///           
 ///                       // Exemples
 ///                       List&lt;DirectoryInfo&gt; result = root.EnumerateDirectories().ToList();
 ///           
 ///                       // Unit Test
 ///                       Assert.AreEqual(2, result.Count);
 ///                   }
 ///               }
 ///           }
 ///     </code>
 /// </example>
 public static IEnumerable<DirectoryInfo> EnumerateDirectories(this DirectoryInfo @this, String[] searchPatterns)
 {
     return searchPatterns.SelectMany(x => @this.GetDirectories(x)).Distinct();
 }
开发者ID:Nucs,项目名称:nlib,代码行数:101,代码来源:DirectoryInfo.EnumerateDirectories.cs

示例6: GetFileSystemEntriesWhere


//.........这里部分代码省略.........
 ///       namespace ExtensionMethods.Examples
 ///       {
 ///           [TestClass]
 ///           public class System_IO_DirectoryInfo_GetFileSystemEntriesWhere
 ///           {
 ///               [TestMethod]
 ///               public void GetFileSystemEntriesWhere()
 ///               {
 ///                   // Type
 ///                   var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_GetFileSystemEntriesWhere&quot;));
 ///                   Directory.CreateDirectory(root.FullName);
 ///                   root.CreateSubdirectory(&quot;DirFizz123&quot;);
 ///                   root.CreateSubdirectory(&quot;DirBuzz123&quot;);
 ///                   var file1 = new FileInfo(Path.Combine(root.FullName, &quot;test1.txt&quot;));
 ///                   file1.Create();
 /// 
 ///                   // Exemples
 ///                   string[] result = root.GetFileSystemEntriesWhere(x =&gt; x.Contains(&quot;DirFizz&quot;) || x.EndsWith(&quot;.txt&quot;));
 /// 
 ///                   // Unit Test
 ///                   Assert.AreEqual(2, result.Length);
 ///               }
 ///           }
 ///       }
 /// </code>
 /// </example>
 /// <example>
 ///     <code>
 ///       using System;
 ///       using System.IO;
 ///       using Microsoft.VisualStudio.TestTools.UnitTesting;
 ///       using Z.ExtensionMethods;
 /// 
 ///       namespace ExtensionMethods.Examples
 ///       {
 ///           [TestClass]
 ///           public class System_IO_DirectoryInfo_GetFileSystemEntriesWhere
 ///           {
 ///               [TestMethod]
 ///               public void GetFileSystemEntriesWhere()
 ///               {
 ///                   // Type
 ///                   var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_GetFileSystemEntriesWhere&quot;));
 ///                   Directory.CreateDirectory(root.FullName);
 ///                   root.CreateSubdirectory(&quot;DirFizz123&quot;);
 ///                   root.CreateSubdirectory(&quot;DirBuzz123&quot;);
 ///                   var file1 = new FileInfo(Path.Combine(root.FullName, &quot;test1.txt&quot;));
 ///                   file1.Create();
 /// 
 ///                   // Exemples
 ///                   string[] result = root.GetFileSystemEntriesWhere(x =&gt; x.Contains(&quot;DirFizz&quot;) || x.EndsWith(&quot;.txt&quot;));
 /// 
 ///                   // Unit Test
 ///                   Assert.AreEqual(2, result.Length);
 ///               }
 ///           }
 ///       }
 /// </code>
 /// </example>
 /// ###
 /// <exception cref="T:System.ArgumentException">
 ///     <paramref name="this " />is a zero-length string, contains only
 ///     white space, or contains invalid characters as defined by
 ///     <see
 ///         cref="M:System.IO.Path.GetInvalidPathChars" />
 ///     .- or -<paramref name="searchPattern" /> does not contain a valid pattern.
 /// </exception>
 /// ###
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="this" /> is null.-or-
 ///     <paramref name="searchPattern" /> is null.
 /// </exception>
 /// ###
 /// <exception cref="T:System.ArgumentOutOfRangeException">
 ///     <paramref name="searchOption" /> is not a valid
 ///     <see cref="T:System.IO.SearchOption" /> value.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.DirectoryNotFoundException">
 ///     <paramref name="this" /> is invalid, such as
 ///     referring to an unmapped drive.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.IOException">
 ///     <paramref name="this" /> is a file name.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.PathTooLongException">
 ///     The specified @this, file name, or combined exceed the
 ///     system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters
 ///     and file names must be less than 260 characters.
 /// </exception>
 /// ###
 /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// ###
 /// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
 public static string[] GetFileSystemEntriesWhere(this DirectoryInfo @this, String[] searchPatterns, SearchOption searchOption, Func<string, bool> predicate)
 {
     return searchPatterns.SelectMany(x => Directory.EnumerateFileSystemEntries(@this.FullName, x, searchOption)).Distinct().Where(x => predicate(x)).ToArray();
 }
开发者ID:fqybzhangji,项目名称:Z.ExtensionMethods,代码行数:101,代码来源:DirectoryInfo.GetFileSystemEntriesWhere.cs

示例7: GetDirectoriesWhere


//.........这里部分代码省略.........
 /// 
 /// 
 ///       namespace ExtensionMethods.Examples
 ///       {
 ///           [TestClass]
 ///           public class System_IO_DirectoryInfo_GetDirectoriesWhere
 ///           {
 ///               [TestMethod]
 ///               public void GetDirectoriesWhere()
 ///               {
 ///                   // Type
 ///                   var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_GetDirectories&quot;));
 ///                   Directory.CreateDirectory(root.FullName);
 ///                   root.CreateSubdirectory(&quot;DirFizz123&quot;);
 ///                   root.CreateSubdirectory(&quot;DirBuzz123&quot;);
 ///                   root.CreateSubdirectory(&quot;DirNotFound123&quot;);
 /// 
 ///                   // Exemples
 ///                   DirectoryInfo[] result = root.GetDirectoriesWhere(x =&gt; x.Name.StartsWith(&quot;DirFizz&quot;) || x.Name.StartsWith(&quot;DirBuzz&quot;));
 /// 
 ///                   // Unit Test
 ///                   Assert.AreEqual(2, result.Length);
 ///               }
 ///           }
 ///       }
 /// </code>
 /// </example>
 /// <example>
 ///     <code>
 ///       using System;
 ///       using System.IO;
 ///       using Microsoft.VisualStudio.TestTools.UnitTesting;
 ///       using Z.ExtensionMethods;
 /// 
 ///       namespace ExtensionMethods.Examples
 ///       {
 ///           [TestClass]
 ///           public class System_IO_DirectoryInfo_GetDirectoriesWhere
 ///           {
 ///               [TestMethod]
 ///               public void GetDirectoriesWhere()
 ///               {
 ///                   // Type
 ///                   var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_GetDirectories&quot;));
 ///                   Directory.CreateDirectory(root.FullName);
 ///                   root.CreateSubdirectory(&quot;DirFizz123&quot;);
 ///                   root.CreateSubdirectory(&quot;DirBuzz123&quot;);
 ///                   root.CreateSubdirectory(&quot;DirNotFound123&quot;);
 /// 
 ///                   // Exemples
 ///                   DirectoryInfo[] result = root.GetDirectoriesWhere(x =&gt; x.Name.StartsWith(&quot;DirFizz&quot;) || x.Name.StartsWith(&quot;DirBuzz&quot;));
 /// 
 ///                   // Unit Test
 ///                   Assert.AreEqual(2, result.Length);
 ///               }
 ///           }
 ///       }
 /// </code>
 /// </example>
 /// ###
 /// <param name="searchPattern">
 ///     The search string to match against the names of directories in
 ///     <paramref name="this" />.
 /// </param>
 /// ###
 /// <exception cref="T:System.ArgumentException">
 ///     <paramref name="this " />is a zero-length string, contains only
 ///     white space, or contains invalid characters as defined by
 ///     <see
 ///         cref="M:System.IO.Path.GetInvalidPathChars" />
 ///     .- or -<paramref name="searchPattern" /> does not contain a valid pattern.
 /// </exception>
 /// ###
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="this" /> is null.-or-
 ///     <paramref name="searchPattern" /> is null.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.DirectoryNotFoundException">
 ///     <paramref name="this" /> is invalid, such as
 ///     referring to an unmapped drive.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.IOException">
 ///     <paramref name="this" /> is a file name.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.PathTooLongException">
 ///     The specified @this, file name, or combined exceed the
 ///     system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters
 ///     and file names must be less than 260 characters.
 /// </exception>
 /// ###
 /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// ###
 /// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
 public static DirectoryInfo[] GetDirectoriesWhere(this DirectoryInfo @this, String[] searchPatterns, Func<DirectoryInfo, bool> predicate)
 {
     return searchPatterns.SelectMany(x => @this.GetDirectories(x)).Distinct().Where(x => predicate(x)).ToArray();
 }
开发者ID:fqybzhangji,项目名称:Z.ExtensionMethods,代码行数:101,代码来源:DirectoryInfo.GetDirectoriesWhere.cs

示例8: GetFileSystemEntries


//.........这里部分代码省略.........
 ///       namespace ExtensionMethods.Examples
 ///       {
 ///           [TestClass]
 ///           public class System_IO_DirectoryInfo_GetFileSystemEntries
 ///           {
 ///               [TestMethod]
 ///               public void GetFileSystemEntries()
 ///               {
 ///                   // Type
 ///                   var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_GetFileSystemEntries&quot;));
 ///                   Directory.CreateDirectory(root.FullName);
 ///                   root.CreateSubdirectory(&quot;DirFizz123&quot;);
 ///                   root.CreateSubdirectory(&quot;DirBuzz123&quot;);
 ///                   var file1 = new FileInfo(Path.Combine(root.FullName, &quot;test1.txt&quot;));
 ///                   file1.Create();
 /// 
 ///                   // Exemples
 ///                   string[] result = root.GetFileSystemEntries(new[] {&quot;DirFizz*&quot;, &quot;*.txt&quot;});
 /// 
 ///                   // Unit Test
 ///                   Assert.AreEqual(2, result.Length);
 ///               }
 ///           }
 ///       }
 /// </code>
 /// </example>
 /// <example>
 ///     <code>
 ///       using System;
 ///       using System.IO;
 ///       using Microsoft.VisualStudio.TestTools.UnitTesting;
 ///       using Z.ExtensionMethods;
 /// 
 ///       namespace ExtensionMethods.Examples
 ///       {
 ///           [TestClass]
 ///           public class System_IO_DirectoryInfo_GetFileSystemEntries
 ///           {
 ///               [TestMethod]
 ///               public void GetFileSystemEntries()
 ///               {
 ///                   // Type
 ///                   var root = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;System_IO_DirectoryInfo_GetFileSystemEntries&quot;));
 ///                   Directory.CreateDirectory(root.FullName);
 ///                   root.CreateSubdirectory(&quot;DirFizz123&quot;);
 ///                   root.CreateSubdirectory(&quot;DirBuzz123&quot;);
 ///                   var file1 = new FileInfo(Path.Combine(root.FullName, &quot;test1.txt&quot;));
 ///                   file1.Create();
 /// 
 ///                   // Exemples
 ///                   string[] result = root.GetFileSystemEntries(new[] {&quot;DirFizz*&quot;, &quot;*.txt&quot;});
 /// 
 ///                   // Unit Test
 ///                   Assert.AreEqual(2, result.Length);
 ///               }
 ///           }
 ///       }
 /// </code>
 /// </example>
 /// ###
 /// <param name="searchPattern">
 ///     The search string to match against the names of directories in
 ///     <paramref name="this" />.
 /// </param>
 /// ###
 /// <exception cref="T:System.ArgumentException">
 ///     <paramref name="this " />is a zero-length string, contains only
 ///     white space, or contains invalid characters as defined by
 ///     <see
 ///         cref="M:System.IO.Path.GetInvalidPathChars" />
 ///     .- or -<paramref name="searchPattern" /> does not contain a valid pattern.
 /// </exception>
 /// ###
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="this" /> is null.-or-
 ///     <paramref name="searchPattern" /> is null.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.DirectoryNotFoundException">
 ///     <paramref name="this" /> is invalid, such as
 ///     referring to an unmapped drive.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.IOException">
 ///     <paramref name="this" /> is a file name.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.PathTooLongException">
 ///     The specified @this, file name, or combined exceed the
 ///     system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters
 ///     and file names must be less than 260 characters.
 /// </exception>
 /// ###
 /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// ###
 /// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
 public static string[] GetFileSystemEntries(this DirectoryInfo @this, String[] searchPatterns)
 {
     return searchPatterns.SelectMany(x => Directory.EnumerateFileSystemEntries(@this.FullName, x)).Distinct().ToArray();
 }
开发者ID:fqybzhangji,项目名称:Z.ExtensionMethods,代码行数:101,代码来源:DirectoryInfo.GetFileSystemEntries.cs

示例9: GetFiles

 /// <summary>
 ///     Returns an enumerable collection of file names that match a search pattern in a specified @this, and
 ///     optionally searches subdirectories.
 /// </summary>
 /// <param name="this">The directory to search.</param>
 /// <param name="searchPatterns">
 ///     The search string to match against the names of directories in
 ///     <paramref name="this" />.
 /// </param>
 /// <param name="searchOption">
 ///     One of the enumeration values that specifies whether the search operation should
 ///     include only the current directory or should include all subdirectories.The default value is
 ///     <see
 ///         cref="F:System.IO.SearchOption.TopDirectoryOnly" />
 ///     .
 /// </param>
 /// <returns>
 ///     An enumerable collection of the full names (including paths) for the files in the directory specified by
 ///     <paramref
 ///         name="this" />
 ///     and that match the specified search pattern and option.
 /// </returns>
 /// ###
 /// <exception cref="T:System.ArgumentException">
 ///     <paramref name="this " />is a zero-length string, contains only
 ///     white space, or contains invalid characters as defined by
 ///     <see
 ///         cref="M:System.IO.Path.GetInvalidPathChars" />
 ///     .- or -<paramref name="searchPattern" /> does not contain a valid pattern.
 /// </exception>
 /// ###
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="this" /> is null.-or-
 ///     <paramref name="searchPattern" /> is null.
 /// </exception>
 /// ###
 /// <exception cref="T:System.ArgumentOutOfRangeException">
 ///     <paramref name="searchOption" /> is not a valid
 ///     <see cref="T:System.IO.SearchOption" /> value.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.DirectoryNotFoundException">
 ///     <paramref name="this" /> is invalid, such as
 ///     referring to an unmapped drive.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.IOException">
 ///     <paramref name="this" /> is a file name.
 /// </exception>
 /// ###
 /// <exception cref="T:System.IO.PathTooLongException">
 ///     The specified @this, file name, or combined exceed the
 ///     system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters
 ///     and file names must be less than 260 characters.
 /// </exception>
 /// ###
 /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// ###
 /// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
 public static FileInfo[] GetFiles(this DirectoryInfo @this, String[] searchPatterns, SearchOption searchOption)
 {
     return searchPatterns.SelectMany(x => @this.GetFiles(x, searchOption)).Distinct().ToArray();
 }
开发者ID:ChuangYang,项目名称:Z.ExtensionMethods,代码行数:63,代码来源:DirectoryInfo.GetFiles.cs


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