Monorail: simplify programmatic configuration

2 views
Skip to first unread message

Andre Loker

unread,
Jul 3, 2008, 3:40:50 AM7/3/08
to Castle Developer Group
Hi Group,

I recently wrote some extension methods to simplify the programmatic configuration of Monorail. For example instead of

var viewEngineConfig = configuration.ViewEngineConfig;
viewEngineConfig.VirtualPathRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "views");
viewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(AspViewEngine), true));
viewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(NVelocityViewEngine), false));

I now simply write:

configuration.ViewEngineConfig
  .SetRelativeViewDirectory("views")
  .AddViewEngine<AspViewEngine>(true)
  .AddViewEngine<NVelocityViewEngine>(false);

Another example: to use the smtp settings from the web config <smtp> section I can write:

configuration.SmtpConfig.ConfigureFromWebConfig();

(I could not find an existing facility in MR for this)

These extension methods could be easily added as normal instance methods of ViewEngineConfig and SmtpConfig. If anyone is interested, I can submit a patch. I don't even know whether there are that many "programmatic configurers".

Regards,
Andre

Hamilton Verissimo

unread,
Jul 3, 2008, 10:49:11 AM7/3/08
to castle-pro...@googlegroups.com
Cool. It would be better as methods (rather than extensions) as we
still want to support .net 2

--
Cheers,
hamilton verissimo
ham...@castlestronghold.com
http://www.castlestronghold.com/

Andre Loker

unread,
Jul 10, 2008, 5:46:29 AM7/10/08
to castle-pro...@googlegroups.com
I found the time to create a patch

http://support.castleproject.org/projects/MR/issues/view/MR-ISSUE-467

Should be completely .net 2.0 compatible (at least it compiles here)
Reply all
Reply to author
Forward
0 new messages