public static string GetScript(string className) { AjaxConfiguration config = AjaxConfiguration.GetConfig(); AjaxClass c = config.FindClass(className); if (c == null) { return(string.Empty); } StringBuilder script = new StringBuilder(); AppendClassScript(c, ref script); return(script.ToString()); }
public static string GetScript(string className, string methodName) { AjaxConfiguration config = AjaxConfiguration.GetConfig(); AjaxClass c_old = config.FindClass(className); AjaxMethod m = config.FindMethod(c_old, methodName); if (m == null) { return(string.Empty); } AjaxClass c = c_old.Clone() as AjaxClass; c.Methods.Add(m); StringBuilder script = new StringBuilder(); AppendClassScript(c, ref script); return(script.ToString()); }
private List <AjaxClass> Find() { List <AjaxClass> list = new List <AjaxClass>(); AjaxConfiguration config = AjaxConfiguration.GetConfig(); foreach (string className in _methods.Keys) { AjaxClass c = config.FindClass(className); List <string> ms = _methods[className]; if (ms.Count > 0) { AjaxClass newc = c.Clone() as AjaxClass; foreach (string methodName in _methods[className]) { AjaxMethod m = config.FindMethod(c, methodName);//.Clone ( ) as AjaxMethod; newc.Methods.Add(m); } c = newc; } list.Add(c); } if (JContext.Current.Controller != null) { Type t = JContext.Current.Controller.GetType(); AjaxClass ac = null; if (AjaxConfiguration.ControllerAjax.ContainsKey(t)) { ac = AjaxConfiguration.ControllerAjax[t]; } if (ac != null) { if (StringUtil.IsNullOrEmpty(gAjaxMethods)) { list.Add(ac); } else { List <string> methods = new List <string>(StringUtil.Split(gAjaxMethods, ",", true, true)); AjaxClass tmp = ac.Clone() as AjaxClass; tmp.Methods = ac.Methods.FindAll(delegate(AjaxMethod am) { // 通配符(*)查找 bool match = false; foreach (var item in methods) { if (item.StartsWith("*") && item.EndsWith("*")) { match = am.MethodName.Contains(item.Substring(1, item.Length - 1)); } else if (item.StartsWith("*")) { match = am.MethodName.EndsWith(item.Substring(1), StringComparison.InvariantCultureIgnoreCase); } else if (item.EndsWith("*")) { match = am.MethodName.StartsWith(item.Substring(0, item.Length - 1), StringComparison.InvariantCultureIgnoreCase); } else { match = am.MethodName.Equals(item, StringComparison.InvariantCultureIgnoreCase); } if (match) { return(true); } } return(false); }); list.Add(tmp); } } } return(list); }