예제 #1
0
        static internal void Record(Root root, Relation relation, Item key, Item item, int index1, int index2)
        {
            var n1 = index1 + 1;
            var n2 = index2 + 1;

            var name = $" [{relation.GetNameId(root)}]     {item.GetDoubleNameId(root)}     {n1}->{n2}";
            var chg  = new ItemChildMoved(root.Get <ChangeRoot>().ChangeSet, relation, key, item, index1, index2, name);

            chg.Redo();
        }
예제 #2
0
        static internal void Record(Root root, Relation rel, Item item1, Item item2)
        {
            var nam1 = item1.GetDoubleNameId(root);
            var nam2 = item2.GetDoubleNameId(root);
            var rnam = rel.GetNameId(root);

            var name = $" [{rnam}]   ({nam1}) --> ({nam2})";

            (int parentIndex, int chilldIndex) = rel.AppendLink(item1, item2);
            new ItemLinked(root.Get <ChangeRoot>().ChangeSet, rel, item1, item2, parentIndex, chilldIndex, name);
        }
예제 #3
0
        internal static bool Record(ChangeSet owner, Root root, Relation rel, Item item1, Item item2, Dictionary <Relation, Dictionary <Item, List <Item> > > history)
        {
            #region track/check the history  ==================================
            // Avoid attempts to unlink the same relationship multiple times,
            // also update the historic record.
            List <Item> items;

            if (history.TryGetValue(rel, out Dictionary <Item, List <Item> > itemItems))
            {     //======================================================================this relation has been here before
                if (itemItems.TryGetValue(item1, out items))
                { //============================================the parent item has been here before
                    if (items.Contains(item2))
                    {
                        return(false); //and the child item has already been unlinked, so there is nothing to do
                    }
                    items.Add(item2);  //===================update the historic record
                }
                else
                {//============================================the parent item has not been here before
                    items = new List <Item>(2)
                    {
                        item2
                    };
                    itemItems.Add(item1, items);//=========update the historic record
                }
            }
            else
            {//======================================================================this relation has not been here before
                itemItems = new Dictionary <Item, List <Item> >(4);
                items     = new List <Item>(2)
                {
                    item2
                };
                itemItems.Add(item1, items);
                history.Add(rel, itemItems);//=========update the historic record
            }
            #endregion

            (int parentIndex, int childIndex) = rel.GetIndex(item1, item2);
            if (parentIndex < 0 || childIndex < 0)
            {
                return(false);                                   //appearently the relationship doesn't exists
            }
            var nam1 = item1.GetDoubleNameId(root);
            var nam2 = item2.GetDoubleNameId(root);
            var rnam = rel.GetNameId(root);

            var name = $" [{rnam}]   ({nam1}) --> ({nam2})";
            new ItemUnLinked(owner, rel, item1, item2, parentIndex, childIndex, name);

            return(true);
        }
예제 #4
0
        internal static bool Record(Root root, Relation rel, Item item1, Item item2)
        {
            (int parentIndex, int childIndex) = rel.GetIndex(item1, item2);
            if (parentIndex < 0 || childIndex < 0)
            {
                return(false);                                   //appearently the relationship doesn't exists
            }
            var nam1 = item1.GetDoubleNameId(root);
            var nam2 = item2.GetDoubleNameId(root);
            var rnam = rel.GetNameId(root);

            var name = $" [{rnam}]   ({nam1}) --> ({nam2})";

            var ci = new ItemUnLinked(root.Get <ChangeRoot>().ChangeSet, rel, item1, item2, parentIndex, childIndex, name);

            ci.DoNow();

            return(true);
        }