This is weird, for some reason I get the emails from threads but I
can't see them online. So this is in response to Noam's last email to
this thread.
---
Yes, unfortunately that's the only way to do it right now in v2.1
since the bits don't know anything about the new MVC2 features. The
support for MVC2 pieces will be added on v2.2 which I'm currently
working on at
http://github.com/jglozano/mvcturbine.
However, if you want to use the Area "Blade" for registration of MVC2
areas, you can do so (Will post code below). Essentially a "Blade" is
component that Turbine knows about and executes at App_Start. So what
we've done is to take the all the pieces that would typically go
inside the App_Start method and moved to a "Blade" in order to keep
all the extra clutter from App_Start from getting out of control.
Some of the clutter is the AreaRegistration pieces that are part of
the MVC2 bits.
Instead the same came accomplished with this:
public class AreaBlade : Blade, ISupportAutoRegistration {
public void AddRegistrations(AutoRegistrationList
registrationList) {
registrationList.Add(Registration.Simple<AreaRegistration>());
}
public override void Spin(IRotorContext context) {
var serviceLocator =
GetServiceLocatorFromContext(context);
var areaList = GetRegisteredAreas(serviceLocator);
if (areaList == null || areaList.Count == 0) return;
foreach (AreaRegistration registration in areaList) {
var registrationContext = new
AreaRegistrationContext(registration.AreaName, RouteTable.Routes);
var areaNamespace = registration.GetType().Namespace;
if (areaNamespace != null) {
registrationContext.Namespaces.Add(areaNamespace +
".*");
}
registration.RegisterArea(registrationContext);
}
}
public virtual IList<AreaRegistration>
GetRegisteredAreas(IServiceLocator locator) {
try {
return locator.ResolveServices<AreaRegistration>();
}
catch (Exception) {
return null;
}
}
}
All you need to do is add this class in an assembly that is referenced
by your application and Turbine automatically will register your
AreaRegistration types. Thus eliminating the need to call
AreaRegistration.RegisterAllAreas() from the App_Start.
If you feel uncomfortable with this piece, I completely understand and
like I previously mentioned, this will be added to v2.2 of MVC Turbine
so it will become a non-issue.
Thanks for checking out MVC Turbine!