Пример #1
0
        private void RemoveNameProperty(Root root)
        {
            var pm = Owner as ItemModel;
            var tx = pm.GetItem();

            pm.ChildDelta++;
            ItemUnLinked.Record(root, root.Get <Relation_Store_NameProperty>(), tx, Item);
        }
        private void RemoveSummaryProperty(Root root)
        {
            var pm = Owner as LineModel;
            var tx = pm.Item;

            pm.ChildDelta++;
            ItemUnLinked.Record(root, root.Get <Relation_Store_SummaryProperty>(), tx, Item);
        }
Пример #3
0
        internal void RemoveItem(Item target)
        {
            var root      = Owner;
            var hitList   = new List <Item>();                                           //======================== dependant items that also need to be killed off
            var stoCRels  = root.Get <Relation_Store_ChildRelation>();                   //==== souce1 of relational integrity
            var stoPRels  = root.Get <Relation_Store_ParentRelation>();                  //==== souce2 of relational integrity
            var stoXCRels = root.Get <Relation_StoreX_ChildRelation>();                  //==== souce1 of relational integrity
            var stoXPRels = root.Get <Relation_StoreX_ParentRelation>();                 //==== souce2 of relational integrity

            _ = root.Get <Relation_Store_ColumnX>();                                     //======= reference to user created columns
            var history = new Dictionary <Relation, Dictionary <Item, List <Item> > >(); //history of unlinked relationships

            FindDependents(target, hitList, stoCRels, stoXCRels);
            hitList.Reverse();

            foreach (var item in hitList)
            {
                if (item is Relation r)
                {
                    var N = r.GetLinks(out List <Item> parents, out List <Item> children);

                    for (int i = 0; i < N; i++)
                    {
                        ItemUnLinked.Record(ChangeSet, root, r, parents[i], children[i], history);
                    }
                }
                if (TryGetParentRelations(item, out IList <Relation> relations, stoPRels, stoXPRels))
                {
                    foreach (var rel in relations)
                    {
                        if (!rel.TryGetParents(item, out List <Item> parents))
                        {
                            continue;
                        }

                        foreach (var parent in parents)
                        {
                            ItemUnLinked.Record(ChangeSet, root, rel, parent, item, history);
                        }
                    }
                }
                if (TryGetChildRelations(item, out relations, stoCRels, stoXCRels))
                {
                    foreach (var rel in relations)
                    {
                        if (!rel.TryGetChildren(item, out List <Item> children))
                        {
                            continue;
                        }

                        foreach (var child in children)
                        {
                            ItemUnLinked.Record(ChangeSet, root, rel, item, child, history);
                        }
                    }
                }
            }

            foreach (var item in hitList)
            {
                ItemRemoved.Record(ChangeSet, root, item);
            }

            ChangeSet.Redo(); //now finally do all changes in the correct order
        }
Пример #4
0
 private void RemoveSummaryProperty(Root root)
 {
     Owner.ChildDelta++;
     ItemUnLinked.Record(root, root.Get <Relation_Store_SummaryProperty>(), Owner.GetItem(), Item);
 }