Example #1
0
        /// <summary>
        /// Validates if a template is valid
        /// </summary>
        /// <param name="code">Code to validate</param>
        /// <param name="renderingEngine">Rendering engine that is used</param>
        /// <returns>Validated template</returns>
        public ExportTemplateValidationResult ValidateTemplate(string code, ExportTemplateRenderingEngine renderingEngine)
        {
            if (!_renderingEngine.ContainsKey(renderingEngine))
            {
                return(new ExportTemplateValidationResult
                {
                    IsValid = false
                });
            }

            return(_renderingEngine[renderingEngine].ValidateTemplate(code));
        }
        /// <summary>
        /// Returns the Export Template Placeholders for a Template Type
        /// </summary>
        /// <param name="templateType">Template Type</param>
        /// <param name="renderingEngine">Rendering engine</param>
        /// <returns>Export Template Placeholder</returns>
        public List <ExportTemplatePlaceholder> GetExportTemplatePlaceholdersForType(TemplateType templateType, ExportTemplateRenderingEngine renderingEngine)
        {
            if (!_renderers.ContainsKey(renderingEngine))
            {
                throw new KeyNotFoundException(string.Format("Unknown rendering engine {0} for Condition {1}", renderingEngine.ToString(), _templateType.ToString()));
            }

            return(_renderers[renderingEngine].GetExportTemplatePlaceholdersForType(templateType));
        }
Example #3
0
        /// <summary>
        /// Returns the placeholders for an action
        /// </summary>
        /// <param name="templateType">Template type</param>
        /// <param name="renderingEngine">Rendering engine</param>
        /// <returns>Placeholders</returns>
        private List <ExportTemplatePlaceholder> GetPlaceholdersForAction(TemplateType templateType, ExportTemplateRenderingEngine renderingEngine)
        {
            List <ExportTemplatePlaceholder> placeholders = new List <ExportTemplatePlaceholder>();

            // Read template type for base placeholders from template rendering engine to allow mixed mode
            ExportTemplate template = _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleAction).Result;

            if (!_renderers.ContainsKey(template.RenderingEngine))
            {
                throw new KeyNotFoundException(string.Format("Unknown rendering engine {0} for ActionNode", renderingEngine.ToString()));
            }

            placeholders.AddRange(_renderers[template.RenderingEngine].GetPlaceholdersForTemplate(templateType));

            foreach (ActionRendererDispatcher curRenderer in _actionRenderes.Values)
            {
                if (curRenderer.HasPlaceholdersForTemplateType(templateType))
                {
                    placeholders.AddRange(curRenderer.GetExportTemplatePlaceholdersForType(templateType, renderingEngine));
                }
            }

            return(placeholders);
        }
Example #4
0
        /// <summary>
        /// Returns the placeholders for a template
        /// </summary>
        /// <param name="templateType">Template Type</param>
        /// <param name="renderingEngine">Rendering engine</param>
        /// <returns>List of template placeholders</returns>
        public List <ExportTemplatePlaceholder> GetPlaceholdersForTemplate(TemplateType templateType, ExportTemplateRenderingEngine renderingEngine)
        {
            if (!HasPlaceholdersForTemplateType(templateType))
            {
                return(new List <ExportTemplatePlaceholder>());
            }

            if (templateType == TemplateType.TaleAction)
            {
                if (!_renderers.ContainsKey(renderingEngine))
                {
                    throw new KeyNotFoundException(string.Format("Unknown rendering engine {0} for ActionNode", renderingEngine.ToString()));
                }

                return(_renderers[renderingEngine].GetPlaceholdersForTemplate(templateType));
            }

            return(GetPlaceholdersForAction(templateType, renderingEngine));
        }
Example #5
0
        /// <summary>
        /// Returns the Export Template Placeholders for a Template Type
        /// </summary>
        /// <param name="templateType">Template Type</param>
        /// <param name="renderingEngine">Rendering engine</param>
        /// <returns>Export Template Placeholder</returns>
        public List <ExportTemplatePlaceholder> GetExportTemplatePlaceholdersForType(TemplateType templateType, ExportTemplateRenderingEngine renderingEngine)
        {
            // Since project and export settings are not required for resolving placeholders the renderes are setup without loading the data
            _curProject = _cachedDbAccess.GetUserProject().Result;
            SetupStepRenderes();

            List <ExportTemplatePlaceholder> placeholders = new List <ExportTemplatePlaceholder>();

            foreach (IExportDialogStepRenderer curRenderer in _stepRenderers)
            {
                placeholders.AddRange(curRenderer.GetPlaceholdersForTemplate(templateType, renderingEngine));
            }

            placeholders.AddRange(_conditionRenderer.GetExportTemplatePlaceholdersForType(templateType, renderingEngine));

            return(placeholders);
        }
Example #6
0
        /// <summary>
        /// Returns the Export Template Placeholders for a Template Type
        /// </summary>
        /// <param name="templateType">Template Type</param>
        /// <param name="renderingEngine">Rendering engine</param>
        /// <returns>Export Template Placeholder</returns>
        public List <ExportTemplatePlaceholder> GetExportTemplatePlaceholdersForType(TemplateType templateType, ExportTemplateRenderingEngine renderingEngine)
        {
            List <ExportTemplatePlaceholder> placeholders = new List <ExportTemplatePlaceholder>();

            foreach (ConditionRendererDispatcher curRenderer in _elementRenderes.Values)
            {
                if (curRenderer.HasPlaceholdersForTemplateType(templateType))
                {
                    placeholders.AddRange(curRenderer.GetExportTemplatePlaceholdersForType(templateType, renderingEngine));
                }
            }

            return(placeholders);
        }
Example #7
0
        /// <summary>
        /// Fills the placeholders of a code
        /// </summary>
        /// <param name="templateType">Template Type</param>
        /// <param name="code">Code to fill</param>
        /// <param name="data">Export Data</param>
        /// <param name="renderingEngine">Rendering Engine</param>
        /// <returns>Filled Code</returns>
        public async Task <ExportPlaceholderFillResult> FillPlaceholders(TemplateType templateType, string code, ExportObjectData data, ExportTemplateRenderingEngine renderingEngine)
        {
            if (!_renderingEngine.ContainsKey(renderingEngine))
            {
                throw new KeyNotFoundException(string.Format("Unknown rendering engine {0}", renderingEngine.ToString()));
            }

            return(await _renderingEngine[renderingEngine].FillPlaceholders(templateType, code, data));
        }