public static void AddRouteAction(string name, string classType) { Type cType = Type.GetType(classType); if (cType == null) { throw new Exception(string.Format("RouteAction\r\nType {0} not found", classType)); } RouteAction action = null; try { action = (RouteAction)Activator.CreateInstance(cType); } catch (Exception ex) { throw new Exception("Fail on create RouteAction by type " + classType, ex); } lock (_routeActions) { if (_routeActions.ContainsKey(name)) { _routeActions[name] = action; } else { _routeActions.Add(name, action); } } }
/// <summary> /// Recupera a ação com de rota com base no nome informado. /// </summary> /// <param name="name"></param> /// <returns></returns> public static RouteAction GetAction(string name) { RouteAction action = null; _routeActions.TryGetValue(name, out action); return(action); }