// routing methods set private static string GetRouteValue(ControllerContext context, string key) { var logger = ObjectFactory.GetInstance<Logger>(); if (context == null) { logger.Error("[Extensions].[ControllerContextExtensions].[GetRouteValue] throwing exception ([context] == null)."); throw new ArgumentNullException("context"); } if (key == null) { logger.Error("[Extensions].[ControllerContextExtensions].[GetRouteValue] throwing exception ([key] == null)."); throw new ArgumentNullException("key"); } var result = context .With(c => c.RouteData) .With(rd => rd.Values) .With(v => v["Controller"]) .Return(c => (string)c); if (result == null) { logger.Error("[Extensions].[ControllerContextExtensions].[GetRouteValue] throwing exception ([context] does not contains value)."); throw new ArgumentException("context"); } return result; }