Esempio n. 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);
        }
Esempio n. 2
0
        public DTObject CreateAndPush(string findExp)
        {
            ValidateReadOnly();

            DTEList entity = GetOrCreateList(findExp);

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

            if (entity == null)
            {
                return(null);
            }
            return(entity.GetObjects());
        }
Esempio n. 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);
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
        }
Esempio n. 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));
        }
Esempio n. 10
0
 public void Reset()
 {
     this.Clear();
     _list  = null;
     _owner = null;
 }
Esempio n. 11
0
 public void Init(DTEList owner, bool isPinned)
 {
     _owner        = owner;
     this.IsPinned = isPinned;
     _list         = DTOPool.CreateObjects(isPinned);
 }