Castle Contrib - Screencast Five

23 Apr 2007

This screencast takes a break from the theme of the past few in the series and examines two of the projects within Castle's Contrib project - CodeGenerator and ActiveWriter.

The Monday morning blues mean this cast is a little less fluent than the others, but I hope you find it useful. Read on for some of the code snippets used in the screencast.

Here's the snippet you need to add to your .csproj file to enable the CodeGenerator:

<Import Project="$(MSBuildExtensionsPath)\Castle.Tools.CodeGenerator\Castle.Tools.CodeGenerator.targets" />

Here's the code for the AbstractController base class I use in the CodeGenerator segment:

using Castle.MonoRail.Framework;
using Castle.Tools.CodeGenerator.Services;
using CodeGeneratorTest.SiteMap;

namespace CodeGeneratorTest.Controllers
	public class AbstractController : SmartDispatcherController
		private ICodeGeneratorServices _services;

		public ICodeGeneratorServices CodeGeneratorServices
			get { return _services; }

		public RootAreaNode Site
			get { return new RootAreaNode(_services); }

		protected virtual void PerformGeneratedInitialize()
			_services = new DefaultCodeGeneratorServices(
				new DefaultControllerReferenceFactory(),
				new AspDotNetRedirectService(),
				new DefaultArgumentConversionService(),
				new DefaultRuntimeInformationService());
			_services.Controller = this;

		protected override void Initialize()


Feedback or questions on this post? Create an issue on GitHub.