コード例 #1
0
        /// <summary>
        /// 获取控件的默认属性的信息
        /// </summary>
        /// <param name="ctr"></param>
        /// <returns></returns>
        private static ContorlDefaultPropertyInfo GetBinderInfo(Control ctr)
        {
            if (ctr == null)
            {
                return(null);
            }
            Type   crlType = ctr.GetType();
            string key     = crlType.FullName;
            ContorlDefaultPropertyInfo defaultInfo = null;

            if (!dicContorlBinder.TryGetValue(key, out defaultInfo))
            {
                defaultInfo = new ContorlDefaultPropertyInfo();
                string strProName = GetContorlBinderName(ctr);
                if (strProName == null)
                {
                    return(null);
                }
                PropertyInfo[] destproper = crlType.GetProperties();
                ///读取属性别名
                foreach (PropertyInfo pinf in destproper)
                {
                    if (pinf.Name == strProName)
                    {
                        defaultInfo.PropertyType   = pinf.PropertyType;
                        defaultInfo.PropertyHandle = FastValueGetSet.GetPropertyInfoHandleWithOutCache(strProName, crlType);
                        defaultInfo.DefaultValue   = GetDefaultPropertyValue(pinf);
                    }
                }
                dicContorlBinder.Add(key, defaultInfo);
            }
            return(defaultInfo);
        }
コード例 #2
0
        /// <summary>
        /// 无缓存的获取控件默认值
        /// </summary>
        /// <param name="ctr"></param>
        /// <returns></returns>
        internal static ContorlDefaultPropertyInfo GetDefaultPropertyInfoWithoutCache(Control ctr)
        {
            Type   crlType    = ctr.GetType();
            string strProName = GetDefaultPropertyName(ctr);
            ContorlDefaultPropertyInfo defaultInfo = null;

            if (strProName != null)
            {
                defaultInfo = new ContorlDefaultPropertyInfo();
                PropertyInfo[] destproper = crlType.GetProperties();
                ///读取属性别名
                foreach (PropertyInfo pinf in destproper)
                {
                    if (pinf.Name.Equals(strProName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        defaultInfo.PropertyType   = pinf.PropertyType;
                        defaultInfo.PropertyHandle = FastValueGetSet.GetPropertyInfoHandleWithOutCache(strProName, crlType);
                        defaultInfo.DefaultValue   = GetDefaultPropertyValue(pinf);
                    }
                }
            }
            return(defaultInfo);
        }