zoukankan      html  css  js  c++  java
  • 使用Assembly生成带参数的泛型实例

    public class DataAccess<T>
    {
            protected static readonly string _path = ConfigurationSettings.AppSettings["WebDAL"];

            public static IDAL.ITreeTable<T> CreatTreeTable(string tableName, string idName, string parentIdName, string displayOrderName)
            {
                if (string.IsNullOrEmpty(tableName) || string.IsNullOrEmpty(idName) || string.IsNullOrEmpty(parentIdName))
                    throw new Exception("tableName,idName,parentIdName,displayOrder必须设置.");

                string className = _path + ".TreeTable`1[[" + typeof(T).FullName + "," + typeof(T).Assembly.ToString() + "]]";
                Assembly assembly = Assembly.Load(_path);
                Type t = assembly.GetType(className);
                object[] args = new object[4];
                args[0] = tableName;
                args[1] = idName;
                args[2] = parentIdName;
                args[3] = displayOrderName;
                return (IDAL.ITreeTable<T>)Activator.CreateInstance(t, args);
            }
    }

  • 相关阅读:
    ci上传图片
    Mac下使用svn命令
    linux 下svn忽略文件
    thinkphp5 隐藏入口和支持pathinfo
    ci tp重定向
    php命名空间
    thinkphp5学习记录一
    Mac下安装homebrew
    使用iTerm2快捷连接SSH
    摄影基础
  • 原文地址:https://www.cnblogs.com/lswweb/p/1035997.html
Copyright © 2011-2022 走看看