Namespace Mapping

Topics: Bootstrappers & IoC, Conventions
Feb 12, 2013 at 1:36 PM
I am trying to create what I think is a simple namespace mapping, but I can't get exactly what I need.

I am trying to map the following:
ViewModels = MyCompany.MyApp.ModuleName.ViewModels.MyViewModel
Views = MyCompany.MyUI.ModuleName.Views.MyView

I can get this to work if I add a namespace mapping for MyCompany.MyApp.ModuleName.ViewModels -> MyCompany.MyUI.ModuleName.Views
But doing this means that I would need to include a mapping for every module.

I would rather do something like this:
ViewLocator.AddSubNameSpaceMapping("MyApp", "MyUI"), but I end up with a transformed view name of MyCompany.MyUI.ModuleName.ViewModels.MyView

I thought CM should change the ViewModels part of the namespace to Views automatically, but I've followed the code through and don't see where that should be happening.

I am thinking of overriding the name transformation, but I would like to do as little customization as possible so I wanted to see if there was something I am missing? Does anyone know of a better way?
Feb 12, 2013 at 4:27 PM
You should be able to use the NameTransformer to do what you want. Details are here: NameTransformer
Feb 12, 2013 at 6:21 PM
Thanks, not sure how I missed that documentation originally. I created a new rule and everything works perfectly.