Exemple #1
0
        private UndoHistoryItem PopulateUndoHistoryItem(RuleRepositoryDefBase x, Action <UndoHistoryItem> undoAction)
        {
            var idx = -1;

            if (x.ParentCollection != null)
            {
                idx = x.ParentCollection.IndexOf(x.Guid);
            }

            return(new UndoHistoryItem
            {
                DefToUndo = x.CopyWithSameGuids(),
                ParentGuid = x.Parent.Guid,
                OriginalIndex = idx,
                UndoAction = undoAction
            });
        }
Exemple #2
0
        internal void IgnoreExistingDef(RuleRepositoryDefBase child, string cat, RuleApplicationDef dest)
        {
            //does this def exist in the destination, keep going deep
            if ((this.FindDefDeep(dest, child.Guid.ToString()) != null))
            {
                if (child.HasChildCollectionChildren == false)
                {
                    Debug.WriteLine("The child exists in the ruleapp and has no children -- Do nothing.");
                }
                else
                {
                    //traverse the children and add only those that don't exist
                    var collquery = from childcollections in child.GetAllChildCollections()
                                    select childcollections;
                    foreach (RuleRepositoryDefCollection defcollection in collquery)
                    {
                        var defquery = from RuleRepositoryDefBase items in defcollection select items;
                        foreach (var def in defquery.ToList <RuleRepositoryDefBase>())
                        {
                            IgnoreExistingDef(def, cat, dest);
                        }
                    }
                }
            }
            else
            {
                if (child.AssignedCategories.Contains(cat))
                {
                    RuleRepositoryDefBase destParent = this.FindDefDeep(dest, child.Parent.Guid.ToString());
                    RuleRepositoryDefBase copy       = child.CopyWithSameGuids();
                    child.SetParent(null);
                    if (destParent.AuthoringElementTypeName != "Rule Set")
                    {
                        SimpleRuleDef simpleParent = (SimpleRuleDef)destParent;
                        simpleParent.SubRules.Add(child);
                    }
                    else
                    {
                        destParent.ThisRuleSet.Rules.Add(child);
                    }

                    //Debug.WriteLine("----Just add it --- " + child.Name + " Parent in dest: " + destParent.Name);
                }
            }
        }