Although it's not directly possible you can use IDictionary for that.
internal class MyProvider : Dictionary<string, string>, IDictionary
{
bool IDictionary.Contains(object name)
{
return true;
}
public object this[object key]
{
get { return "Value for " + key; }
set { }
}
}
Assert.AreEqual("Value for TheKey", Template.Create("[TheKey]").DataFrom(new MyProvider()).Render());
Converting this to support lambda is rather trivial.
I know this is a bit of a hack, and I think we'll expose ITemplateDataProvider interface in the next release:
internal class CustomProvider : ITemplateDataProvider
{
public object GetValue(string key)
{
return "Value for " + key; }
public bool HasValue(string name)
{
return true;
}
}
Assert.AreEqual("Value for TheKey", Template.Create("[TheKey]").DataFrom(new CustomProvider()).Render());