public void RegisterController(Type type, bool UseThreadPool = true)
{
// Create a factory for it
var rm = new ControllerFactory(this, type, UseThreadPool);
var cleanName = CleanControllerName(type.Name);
// Map all it's routes
bool any_routes = false;
foreach (HttpControllerAttribute attr in type.GetCustomAttributes(typeof(HttpControllerAttribute), false))
{
if (attr.pattern != null)
Application.Route(attr.pattern, rm);
else
Application.Route("/" + cleanName, rm);
any_routes = true;
}
// Map default route if not specified by at least one attribute
if (!any_routes)
{
Application.Route("/" + cleanName, rm);
}
// Register fully qualified name eg: "MyProject.Controllers.HomeController"
ControllerTypes.Add(type.FullName, type);
// Register normal name eg: "HomeController"
ControllerTypes.Add(type.Name, type);
// Register shortened name eg: "Home"
if (cleanName != type.Name)
ControllerTypes.Add(cleanName, type);
}