示例#1
0
        /// <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);
        }
示例#2
0
        public DTObject CreateAndPush(string findExp)
        {
            ValidateReadOnly();

            DTEList entity = GetOrCreateList(findExp);

            return(entity.CreateAndPush());
        }
示例#3
0
        public DTObjects GetList(string findExp, bool throwError)
        {
            DTEList entity = FindEntity <DTEList>(findExp, throwError);

            if (entity == null)
            {
                return(null);
            }
            return(entity.GetObjects());
        }
示例#4
0
        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);
        }
示例#5
0
        /// <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);
            }
        }
示例#6
0
        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);
            }
        }
示例#7
0
        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);
        }
示例#8
0
        /// <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));
        }
示例#10
0
 public void Reset()
 {
     this.Clear();
     _list  = null;
     _owner = null;
 }
示例#11
0
 public void Init(DTEList owner, bool isPinned)
 {
     _owner        = owner;
     this.IsPinned = isPinned;
     _list         = DTOPool.CreateObjects(isPinned);
 }