public static IEnumerable <IDelta> ComputeDelta(CanvasDocument parent, CanvasDocument child)
        {
            var delta = new List <IDelta>();

            foreach (var originalScreen in parent._screens)
            {
                if (child._screens.TryGetValue(originalScreen.Key, out var childScreen))
                {
                    delta.AddRange(ControlDiffVisitor.GetControlDelta(childScreen, originalScreen.Value, parent._editorStateStore));
                }
                else
                {
                    delta.Add(new RemoveControl()
                    {
                        ControlName = originalScreen.Key, ParentControlPath = ControlPath.Empty
                    });
                }
            }
            foreach (var newScreen in child._screens.Where(kvp => !parent._screens.ContainsKey(kvp.Key)))
            {
                delta.Add(new AddControl()
                {
                    Control = newScreen.Value, ControlStates = child._editorStateStore.GetControlsWithTopParent(newScreen.Key).ToDictionary(state => state.Name), ParentControlPath = ControlPath.Empty
                });
            }

            return(delta);
        }
Example #2
0
        public static IEnumerable <IDelta> GetControlDelta(BlockNode ours, BlockNode parent, EditorStateStore childStateStore, TemplateStore parentTemplateStore, TemplateStore childTemplateStore, bool isInComponent)
        {
            var visitor = new ControlDiffVisitor(childStateStore, parentTemplateStore, childTemplateStore);

            visitor.Visit(ours, new ControlDiffContext(new ControlPath(new List <string>()), parent, isInComponent));

            return(visitor._deltas);
        }
Example #3
0
        public static IEnumerable <IDelta> GetControlDelta(BlockNode ours, BlockNode parent, EditorStateStore stateStore)
        {
            var visitor = new ControlDiffVisitor(stateStore);

            visitor.Visit(ours, new ControlDiffContext()
            {
                Theirs = parent, Path = new ControlPath(new List <string>())
            });

            return(visitor._deltas);
        }
Example #4
0
        public static IEnumerable <IDelta> ComputeDelta(CanvasDocument parent, CanvasDocument child)
        {
            var delta = new List <IDelta>();

            foreach (var originalScreen in parent._screens)
            {
                if (child._screens.TryGetValue(originalScreen.Key, out var childScreen))
                {
                    delta.AddRange(ControlDiffVisitor.GetControlDelta(childScreen, originalScreen.Value, parent._editorStateStore));
                }
                else
                {
                    delta.Add(new RemoveControl()
                    {
                        ControlName = originalScreen.Key, ParentControlPath = ControlPath.Empty
                    });
                }
            }
            foreach (var newScreen in child._screens.Where(kvp => !parent._screens.ContainsKey(kvp.Key)))
            {
                delta.Add(new AddControl()
                {
                    Control = newScreen.Value, ControlStates = child._editorStateStore.GetControlsWithTopParent(newScreen.Key).ToDictionary(state => state.Name), ParentControlPath = ControlPath.Empty
                });
            }

            var childTemplatesDict = child._templates.UsedTemplates.ToDictionary(temp => temp.Name.ToLower());

            foreach (var template in child._templateStore.Contents)
            {
                if (parent._templateStore.TryGetTemplate(template.Key, out _))
                {
                    continue;
                }

                childTemplatesDict.TryGetValue(template.Key.ToLower(), out var jsonTemplate);

                delta.Add(new AddTemplate()
                {
                    Name = template.Key, Template = template.Value, JsonTemplate = jsonTemplate
                });
            }

            AddResourceDeltas(parent, child, delta);

            AddDataSourceDeltas(parent, child, delta);

            return(delta);
        }
Example #5
0
 private static void AddControlDeltas(CanvasDocument parent, CanvasDocument child, Dictionary <string, IR.BlockNode> parentControlSet, Dictionary <string, IR.BlockNode> childControlSet, bool isComponents, List <IDelta> deltas)
 {
     foreach (var originalTopParentControl in parentControlSet)
     {
         if (childControlSet.TryGetValue(originalTopParentControl.Key, out var childScreen))
         {
             deltas.AddRange(ControlDiffVisitor.GetControlDelta(childScreen, originalTopParentControl.Value, child._editorStateStore, parent._templateStore, child._templateStore, isComponents));
         }
         else
         {
             deltas.Add(new RemoveControl(ControlPath.Empty, originalTopParentControl.Key, isComponents));
         }
     }
     foreach (var newScreen in childControlSet.Where(kvp => !parentControlSet.ContainsKey(kvp.Key)))
     {
         deltas.Add(new AddControl(ControlPath.Empty, newScreen.Value, child._editorStateStore.GetControlsWithTopParent(newScreen.Key).ToDictionary(state => state.Name), isComponents));
     }
 }