Пример #1
0
        public PlanSnapshot RebuildSnapshot()
        {
            var prev = Snapshot;

            Snapshot = new PlanSnapshot(Root, true);

            return(prev);
        }
Пример #2
0
        public LoadedPlan(PlanNodeDO root, bool isNew = false)
        {
            IsNew = isNew;
            Root  = root;

            if (isNew)
            {
                Snapshot = new PlanSnapshot();
            }
            else
            {
                RebuildSnapshot();
            }
        }
Пример #3
0
        /**********************************************************************************/

        public Changes Compare(PlanSnapshot referece)
        {
            var diff = new Changes();
            List <PropertyInfo> changedProperties = null;

            PlanNodeDO node;

            foreach (var refNodeId in _nodes)
            {
                if (!referece._nodes.TryGetValue(refNodeId.Key, out node))
                {
                    diff.Insert.Add(refNodeId.Value);
                }
                else
                {
                    if (changedProperties == null)
                    {
                        changedProperties = new List <PropertyInfo>();
                    }

                    node.CheckModified(refNodeId.Value, changedProperties);

                    if (changedProperties.Count > 0)
                    {
                        diff.Update.Add(new ChangedObject(refNodeId.Value, changedProperties));
                        changedProperties = null;
                    }
                }
            }

            foreach (var refNodeId in referece._nodes)
            {
                if (!_nodes.TryGetValue(refNodeId.Key, out node))
                {
                    diff.Delete.Add(refNodeId.Value);
                }
            }

            return(diff);
        }