Beispiel #1
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="container">容器</param>
        /// <param name="model">实体</param>
        /// <param name="type">命名类型</param>
        public static void UpdateModel(Control container, object model, PrefixType type)
        {
            Control.ControlCollection ctrs = container.Controls;
            if (ctrs == null || ctrs.Count <= 0)
            {
                return;
            }
            ClassInfoHandle classHandle = ClassInfoManager.GetClassHandle(model.GetType());

            foreach (Control ctr in ctrs)
            {
                string proName = UpdateModelInfo.GetKey(ctr.Name, type);
                if (string.IsNullOrEmpty(proName))
                {
                    continue;
                }
                PropertyInfoHandle handle = classHandle.PropertyInfo[proName];
                if (handle == null || !handle.HasSetHandle)//搜索里层
                {
                    UpdateModel(ctr, model, type);
                }
                else
                {
                    try
                    {
                        SetModelValue(ctr, model, handle);
                    }
                    catch { }
                }
            }
        }
Beispiel #2
0
        //private static Dictionary<string, Dictionary<string, ModelInfo>> dicCache = new Dictionary<string, Dictionary<string, ModelInfo>>();

        /// <summary>
        /// 填充实体跟页面的对应表
        /// </summary>
        /// <param name="objPage">页面类</param>
        /// <param name="modleType">实体类型</param>
        private static Dictionary <string, ModelInfo> GetPageMapInfo(Control objControl, Type modleType, PrefixType pType)
        {
            Dictionary <string, ModelInfo> handleMapping = new Dictionary <string, ModelInfo>();
            ClassInfoHandle handle  = ClassInfoManager.GetClassHandle(modleType);
            List <Control>  lstCtrs = GetAllContorl(objControl);

            foreach (Control ctr in lstCtrs)
            {
                string id = UpdateModelInfo.GetKey(ctr.ID, pType);
                if (!string.IsNullOrEmpty(id))
                {
                    ModelInfo          info  = new ModelInfo();
                    PropertyInfoHandle pInfo = handle.PropertyInfo[id];
                    if (pInfo != null)
                    {
                        info.Phandle = pInfo;
                        ContorlDefaultPropertyInfo ctrInfo = ControlDefaultValue.GetDefaultPropertyInfoWithoutCache(ctr);
                        info.CtrHandle        = ctrInfo;
                        info.Ctr              = ctr;
                        handleMapping[ctr.ID] = info;
                    }
                }
            }
            return(handleMapping);
        }