Ejemplo n.º 1
0
        /// <summary>
        /// 构造自定义类 填充Object委托
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="type">要填充的类型</param>
        /// <returns></returns>
        public static DegFullCustomObjNoT CreateDegFullCustomObj(IDataReader reader, Type type)
        {
            string key = string.Format("{0}{1}", type.FullName, FullDataHelper.GetDataReaderInfo(reader));

            Delegate degMethod;

            if (_idiFullCustomObj_noT.TryGetValue(key, out degMethod))
            {
                return((DegFullCustomObjNoT)degMethod);
            }

            DegFullCustomObjNoT deg = null;
            //构造填充方法
            DynamicMethod method = FullDataHelper.CreateFullObjMethod(reader, type, false, false);

            //为动态方法构造调用委托
            deg = (DegFullCustomObjNoT)method.CreateDelegate(typeof(DegFullCustomObjNoT));
            if (!_idiFullCustomObj_noT.ContainsKey(key))
            {
                _idiFullCustomObj_noT.Add(key, deg);
            }
            return(deg);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 构造填充映射类对象 填充Object委托
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="type">要填充的类型</param>
        /// <returns></returns>
        public static DegFullMapObjNoT CreateDegFullMapObj(IDataReader reader, Type type)
        {
            //判断是否已经存在该类型的动态方法
            Delegate degMethod;

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

            DegFullMapObjNoT deg = null;

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

            //为动态方法构造调用委托
            deg = (DegFullMapObjNoT)method.CreateDelegate(typeof(DegFullMapObjNoT));
            if (!_idiFullMapObj_noT.ContainsKey(type.FullName))
            {
                _idiFullMapObj_noT.Add(type.FullName, deg);
            }
            return(deg);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 构造动态类 填充Object委托
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static DegFullDynamicObj CreateDegDynamicFullObj(IDataReader reader)
        {
            Type type = FullDataHelper.CreateType(reader);

            DegFullDynamicObj degMethod;

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

            DegFullDynamicObj deg = null;

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

            //为动态方法构造调用委托
            deg = (DegFullDynamicObj)method.CreateDelegate(typeof(DegFullDynamicObj));
            if (!_idiFullDynamicObj.ContainsKey(type.FullName))
            {
                _idiFullDynamicObj.TryAdd(type.FullName, deg);
            }
            return(deg);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 构造填充映射类对象 填充Object委托
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static DegFullMapObj <T> CreateDegFullMapObj <T>(IDataReader reader)
        {
            //判断是否已经存在该类型的动态方法
            Type     type = typeof(T);
            Delegate degMethod;

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

            DegFullMapObj <T> deg = null;

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

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