Пример #1
0
            internal void Clone(EntityTreeChildren source, CloneOptions options)
            {
                _loaded = source._loaded;
                if (_loaded)
                {
                    var srcNodes = source._nodes;
                    if (srcNodes != null)
                    {
                        _nodes = new List <Entity>();

                        var repo       = _owner.FindRepository();
                        var entityType = _owner.GetType();

                        for (int i = 0, c = srcNodes.Count; i < c; i++)
                        {
                            var src = srcNodes[i];

                            Entity entity = null;
                            if (repo != null)
                            {
                                entity = repo.New();
                            }
                            else
                            {
                                entity = Entity.New(entityType);
                            }

                            entity.Clone(src, options);

                            entity._treeParent = _owner;
                            _nodes.Add(entity);
                        }
                    }
                }
            }
Пример #2
0
            internal void Clone(EntityTreeChildren source, CloneOptions options)
            {
                _loaded = source._loaded;
                if (_loaded)
                {
                    var srcNodes = source._nodes;
                    if (srcNodes != null)
                    {
                        _nodes = new List <Entity>();

                        var repo       = _owner.FindRepository();
                        var entityType = _owner.GetType();

                        for (int i = 0, c = srcNodes.Count; i < c; i++)
                        {
                            var src = srcNodes[i];

                            Entity entity = null;
                            if (repo != null)
                            {
                                entity = repo.New();
                            }
                            else
                            {
                                entity = Entity.New(entityType);
                            }

                            /*修复Entitylist使用TreeChildren属性Clone时TreeIndex错误问题
                             *原因是TreeChildren中实体Clone时会TreePId改变触发OnTreePIdChanged事件,
                             * OnTreePIdChanged事件中会处理entity._treeParent为空并且
                             * _treeParent.Id不等于新的克隆值时,需要重新设置TreeParent值
                             * 导致设置TreeIndex错误
                             * 所以需要entity克隆前设置_treeParent的值为 source._owner
                             */

                            entity._treeParent = source._owner;

                            entity.Clone(src, options);

                            entity._treeParent = _owner;
                            _nodes.Add(entity);
                        }
                    }
                }
            }
Пример #3
0
            internal LoadedChildrenEnumerator(Entity entity)
            {
                _entity = entity;

                //Entity 有可能是一个 Criteria,这时会没有仓库。
                var repo = entity.FindRepository();

                if (repo != null)
                {
                    _childProperties = repo.GetChildProperties();
                }
                else
                {
                    _childProperties = new IProperty[0];
                }
                _index   = -1;
                _current = new ChildPropertyField();
            }