Beispiel #1
0
        /// <summary>
        /// Gets the instance of route handler.
        /// </summary>
        /// <param name="route">The route.</param>
        /// <returns></returns>
        /// <exception cref="System.ApplicationException"></exception>
        private static IRouteHandler GetInstanceOfRouteHandler(RouteConfigElement route)
        {
            IRouteHandler routeHandler;

            if (string.IsNullOrEmpty(route.RouteHandlerType))
            {
                routeHandler = new MvcRouteHandler();
            }
            else
            {
                try
                {
                    var routeHandlerType = Type.GetType(route.RouteHandlerType);
                    routeHandler = Activator.CreateInstance(routeHandlerType) as IRouteHandler;
                }
                catch (Exception exception)
                {
                    throw new ApplicationException(
                              string.Format("Can not create an instace of IRouteHandler {0}", route.RouteHandlerType), exception);
                }
            }

            return(routeHandler);
        }
Beispiel #2
0
 /// <summary>
 /// Gets the defaults.
 /// </summary>
 /// <param name="route">The route.</param>
 /// <returns></returns>
 private static RouteValueDictionary GetDefaults(RouteConfigElement route)
 {
     return(GetDictionaryFromAttributes(route.Defaults.Attributes));
 }