示例#1
0
 private void Add(TemplateTag tag)
 {
     try { tags.Add(tag.Type, tag); }
     catch (Exception e) when(e is ArgumentException ||
                              e is ArgumentNullException ||
                              e is NotSupportedException)
     {
         throw new ArgumentException($"There was a problem when inserting tag for {tag.Type}");
     }
 }
示例#2
0
    public void TestFill(string templateString, string content, string expected)
    {
        var tag = new TemplateTag
        {
            Template = templateString
        };

        var filler = new TemplateFiller();

        var result = filler.Fill(tag, content);

        Assert.Equal(expected, result);
    }
示例#3
0
    private TemplateTag GetTagWriterFor(string fileName)
    {
        try
        {
            var     template = new TemplateTag();
            TagType type     = GetTagTypeForString(fileName);

            template.Type = type;

            return(template);
        }
        catch (ArgumentException ex)
        {
            string value = $"There was an exception when converting template file names into template types. {fileName} did not convert cleanly";
            Console.WriteLine(value);
            throw (new ArgumentException(value, ex));
        }
    }
 public override string ApplyTemplate(TemplateTag tpl)
 {
     return tpl.Apply(this.Path);
 }
示例#5
0
 public string Fill(TemplateTag tag, string content)
 {
     return(tag.Template.Replace("{{}}", content));
 }
示例#6
0
 public void AddTag(TemplateTag templateTag)
 {
     _templateTags[templateTag.Tag] = templateTag;
 }
示例#7
0
 public void AddTag(TemplateTag templateTag)
 {
     _templateTags[templateTag.Tag] = templateTag;
 }
 public override string ApplyTemplate(TemplateTag tpl)
 {
     return(tpl.Apply(this.Path));
 }