public static bool IsWebServerObject(object obj) { Type t = obj as Type; if (t != null) { return(PhpTypeAttribute.IsPhpType(t)); } return(obj is IPhpType || obj is IWebServerProgrammingSupport || obj is IWebPage); }
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); }