internal void ApplyBeforeMsAppWriteTransforms(ErrorContainer errors) { // Update volatile documentproperties _entropy.GetProperties(_properties); // Shard templates, parse for default values var templateDefaults = new Dictionary <string, ControlTemplate>(); foreach (var template in _templates.UsedTemplates) { if (!ControlTemplateParser.TryParseTemplate(_templateStore, template.Template, _properties.DocumentAppType, templateDefaults, out _, out _)) { errors.GenericError($"Unable to parse template file {template.Name}"); throw new DocumentException(); } } // Also add Screen and App templates (not xml, constructed in code on the server) GlobalTemplates.AddCodeOnlyTemplates(_templateStore, templateDefaults, _properties.DocumentAppType); // Generate DynamicControlDefinitionJson for power apps controls foreach (var kvp in _pcfControls) { if (_templateStore.TryGetTemplate(kvp.Key, out var template)) { template.DynamicControlDefinitionJson = PcfControl.GenerateDynamicControlDefinition(kvp.Value); } else { // Validation for accidental deletion of ocf control templates. errors.ValidationError($"Could not find Pcf Control Template with name: {kvp.Key} in pkgs/PcfControlTemplates directory. " + $"If it was intentionally deleted, please delete the entry from ControlTemplates.json along with its references from source files."); } } var componentInstanceTransform = new ComponentInstanceTransform(errors); var componentDefTransform = new ComponentDefinitionTransform(errors, _templateStore, componentInstanceTransform); // Transform component definitions and populate template set of component instances that need updates foreach (var ctrl in _components) { componentDefTransform.BeforeWrite(ctrl.Value); AddComponentDefaults(ctrl.Value, templateDefaults); } var transformer = new SourceTransformer(this, errors, templateDefaults, new Theme(_themes), componentInstanceTransform, _editorStateStore, _templateStore, _entropy); foreach (var ctrl in _screens.Concat(_components)) { transformer.ApplyBeforeWrite(ctrl.Value); } RestoreAssetFilePaths(); }
internal void ApplyBeforeMsAppWriteTransforms(ErrorContainer errors) { // Update volatile documentproperties _entropy.GetProperties(_properties); // Shard templates, parse for default values var templateDefaults = new Dictionary <string, ControlTemplate>(); foreach (var template in _templates.UsedTemplates) { if (!ControlTemplateParser.TryParseTemplate(_templateStore, template.Template, _properties.DocumentAppType, templateDefaults, out _, out _)) { errors.GenericError($"Unable to parse template file {template.Name}"); throw new DocumentException(); } } // Also add Screen and App templates (not xml, constructed in code on the server) GlobalTemplates.AddCodeOnlyTemplates(_templateStore, templateDefaults, _properties.DocumentAppType); var componentInstanceTransform = new ComponentInstanceTransform(errors); var componentDefTransform = new ComponentDefinitionTransform(errors, _templateStore, componentInstanceTransform); // Transform component definitions and populate template set of component instances that need updates foreach (var ctrl in _components) { componentDefTransform.BeforeWrite(ctrl.Value); AddComponentDefaults(ctrl.Value, templateDefaults); } var transformer = new SourceTransformer(errors, templateDefaults, new Theme(_themes), componentInstanceTransform, _editorStateStore, _templateStore, _entropy); foreach (var ctrl in _screens.Concat(_components)) { transformer.ApplyBeforeWrite(ctrl.Value); } RestoreAssetFilePaths(); }