public Message RenderMailMessage(String templateName, IDictionary parameters, bool doNotApplyLayout)
{
if (HttpContext.Current == null)
{
throw new RailsException("No http context available");
}
if (logger.IsDebugEnabled)
{
logger.DebugFormat("Rendering email message. Template name {0}", templateName);
}
IRailsEngineContext context = EngineContextModule.ObtainRailsEngineContext(HttpContext.Current);
Controller controller = context.CurrentController;
if (controller == null)
{
throw new RailsException("No controller found on the executing activity");
}
if (parameters != null && parameters.Count != 0)
{
foreach(DictionaryEntry entry in parameters)
{
controller.PropertyBag.Add(entry.Key, entry.Value);
}
}
try
{
return RenderMailMessage(templateName, context, controller, doNotApplyLayout);
}
finally
{
if (parameters != null && parameters.Count != 0)
{
foreach(DictionaryEntry entry in parameters)
{
controller.PropertyBag.Remove(entry.Key);
}
}
}
}