コード例 #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
        private DTEList CreateListEntity(string name, IEnumerable list)
        {
            var dte = DTOPool.CreateDTEList(this.IsPinned);

            dte.Name = name;

            foreach (var item in list)
            {
                dte.CreateAndPush((dto) =>
                {
                    dto.SetValue(item);
                });
            }
            return(dte);
        }
コード例 #3
0
        private static void FillEntities(List <DTEntity> entities, CodeTreeNode node, bool isReadOnly, bool isPinned)
        {
            var name = JSON.GetStringValue(node.Name.ToString());

            if (node.Type == CodeType.Object)
            {
                var members = DTOPool.CreateDTEntities(isPinned);
                //收集成员
                foreach (CodeTreeNode item in node.Childs)
                {
                    FillEntities(members, item, isReadOnly, isPinned);
                }

                var obj = DTOPool.CreateDTEObject(members, isPinned);
                obj.Name = name;
                entities.Add(obj);
            }
            else if (node.Type == CodeType.List)
            {
                var childs = DTOPool.CreateObjects(isPinned);
                using (var temp = DTOPool.EntitiesPool.Borrow())
                {
                    //收集成员
                    var tempChilds = temp.Item;
                    foreach (CodeTreeNode item in node.Childs)
                    {
                        FillEntities(tempChilds, item, isReadOnly, isPinned);
                    }

                    foreach (var e in tempChilds)
                    {
                        var item = CreateDTObject(e, isReadOnly, isPinned);
                        childs.Add(item);
                    }
                }

                var list = DTOPool.CreateDTEList(childs, isPinned);
                list.Name = name;
                entities.Add(list);
            }
            else
            {
                object value = node.Type == CodeType.StringValue ? JSON.GetStringValue(node.Value) : JSON.GetValue(node.Value);
                var    dte   = DTOPool.CreateDTEValue(name, value, isPinned);
                entities.Add(dte);
            }
        }
コード例 #4
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);
        }
コード例 #5
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);
                });
            }
            ;
        }
コード例 #6
0
 /// <summary>
 /// 仅克隆结构
 /// </summary>
 /// <returns></returns>
 public override DTEntity Clone()
 {
     return(DTOPool.CreateDTEList(this.Name, this.ItemTemplate, this.Items, this.IsPinned));
 }