public static bool ApplyChange(BlockNode block, ControlPath path, string property, string expression, bool wasRemoved) { var visitor = new ChangePropertyVisitor(property, expression, wasRemoved); visitor.Visit(block, path); return(visitor._success); }
public void Apply(CanvasDocument document) { var topParentName = ControlPath.Current; if (document._screens.TryGetValue(topParentName, out var blockNode)) { ChangePropertyVisitor.ApplyChange(blockNode, ControlPath.Next(), PropertyName, Expression, WasRemoved); return; } if (document._components.TryGetValue(topParentName, out blockNode)) { ChangePropertyVisitor.ApplyChange(blockNode, ControlPath.Next(), PropertyName, Expression, WasRemoved); return; } // Throw here? what does an error look like in this scenario }
public void Apply(CanvasDocument document) { var topParentName = ControlPath.Current; if (document._screens.TryGetValue(topParentName, out var blockNode)) { if (!ChangePropertyVisitor.ApplyChange(blockNode, ControlPath.Next(), PropertyName, _expression, _wasRemoved)) { return; } } if (document._components.TryGetValue(topParentName, out blockNode)) { if (!ChangePropertyVisitor.ApplyChange(blockNode, ControlPath.Next(), PropertyName, _expression, _wasRemoved)) { return; } if (document._templateStore.TryGetTemplate(topParentName, out var updatableTemplate)) { var customProps = updatableTemplate.CustomProperties.ToDictionary(prop => prop.Name); if (_wasRemoved) { customProps.Remove(PropertyName); } else if (_customProperty != null) { customProps[PropertyName] = _customProperty; } else { return; } updatableTemplate.CustomProperties = customProps.Values.ToArray(); } } }