Created
October 13, 2017 04:07
-
-
Save BenGGolden/b047b06aea99cbdb92c0b2a821ba104e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FluentTagBuilder | |
{ | |
public TagBuilder InnerBuilder { get; private set; } | |
public FluentTagBuilder(string tagName) | |
{ | |
InnerBuilder = new TagBuilder(tagName); | |
} | |
public FluentTagBuilder AddCssClass(string cssClass) | |
{ | |
InnerBuilder.AddCssClass(cssClass); | |
return this; | |
} | |
public FluentTagBuilder GenerateId(string name) | |
{ | |
InnerBuilder.GenerateId(name); | |
return this; | |
} | |
public FluentTagBuilder MergeAttribute(string key, string value, bool replaceExisting = false) | |
{ | |
InnerBuilder.MergeAttribute(key, value, replaceExisting); | |
return this; | |
} | |
public FluentTagBuilder MergeAttributes<TKey, TValue>(IDictionary<TKey, TValue> attributes, | |
bool replaceExisting = false) | |
{ | |
InnerBuilder.MergeAttributes(attributes, replaceExisting); | |
return this; | |
} | |
public FluentTagBuilder SetInnerText(string innerText) | |
{ | |
InnerBuilder.SetInnerText(innerText); | |
return this; | |
} | |
public override string ToString() | |
{ | |
return InnerBuilder.ToString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment