Esempio n. 1
0
        /// <summary>
        /// 写入INI格式的配置文件
        /// </summary>
        /// <param name="setting">标题</param>
        /// <param name="name">属性</param>
        /// <param name="value">值</param>
        /// <returns></returns>
        public bool WriteIniConfigInfos(string setting, string name, string value)
        {
            var inIConfing = new InIConfingHelper(SettingPath);

            inIConfing.Write(setting, name, value);

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// 写入INI格式的配置文件
        /// </summary>
        /// <param name="obj">写入实体</param>
        /// <returns></returns>
        public bool WriteIniConfigInfos(IConfigInfo obj)
        {
            var inIConfing = new InIConfingHelper(SettingPath);

            var properties = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);

            foreach (var property in properties)
            {
                var description =
                    ((DescriptionAttribute)Attribute.GetCustomAttribute(property, typeof(DescriptionAttribute)))
                    .Description;

                if (property.GetValue(obj, null) != null)
                {
                    inIConfing.Write(description, property.Name, property.GetValue(obj, null).ToString());
                }
            }

            return(true);
        }