public void Extract(IControl control) { var name = string.IsNullOrWhiteSpace(ComponentName) ? Name : Name + "|" + ComponentName; if (!AutoValues.TryGetValue(name, out var value)) { value = new AutoValue { Name = name, }; AutoValues.Add(name, value); } value.ControlUniqueId = control.ControlUniqueId; control.ControlUniqueId = null; value.PublishOrderIndex = control.PublishOrderIndex.GetValueOrDefault(); control.PublishOrderIndex = null; if (control.Template.Id == @"http://microsoft.com/appmagic/Component") { // Only remove version for Templates. value.TemplateLastModified = control.Template.LastModifiedTimestamp; control.Template.LastModifiedTimestamp = null; value.TemplateComponentDefinitionLastModified = control.Template.ComponentDefinitionInfo.LastModifiedTimestamp; control.Template.ComponentDefinitionInfo.LastModifiedTimestamp = null; value.TemplateVersion = control.Template.Version; control.Template.Version = null; } }
public bool Extract(Rule rule) { if (!JsRulesHandled.Contains(rule.Property)) { return(false); } if (!AutoValues.TryGetValue(Name, out var value)) { value = new AutoValue { Name = Name, }; AutoValues.Add(Name, value); } switch (rule.Property) { case "ZIndex": value.ZIndex = rule.InvariantScript; break; default: throw new Exception($"Rule Property {rule.Property} not defined for AutoValueExtractor.Extract"); } rule.InvariantScript = "AutoValue"; return(true); }
public string Serialize() { var value = new AutoValues { Values = AutoValues.OrderBy(v => v.Key).Select(v => v.Value).ToList() }; return(value.Serialize(Formatting.Indented)); }
public void Inject(IControl control, string controlPath) { var name = string.Join(Environment.NewLine, Path.GetRelativePath(RootCodePath, Path.GetDirectoryName(controlPath)).Split(new[] { Path.DirectorySeparatorChar })); name = string.IsNullOrWhiteSpace(ComponentName) ? name : name + "|" + ComponentName; if (!AutoValues.TryGetValue(name, out var value)) { throw new KeyNotFoundException($"Unable to find auto value for rule {control.Name} at {controlPath}"); } control.ControlUniqueId = value.ControlUniqueId; control.PublishOrderIndex = value.PublishOrderIndex; if (control.Template.Id == @"http://microsoft.com/appmagic/Component") { // Only remove version for Templates. control.Template.Version = value.TemplateVersion; control.Template.LastModifiedTimestamp = value.TemplateLastModified; control.Template.ComponentDefinitionInfo.LastModifiedTimestamp = value.TemplateComponentDefinitionLastModified; } }
public void Inject(Rule rule, string controlPath) { if (!JsRulesHandled.Contains(rule.Property)) { return; } var name = string.Join(Environment.NewLine, Path.GetRelativePath(RootCodePath, Path.GetDirectoryName(controlPath)).Split(new[] { Path.DirectorySeparatorChar })); if (!AutoValues.TryGetValue(name, out var value)) { throw new KeyNotFoundException($"Unable to find auto value for rule {rule.Property} at {controlPath}"); } switch (rule.Property) { case "ZIndex": rule.InvariantScript = value.ZIndex; break; default: throw new Exception($"Rule Property {rule.Property} not defined for AutoValueExtractor.Inject"); } }