此文记录的是扩展名支持工具类。

/***

    扩展名工具类

    Austin Liu 刘恒辉
    Project Manager and Software Designer

    Date:   2024-01-15 15:18:00

    使用说明:
        1、在类里新建一个对象;
        ExtensionUtil _ExtensionUtil = new ExtensionUtil(new List<string>
        {
            ".exe",
            ".dll",
            ".ico"
        });

        2、判断是否在支持列表中;
        bool isSupport = _ExtensionUtil.IsSupport(".ico");

***/

namespace Lzhdim.LPF.Utility
{
    using System.Collections.Generic;

    /// <summary>
    /// 扩展名工具类
    /// </summary>
    public class ExtensionUtil
    {
        private List<string> _ListSupportExt = null;

        /// <summary>
        /// 扩展名工具类
        /// </summary>
        /// <param name="listSupportExt">是否支持的扩展列表</param>
        public ExtensionUtil(List<string> listSupportExt)
        {
            this._ListSupportExt = listSupportExt;
        }

        /// <summary>
        /// 是否扩展名支持的列表
        /// </summary>
        public List<string> ListSupportExt
        {
            get => this._ListSupportExt;
        }

        /// <summary>
        /// 判断某扩展名是否在支持列表里
        /// </summary>
        /// <param name="ext">扩展名,带.号</param>
        /// <param name="listExt">列表</param>
        /// <returns>true 支持;false 不支持</returns>
        public bool IsSupport(string ext)
        {
            if (_ListSupportExt.Contains(ext))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.