Пример #1
0
 public void ReadStylesTest()
 {
     var reader =
         new TemplateReader(
             @"C:\Users\Sunny\Documents\GitHub\mdocwriter\MDocWriter.WinFormMain\bin\Debug\templates",
             Template.TemplateFileSearchPattern);
     var templateContent = reader.GetTemplateContent(reader.Templates.First());
     var image           = reader.GetPreviewImage(reader.Templates.First());
 }
Пример #2
0
        private string Transform(IEnumerable <KeyValuePair <string, string> > parameters)
        {
            var templateReader = new TemplateReader();
            var template       = templateReader.GetTemplate(this.document.TemplateId);

            if (template != null)
            {
                var templateContent = templateReader.GetTemplateContent(template);
                foreach (var kvp in parameters)
                {
                    if (templateContent.IndexOf(kvp.Key, StringComparison.Ordinal) > 0)
                    {
                        templateContent = templateContent.Replace(kvp.Key, kvp.Value);
                    }
                }
                return(templateContent);
            }
            var keyValuePairs = parameters as KeyValuePair <string, string>[] ?? parameters.ToArray();

            return(keyValuePairs.Any(p => p.Key.Equals(Template.MacroDocumentBody))
                       ? keyValuePairs.First(p => p.Key.Equals(Template.MacroDocumentBody)).Value
                       : null);
        }