示例#1
0
        /// <summary>
        /// 构造填充映射类集合 填充List委托
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="type">要填充的类型</param>
        /// <returns></returns>
        public static DegFullMapListNoT CreateDegFullMapList(IDataReader reader, Type type)
        {
            //判断是否已经存在该类型的动态方法
            Delegate degMethod;

            if (_idiFullMapList_noT.TryGetValue(type.FullName, out degMethod))
            {
                return((DegFullMapListNoT)degMethod);
            }

            DegFullMapListNoT deg = null;

            //构造填充方法
            DynamicMethod method = FullDataHelper.CreateFullListMethod(reader, type, true, false);

            //为动态方法构造调用委托
            deg = (DegFullMapListNoT)method.CreateDelegate(typeof(DegFullMapListNoT));
            if (!_idiFullMapList_noT.ContainsKey(type.FullName))
            {
                _idiFullMapList_noT.Add(type.FullName, deg);
            }
            return(deg);
        }
示例#2
0
        /// <summary>
        /// 构造自定义类 填充List委托
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static DegFullCustomList <T> CreateDegFullCustomList <T>(IDataReader reader)
        {
            string key = string.Format("{0}{1}", typeof(T).FullName, FullDataHelper.GetDataReaderInfo(reader));

            Delegate degMethod;

            if (_idiFullCustomList.TryGetValue(key, out degMethod))
            {
                return((DegFullCustomList <T>)degMethod);
            }

            DegFullCustomList <T> deg = null;

            //构造填充方法
            DynamicMethod method = FullDataHelper.CreateFullListMethod(reader, typeof(T), false);

            //为动态方法构造调用委托
            deg = (DegFullCustomList <T>)method.CreateDelegate(typeof(DegFullCustomList <T>));
            if (!_idiFullCustomList.ContainsKey(key))
            {
                _idiFullCustomList.TryAdd(key, deg);
            }
            return(deg);
        }
示例#3
0
        /// <summary>
        /// 构造动态类 填充List委托
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static DegFullDynamicList CreateDegFullDynamicList(IDataReader reader)
        {
            Type type = FullDataHelper.CreateType(reader);

            DegFullDynamicList degMethod;

            if (_idiFullDynamicList.TryGetValue(type.FullName, out degMethod))
            {
                return(degMethod);
            }

            DegFullDynamicList deg = null;

            //构造填充方法
            DynamicMethod method = FullDataHelper.CreateFullListMethod(reader, type, false);

            //为动态方法构造调用委托
            deg = (DegFullDynamicList)method.CreateDelegate(typeof(DegFullDynamicList));
            if (!_idiFullDynamicList.ContainsKey(type.FullName))
            {
                _idiFullDynamicList.TryAdd(type.FullName, deg);
            }
            return(deg);
        }
示例#4
0
        /// <summary>
        /// 构造填充映射类集合 填充List委托
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static DegFullMapList <T> CreateDegFullMapList <T>(IDataReader reader)
        {
            //判断是否已经存在该类型的动态方法
            Type     type = typeof(T);
            Delegate degMethod;

            if (_idiFullMapList.TryGetValue(type.FullName, out degMethod))
            {
                return((DegFullMapList <T>)degMethod);
            }

            DegFullMapList <T> deg = null;

            //构造填充方法
            DynamicMethod method = FullDataHelper.CreateFullListMethod(reader, typeof(T), true);

            //为动态方法构造调用委托
            deg = (DegFullMapList <T>)method.CreateDelegate(typeof(DegFullMapList <T>));
            if (!_idiFullMapList.ContainsKey(type.FullName))
            {
                _idiFullMapList.TryAdd(type.FullName, deg);
            }
            return(deg);
        }