public static MethodInfo[] GetWebMethods(bool isStatic, object obj) { bool includeClient = MethodInfoWebClient.IsWebClientObject(obj); bool includeServer = MethodInfoWebClient.IsWebServerObject(obj); List <MethodInfo> lst = new List <MethodInfo>(); BindingFlags flags; if (isStatic) { flags = BindingFlags.Public | BindingFlags.Static; } else { flags = BindingFlags.Public | BindingFlags.Instance; } Type t = obj as Type; if (t == null) { t = obj.GetType(); } bool isPhp = PhpTypeAttribute.IsPhpType(t); bool isJs = JsTypeAttribute.IsJsType(t); MethodInfo[] ret = t.GetMethods(flags); if (ret != null && ret.Length > 0) { for (int i = 0; i < ret.Length; i++) { if (!ret[i].IsSpecialName) { if (VPLUtil.IsNotForProgramming(ret[i])) { continue; } bool include = false; if (isPhp) { if (WebServerMemberAttribute.IsServerMethod(ret[i])) { lst.Add(ret[i]); } continue; } if (isJs) { if (WebClientMemberAttribute.IsClientMethod(ret[i])) { lst.Add(ret[i]); } continue; } if (includeClient) { object[] objs = ret[i].GetCustomAttributes(typeof(WebClientMemberAttribute), true); if (objs != null && objs.Length > 0) { include = true; } } if (!include) { if (includeServer) { object[] objs = ret[i].GetCustomAttributes(typeof(WebServerMemberAttribute), true); if (objs != null && objs.Length > 0) { include = true; } } } if (include) { lst.Add(ret[i]); } } } } ret = lst.ToArray(); return(ret); }
public override void LoadNextLevel(TreeViewObjectExplorer tv, TreeNodeObject parentNode) { if (tv != null && tv.RootId != null && parentNode != null && parentNode.OwnerPointer != null && parentNode.OwnerPointer.RootPointer != null) { if (tv.Project != null && (tv.Project.ProjectType == EnumProjectType.WebAppPhp || tv.Project.ProjectType == EnumProjectType.WebAppAspx)) { if (tv.RootId.ClassId != parentNode.OwnerPointer.RootPointer.ClassId) { return; } } } IObjectPointer objRef = parentNode.OwnerPointer; TreeNodeClassRoot topClass = parentNode.TopLevelRootClassNode; bool forPhp = false; if (tv.Project != null) { forPhp = (tv.Project.ProjectType == EnumProjectType.WebAppPhp); } Dictionary <UInt32, IAction> actions = null; if (topClass != null) { if (!topClass.StaticScope) { actions = topClass.GetActions(); } } else { TreeNodeClassType rootType = parentNode.TopLevelNode as TreeNodeClassType; if (rootType != null) { actions = rootType.GetActions(); } } SortedList <string, TreeNode> newNodes = new SortedList <string, TreeNode>(); HtmlElement_BodyBase heb = (HtmlElement_BodyBase)parentNode.OwnerIdentity; MethodInfo[] mifs = heb.GetType().GetMethods(); if (mifs != null) { for (int i = 0; i < mifs.Length; i++) { if (parentNode.SelectionTarget == EnumObjectSelectType.Object) { if (mifs[i].ReturnType.Equals(typeof(void))) { continue; } ParameterInfo[] ps = mifs[i].GetParameters(); if (ps != null && ps.Length > 0) { continue; } } if (VPLUtil.IsNotForProgramming(mifs[i])) { continue; } if (!WebClientMemberAttribute.IsClientMethod(mifs[i]) && !WebServerMemberAttribute.IsServerMethod(mifs[i])) { continue; } MethodInfoPointer mp = new MethodInfoPointer(); mp.Owner = objRef; mp.SetMethodInfo(mifs[i]); int c; TreeNodeMethod nodeMethod = new TreeNodeMethod(ForStatic, mp); string key = mp.GetMethodSignature(out c); TreeNode nodeExist; if (newNodes.TryGetValue(key, out nodeExist)) { TreeNodeMethod mnd = (TreeNodeMethod)nodeExist; if (mnd.MethodInformation.DeclaringType.Equals(mnd.MethodInformation.ReflectedType)) { key = key + " - " + mifs[i].DeclaringType.Name; newNodes.Add(key, nodeMethod); } else { if (mifs[i].DeclaringType.Equals(mifs[i].ReflectedType)) { newNodes[key] = nodeMethod; key = key + " - " + mnd.MethodInformation.DeclaringType.Name; newNodes.Add(key, mnd); } else { key = key + " - " + mifs[i].DeclaringType.Name; newNodes.Add(key, nodeMethod); } } } else { newNodes.Add(key, nodeMethod); } //load actions if (actions != null) { bool bHasActions = false; foreach (IAction a in actions.Values) { ActionClass ac = a as ActionClass; if (ac != null) { MethodPointer mp0 = ac.ActionMethod as MethodPointer; if (mp0 != null) { if (mp0.IsSameObjectRef(mp)) { bHasActions = true; break; } } } } if (bHasActions) { nodeMethod.ShowActionIcon(); } } } parentNode.AddSortedNodes(newNodes); } }