protected virtual void OnControllerNotFound(ControllerNotFoundEventArgs e) { EventHandler <ControllerNotFoundEventArgs> handler = ControllerNotFound; if (handler != null) { handler(this, e); } }
/// <summary> /// get mvc controller type of controller id /// </summary> /// <param name="controllerId"></param> /// <returns></returns> public Type GetControllerType(string key) { if (StringUtil.IsNullOrEmpty(key)) { return(null); } key = key.ToLowerInvariant(); string sitekey = JContext.Current.Area.AreaKey; if (key.Contains(":")) { string[] ar = StringUtil.Split(key, ":", true, true); sitekey = ar[0]; key = ar[1]; } if (controllerTypes.ContainsKey(sitekey)) { Dictionary <string, Type> types = controllerTypes[sitekey]; if (types.ContainsKey(key)) { return(types[key]); } } // get controller from root site Dictionary <string, Type> defaultControllers = null; if (controllerTypes.ContainsKey(AreaConfig.Instance.AreaKey)) { defaultControllers = controllerTypes[AreaConfig.Instance.AreaKey]; } if (defaultControllers != null && defaultControllers.ContainsKey(key)) { return(defaultControllers[key]); } ControllerNotFoundEventArgs e = new ControllerNotFoundEventArgs() { ControllerId = key }; OnControllerNotFound(e); return(e.ControllerType); }
protected virtual void OnControllerNotFound(ControllerNotFoundEventArgs e) { EventHandler<ControllerNotFoundEventArgs> handler = ControllerNotFound; if (handler != null) { handler(this, e); } }
/// <summary> /// get mvc controller type of controller id /// </summary> /// <param name="controllerId"></param> /// <returns></returns> public Type GetControllerType(string key) { if (StringUtil.IsNullOrEmpty(key)) return null; key = key.ToLowerInvariant(); string sitekey = JContext.Current.Area.AreaKey; if (key.Contains(":")) { string[] ar = StringUtil.Split(key, ":", true, true); sitekey = ar[0]; key = ar[1]; } if (controllerTypes.ContainsKey(sitekey)) { Dictionary<string, Type> types = controllerTypes[sitekey]; if (types.ContainsKey(key)) return types[key]; } // get controller from root site Dictionary<string, Type> defaultControllers = null; if (controllerTypes.ContainsKey(AreaConfig.Instance.AreaKey)) defaultControllers = controllerTypes[AreaConfig.Instance.AreaKey]; if (defaultControllers != null && defaultControllers.ContainsKey(key)) return defaultControllers[key]; ControllerNotFoundEventArgs e = new ControllerNotFoundEventArgs() { ControllerId = key }; OnControllerNotFound(e); return e.ControllerType; }