public MvcDirectMethod(string controller, MethodInfo method, DirectControllerAttribute dcAttribute, DirectMethodAttribute dmAttribute) : base(method, dmAttribute) { this.Controller = controller; if (this.Controller.EndsWith("Controller")) { this.Controller = this.Controller.Substring(0, this.Controller.IndexOf("Controller", StringComparison.InvariantCultureIgnoreCase)); } this.DirectControlerAttr = dcAttribute; }
private static void GetControllerMethods(Type type, List <MvcDirectMethod> list) { var methods = type.GetMethods().Where(method => method.IsPublic && (method.ReturnType == typeof(ActionResult) || method.ReturnType.IsSubclassOf(typeof(ActionResult))) && System.Attribute.IsDefined(method, typeof(Ext.Net.DirectMethodAttribute)) ); object[] attrs = type.GetCustomAttributes(typeof(DirectControllerAttribute), true); DirectControllerAttribute dcAttr = (DirectControllerAttribute)attrs[0]; foreach (MethodInfo method in methods) { attrs = method.GetCustomAttributes(typeof(DirectMethodAttribute), true); DirectMethodAttribute dmAttr = (DirectMethodAttribute)attrs[0]; list.Add(new MvcDirectMethod(type.Name, method, dcAttr, dmAttr)); } }