枚举自定义实体
var assembly = Assembly.LoadFrom(string.Format("{0}Blackice.App.Model.dll", BaseConfig.BinnPath)); var types = assembly.GetTypes(); foreach (var t in types) { ButtonList += string.Format("<input style=\"400px;\" type=\"button\" onclick=\"CreateTable('{0}')\" value=\"创建表[{0}]\" />", t.Name); }
创建表
protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { var table = Request["t"]; CreateTable(table); } } protected void CreateTable(string tableName) { if (string.IsNullOrEmpty(tableName)) return; var name = string.Format("Blackice.App.Business.{0}", tableName); var assembly = Assembly.LoadFrom(string.Format(@"{0}Blackice.App.Business.dll", BaseConfig.BinnPath)); var t = assembly.GetType(name); var obj = t.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, new object[] {}); var blnTemp =(bool)t.InvokeMember("CreateTable", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance,null, obj, new object[] {}); var script = blnTemp ? tableName + "操作成功" : tableName + "操作失败"; Response.Write(string.Format("<script>parent.$F('status').innerHTML='{0}'</script>",script)); }