Ejemplo n.º 1
0
        /// <summary>
        /// 读取配置文件
        /// </summary>
        /// <param name="fileName">文件名</param>
        /// <param name="buildType">选择读取类型</param>
        public UseConfigFactory(string fileName, ConfigBuildType buildType = ConfigBuildType.Json)
        {
            switch (buildType)
            {
            case ConfigBuildType.Json:
                _ConfigManager = new ConfigManagerJson(fileName);
                break;

            case ConfigBuildType.Xml:
                _ConfigManager = new ConfigManagerXml(fileName);
                break;

            case ConfigBuildType.Ini:
                _ConfigManager = new ConfigManagerIni(fileName);
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 用于构造 配置文件的构造器
        /// </summary>
        /// <param name="fileName">文件名称</param>
        /// <param name="type">类型</param>
        public ConfigurationBuild(string fileName, ConfigBuildType type)
        {
            var builder = new ConfigurationBuilder();

            switch (type)
            {
            case ConfigBuildType.Json:
                builder.AddJsonFile(fileName, optional: false, reloadOnChange: true);
                break;

            case ConfigBuildType.Xml:
                builder.AddXmlFile(fileName, optional: false, reloadOnChange: true);
                break;

            case ConfigBuildType.Ini:
                builder.AddIniFile(fileName, optional: false, reloadOnChange: true);
                break;

            default:
                throw new Exception("构造 ConfigurationBuild 遇到未识别的类型");
            }
            ConfigBuild = builder.Build();
        }