Example #1
0
        /// <summary>
        /// 添加或者更新参数
        /// </summary>
        /// <param name="key">参数名称</param>
        /// <param name="value">参数值</param>
        /// <param name="comment">描述</param>
        /// <param name="category">分类</param>
        public void AddOrUpdate(string key, string value, string comment, string category)
        {
            var index = ParamData.IndexOf(p => p.Key.Equals(key));

            if (index == -1)
            {
                ParamEntity entity = new ParamEntity();
                entity.Key      = key;
                entity.Value    = value;
                entity.Comment  = comment;
                entity.Category = category;
                if (Insert(entity))
                {
                    ParamData.Add(entity);
                }
            }
            else
            {
                ParamEntity entity = ParamData[index];
                entity.Key   = key;
                entity.Value = value;
                if (!string.IsNullOrEmpty(comment))
                {
                    entity.Comment = comment;
                }
                if (!string.IsNullOrEmpty(category))
                {
                    entity.Category = category;
                }
                Update(entity);
            }
        }
Example #2
0
 /// <summary>
 /// 删除参数对象
 /// </summary>
 /// <param name="entity">参数实体</param>
 protected virtual bool Delete(ParamEntity entity)
 {
     return(true);
 }
Example #3
0
 /// <summary>
 /// 插入参数对象
 /// </summary>
 /// <param name="entity">参数实体</param>
 protected virtual bool Insert(ParamEntity entity)
 {
     return(true);
 }