Naming rule for multiple namespaces

Topics: Conventions, Extensibility
Jul 6, 2012 at 12:00 AM

(sorry for my bad english)

I have on my application the following rule:

ViewLocator.NameTransformer.AddRule
(
	@"(?<nsbefore>([A-Za-z_]\w*\.)*)(?<nsvm>ViewModel\.)(?<nsafter>([A-Za-z_]\w*\.)*)(?<basename>[A-Za-z_]\w*)(?<suffix>ViewModel$)",
	@"${nsbefore}View.${nsafter}${basename}View",
	@"([A-Za-z_]\w*\.)*ViewModel\.([A-Za-z_]\w*\.)*[A-Za-z_]\w*ViewModel$"
);

And on my project I have the folders "View" and "ViewModel" and all works fine.

I then created a folder "Help" and inside that "View" and "ViewModel" folders. Now when I create an instance of MyProject.Help.ViewModel.MyViewModel I need CM to load  MyProject.Help.View.MyView. But i still want the original behavior that is when I create MyProject.ViewModel.MyViewModel, it loads MyProject.View.MyView.

With only the above rule, when I try to activate MyProject.Help.ViewModel.MyViewModel CM shows me the message:

Cannot find view for MyProject.Help.ViewModels.MyViewModel.

I readed the documentation but to be honest I can't even say what is exactly happening in the AddRule above to be able to create a new rule (sometimes I think regular expressions are some sort of black magic :( ).

Can someone help?

thanks