| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Configuration;
- namespace HXX.Scanner.Biz
- {
- /// <summary>
- /// 配置文件Settings.Default操作类
- /// </summary>
- public class config_manager
- {
- /// <summary>
- /// 本地配置文件
- /// </summary>
- private static ApplicationSettingsBase config { get; set; }
- /// <summary>
- /// 初始化配置文件
- /// </summary>
- /// <param name="_config"></param>
- public static void Init(ApplicationSettingsBase _config)
- {
- config = _config;
- }
- /// <summary>
- /// 获取配置信息
- /// </summary>
- /// <param name="key"></param>
- /// <returns></returns>
- public static string Get(string key)
- {
- string value = null;
- var item = config.Properties[key];
- if (item != null)
- {
- var obj = config[key];
- if (obj != null)
- {
- value = obj.ToString();
- }
- }
- return value;
- }
- /// <summary>
- /// 设置配置信息
- /// </summary>
- /// <param name="key"></param>
- /// <param name="value"></param>
- /// <returns></returns>
- public static bool Set(string key, string value)
- {
- bool result = false;
- var item = config.Properties[key];
- if (item != null)
- {
- config[key] = value;
- config.Save();
- result = true;
- }
- return result;
- }
- }
- }
|