Custom names for types/namespaces

Oct 27, 2011 at 10:42 AM

Hello,

first of all thanks for the great job you have done with this library!

I would need to use custom names for some of the types and namespaces of my web application and I am wondering if McvCodeRouting supports this scenario. Basically, I would need to map a controller with a name like this:

TestApp.Controllers.MyCoolNamespace.MyController

To an url like this:

/my-cool-namespace/my-controller


I hoped that the RouteFormatter settings would allow me to do that but it seems that its support is limited to a simple casing-change scenario only.
Unfortunately, the following code throws an exception (Only case formatting is currently supported for Namespace route segments).

 

 

            routes.MapCodeRoutes(
               rootNamespace: typeof(Controllers.HomeController).Namespace,
               settings: new CodeRoutingSettings
               {
                   RouteFormatter = (segment, segmentType) =>
                    {
                        switch (segmentType)
                        {
                            case RouteSegmentType.Namespace:
                                {
                                    if (segment == "MyCoolNamespace")
                                    {
                                        return "my-cool-namespace";
                                    }

                                    break;
                                }
                        }

                        return segment;
                    }
               }


Am I missing something?

Thank you so much for your help.
Cheers! 

 

Coordinator
Oct 27, 2011 at 4:00 PM

What you are trying to do is currently not supported, but it's something I intend to work on in the future. Stay tuned.

Coordinator
Dec 11, 2011 at 9:33 PM

This is now supported (in the latest revision) for namespace segments. Next I'll be working on the support for controller segments.

Coordinator
Dec 16, 2011 at 4:53 AM

Ditto for controller segments, coming in the next release.

Dec 16, 2011 at 7:53 AM

Thanks a lot!

In the meanwhile, however, I've started a new MVC routing extension project on my own, built from scratch; so, unfortunately, I don't have the time to check the bounty of your new additions although I am sure they rock like everything else on this project.

Thanks again.
Cheers.