コード例 #1
0
        /// <summary>
        /// 创建动态类
        /// </summary>
        /// <param name="key">字典Key</param>
        /// <param name="propertys">Key:属性名称;Value:属性类型</param>
        /// <param name="parentType">继承的父类类型</param>
        private static Type CreateClass(int key, Dictionary <string, Type> propertys, Type parentType = null)
        {
            lock (LockObject)
            {
                if (DicCreateClassList.ContainsKey(key))
                {
                    return(DicCreateClassList[key]);
                }

                //缓存中没有找到,新建一个构造函数的委托
                return(DicCreateClassList[key] = Dynamics.CreateClassType(propertys, parentType));
            }
        }
コード例 #2
0
        /// <summary>
        /// 创建动态类
        /// </summary>
        /// <param name="key">字典Key</param>
        /// <param name="propertys">Key:属性名称;Value:属性类型</param>
        /// <param name="parentType">继承的父类类型</param>
        /// <param name="constructors">构造函数参数</param>
        private static Type CreateClass(int key, List <PropertyInfo> propertys, Type[] constructors = null, Type parentType = null)
        {
            lock (LockObject)
            {
                if (DicCreateClassList.ContainsKey(key))
                {
                    return(DicCreateClassList[key]);
                }

                //缓存中没有找到,新建一个构造函数的委托
                return(DicCreateClassList[key] = Dynamics.CreateClassType(propertys, constructors, parentType));
            }
        }
コード例 #3
0
        /// <summary>
        ///     当缓存不存在时,上锁加入缓存
        /// </summary>
        protected override Type SetCacheLock()
        {
            lock (LockObject)
            {
                if (CacheList.ContainsKey(Key))
                {
                    return(CacheList[Key]);
                }

                //缓存中没有找到,新建一个构造函数的委托
                var val = _isListProperty ? Dynamics.CreateClassType(_lstAddPropertys, _constructors, _baseType) : Dynamics.CreateClassType(_dicAddPropertys, _baseType);
                return(CacheList[Key] = val);
            }
        }