using System; using System.Globalization; namespace mustache { /// /// Generates text by substituting an object's values for placeholders. /// public sealed class Generator { private readonly IGenerator _generator; /// /// Initializes a new instance of a Generator. /// /// The text generator to wrap. internal Generator(IGenerator generator) { _generator = generator; } /// /// Gets the text that is generated for the given object. /// /// The object to generate the text with. /// The text generated for the given object. public string Render(object source) { return render(CultureInfo.CurrentCulture, source); } /// /// Gets the text that is generated for the given object. /// /// The format provider to use. /// The object to generate the text with. /// The text generated for the given object. public string Render(IFormatProvider provider, object source) { if (provider == null) { provider = CultureInfo.CurrentCulture; } return render(provider, source); } private string render(IFormatProvider provider, object source) { KeyScope scope = new KeyScope(source); return _generator.GetText(provider, scope); } } }