/// <summary> /// 向集合追加一个成员 /// </summary> /// <param name="findExp"></param> /// <param name="member"></param> public void Push(string findExp, DTObject member) { ValidateReadOnly(); DTEList entity = FindEntity <DTEList>(findExp, false); if (entity == null) { var query = QueryExpression.Create(findExp); _root.SetEntity(query, (name) => { var dte = DTOPool.CreateDTEList(this.IsPinned); dte.Name = name; return(dte); }); entity = FindEntity <DTEList>(findExp, true); } ; if (member == null) { return; } entity.Push(member); }
public DTObject CreateAndPush(string findExp) { ValidateReadOnly(); DTEList entity = GetOrCreateList(findExp); return(entity.CreateAndPush()); }
public DTObjects GetList(string findExp, bool throwError) { DTEList entity = FindEntity <DTEList>(findExp, throwError); if (entity == null) { return(null); } return(entity.GetObjects()); }
public static DTObjectList CreateObjectList(DTEList owner, bool isPinned) { var list = isPinned ? new DTObjectList() : Symbiosis.TryMark(_objectListPool, () => { return(new DTObjectList()); }); list.Init(owner, isPinned); return(list); }
/// <summary> /// 保留集合指定序号的条目,移除其他项 /// </summary> /// <param name="listExp"></param> /// <param name="indexs"></param> public void RetainAts(string listExp, IList <int> indexs) { ValidateReadOnly(); DTEList entity = FindEntity <DTEList>(listExp, false); if (entity != null) { entity.RetainAts(indexs); } }
public void Push(string findExp, IEnumerable list, Action <DTObject, object> action) { ValidateReadOnly(); DTEList entity = GetOrCreateList(findExp); foreach (object item in list) { DTObject dto = entity.CreateAndPush(); action(dto, item); } }
private DTEList GetOrCreateList(string findExp) { DTEList entity = FindEntity <DTEList>(findExp, false); if (entity == null) { var query = QueryExpression.Create(findExp); _root.SetEntity(query, (name) => { var dte = DTOPool.CreateDTEList(this.IsPinned); dte.Name = name; return(dte); }); entity = FindEntity <DTEList>(findExp, true); } return(entity); }
/// <summary> /// 如果不存在findExp对应的列表,那么创建 /// </summary> /// <param name="findExp"></param> public void SetList(string findExp) { ValidateReadOnly(); DTEList entity = FindEntity <DTEList>(findExp, false); if (entity == null) { var query = QueryExpression.Create(findExp); _root.SetEntity(query, (name) => { var dte = DTOPool.CreateDTEList(this.IsPinned); dte.Name = name; return(dte); }); } ; }
private TypeEntry CreateEntry(DTEList e) { var name = e.Name; //条目名称 string typeName = GetPathName(name); if (e.Items.Count == 0) { throw new DTOException(string.Format(Strings.DTONotSpecifyType, typeName)); } if (e.Items.Count > 1) { throw new DTOException(string.Format(Strings.DTOListTypeCountError, typeName)); } var metadataCode = GetItemMetadataCode(typeName, e.Items[0]); return(new ListEntry(this, name, typeName, metadataCode)); }
public void Reset() { this.Clear(); _list = null; _owner = null; }
public void Init(DTEList owner, bool isPinned) { _owner = owner; this.IsPinned = isPinned; _list = DTOPool.CreateObjects(isPinned); }