Reactions to story from Zen and the art of Castle maintenance

Reactions / posts that link to this post

  • Photo of sradack

    Registering MonoRail Extensions Programatically

    http://sradack.blogspot.com/2008/05/registering-monorail-ext...
    108 days ago in Practical Software Development · No authority yet

    Hammett inspired me to switch from XML configuration to programmatic configuration of MonoRail with this blog post. But he didn't discuss how to configure MonoRail extensions. I searched around through the source and came up with this solution: public void Configure(IMonoRailConfiguration configuration) { configuration.ViewEngineConfig.ViewPathRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Views"); configuration.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(NVelocityViewEngine), false)); configuration.ConfigurationSection = new MutableConfiguration("monorail"); configuration.ConfigurationSection.Children.Add( new MutableConfiguration("exception") .CreateChild("exceptionHandler") .Attribute("type", typeof(EmailHandler).AssemblyQualifiedName) .Attribute("mailTo", "to@email.com") .Attribute("mailFrom", "from@email.com")); configuration.ExtensionEntries.Add( new ExtensionEntry(typeof(ExceptionChainingExtension), new MutableConfiguration(""))); } This code sets up the EmailHandler that comes with MonoRail.