private void RefreshTree() { tvMethod.BeginUpdate(); try { tvMethod.Nodes.Clear(); tvMethod.Nodes.Add("Root"); MemberInfo[] mis = FormulaBase.GetAllMembers(); for (int i = 0; i < mis.Length; i++) { object[] os = mis[i].GetCustomAttributes(false); TreeNode tn = tvMethod.Nodes[0]; foreach (object o in os) { if (o is CategoryAttribute) { TreeNode tnCategory = null; string Category = (o as CategoryAttribute).Category; for (int j = 0; j < tn.Nodes.Count; j++) { if (tn.Nodes[j].Text == Category) { tnCategory = tn.Nodes[j]; break; } } if (tnCategory == null) { tn.Nodes.Add(tnCategory = new TreeNode(Category, 0, 0)); } TreeNode tnText = new TreeNode(mis[i].Name + GetParam(mis[i]), 1, 1); tnText.Tag = mis[i]; tnCategory.Nodes.Add(tnText); } } } tvMethod.Nodes[0].Expand(); } finally { tvMethod.EndUpdate(); } }
private void Page_Load(object sender, System.EventArgs e) { string Filter = Request.QueryString["Filter"]; if (Filter != null) { Filter = Filter.ToUpper(); } MemberInfo[] mis = FormulaBase.GetAllMembers(); DataTable dtMethods = new DataTable(); dtMethods.Columns.Add("Category"); dtMethods.Columns.Add("Method"); dtMethods.Columns.Add("Parameter"); dtMethods.Columns.Add("Return"); dtMethods.Columns.Add("Description"); for (int i = 0; i < mis.Length; i++) { if (Filter == null || mis[i].Name == Filter) { object[] os = mis[i].GetCustomAttributes(false); if (os.Length > 0) { DataRow dr = dtMethods.NewRow(); if (mis[i] is MethodInfo) { MethodInfo mi = mis[i] as MethodInfo; dr["Return"] = ReplaceType(mi.ReturnType); ParameterInfo[] pis = mi.GetParameters(); string P = ""; string r = ""; for (int j = 0; j < pis.Length; j++) { if (P != "") { P += ","; } P += pis[j].Name; r += "<font color=#FF8000><B>" + pis[j].Name + "</B></font>:" + ReplaceType(pis[j].ParameterType) + "<br>"; } dr["Method"] = mis[i].Name + "(" + P + ")"; dr["Parameter"] = r; } else { PropertyInfo pi = mis[i] as PropertyInfo; dr["Method"] = pi.Name; dr["Return"] = ReplaceType(pi.PropertyType); } foreach (object o in os) { if (o is DescriptionAttribute) { dr["Description"] = Server.HtmlEncode((o as DescriptionAttribute).Description); } else if (o is CategoryAttribute) { string s = (o as CategoryAttribute).Category; string s1 = s.Substring(0, 1); if (htCategory[s1] == null) { dtMethods.Rows.Add(new object[] { s1 }); } htCategory[s1] = s; dr["Category"] = s; } } dtMethods.Rows.Add(dr); } } else { tblMsg.Visible = false; tblAllMethod.Visible = true; } } dgMethods.DataSource = new DataView(dtMethods, "1=1", "Category", DataViewRowState.CurrentRows); dgMethods.DataBind(); }