/// <summary> /// 将对象添加到集合尾处,如果对象已经存在,则不添加. /// </summary> /// <param name="entity">要添加的对象</param> /// <returns>返回添加到的地方</returns> public virtual int AddEntity(Entity entity) { foreach (Entity en in this) { if (en.GetValStrByKey("No") == entity.GetValStrByKey("No")) { return(0); } } return(this.InnerList.Add(entity)); }
/// <summary> /// 将实体类转为json格式 /// </summary> /// <param name="ens"></param> /// <param name="hidenKeys">隐藏字段</param> /// <returns></returns> public string TranslateEntityToJson(BP.En.Entity en, string hidenKeys) { Attrs attrs = en.EnMap.Attrs; StringBuilder append = new StringBuilder(); append.Append("{"); foreach (Attr attr in attrs) { if (!string.IsNullOrEmpty(hidenKeys) && hidenKeys.Contains("@" + attr.Key)) { continue; } string strValue = en.GetValStrByKey(attr.Key); if (!string.IsNullOrEmpty(strValue) && strValue.LastIndexOf("\\") > -1) { strValue = strValue.Substring(0, strValue.LastIndexOf("\\")); } append.Append(attr.Key + ":'" + strValue + "',"); } append = append.Remove(append.Length - 1, 1); append.Append("}"); return(ReplaceIllgalChart(append.ToString())); }