Пример #1
0
        /// <summary>
        /// 转换为文件路径组合器。
        /// </summary>
        /// <param name="fileName">给定的 <see cref="FileNameCombiner"/>。</param>
        /// <param name="basePath">给定的基础路径。</param>
        /// <returns>返回 <see cref="FilePathCombiner"/>。</returns>
        public static FilePathCombiner AsFilePathCombiner(this FileNameCombiner fileName, string basePath = null)
        {
            var combiner = new FilePathCombiner(fileName);

            if (!basePath.IsEmpty())
            {
                combiner.ChangeBasePath(basePath);
            }

            return(combiner);
        }
        public static FileNameCombiner[] AsFileNameCombiners(this string[] fileNames)
        {
            fileNames.NotEmpty(nameof(fileNames));

            var combiners = new FileNameCombiner[fileNames.Length];

            for (var i = 0; i < fileNames.Length; i++)
            {
                combiners[i] = new FileNameCombiner(fileNames[i]);
            }

            return(combiners);
        }
Пример #3
0
 /// <summary>
 /// 构造一个 <see cref="FilePathCombiner"/>。
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="fileName"/> is null.
 /// </exception>
 /// <param name="fileName">给定的文件名。</param>
 /// <param name="basePath">给定的基础路径(可空)。</param>
 public FilePathCombiner(FileNameCombiner fileName, string basePath)
     : base(CombineParameters(fileName, basePath))
 {
     FileName = fileName;
     BasePath = basePath;
 }
Пример #4
0
 /// <summary>
 /// 是指定的文件名(忽略大小写)。
 /// </summary>
 /// <param name="fileName">给定的 <see cref="FileNameCombiner"/>。</param>
 /// <returns>返回布尔值。</returns>
 public bool IsFileName(FileNameCombiner fileName)
 => FileName == fileName;
Пример #5
0
 /// <summary>
 /// 依据当前文件组合器的基础路径与指定的文件名,新建一个 <see cref="FilePathCombiner"/>。
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="newFileName"/> is null.
 /// </exception>
 /// <param name="newFileName">给定的新 <see cref="FileNameCombiner"/>。</param>
 /// <returns>返回 <see cref="FilePathCombiner"/>。</returns>
 public FilePathCombiner WithFileName(FileNameCombiner newFileName)
 => new FilePathCombiner(newFileName, BasePath);
Пример #6
0
 /// <summary>
 /// 改变文件名。
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="newFileName"/> is null.
 /// </exception>
 /// <param name="newFileName">给定的新 <see cref="FileNameCombiner"/>。</param>
 /// <returns>返回当前 <see cref="FilePathCombiner"/>。</returns>
 public FilePathCombiner ChangeFileName(FileNameCombiner newFileName)
 {
     FileName = newFileName.NotNull(nameof(newFileName));
     return(this);
 }
 /// <summary>
 /// 当作数组。
 /// </summary>
 /// <param name="combiner">给定的 <see cref="FileNameCombiner"/>。</param>
 /// <returns>返回 <see cref="FileNameCombiner"/> 集合。</returns>
 public static FileNameCombiner[] AsArray(this FileNameCombiner combiner)
 {
     combiner.NotNull(nameof(combiner));
     return(new FileNameCombiner[] { combiner });
 }