예제 #1
0
 protected override void OnInit(EventArgs e)
 {
     this.Page.LoadComplete      += new EventHandler(Page_LoadComplete);
     this.Page.PreRenderComplete += new EventHandler(Page_PreRenderComplete);
     PropertyEditorHelper.AttachToPage(this.Page);
     base.OnInit(e);
 }
예제 #2
0
        void Page_LoadComplete(object sender, EventArgs e)
        {
            var allEditors = PropertyEditorHelper.GetAllEditors();

            foreach (PropertyValue prop in this.Properties)
            {
                string key = prop.Definition.EditorKey;
                if (string.IsNullOrEmpty(key) == false)
                {
                    if (allEditors.ContainsKey(key))
                    {
                        PropertyEditorBase propEditor = allEditors[key];
                        propEditor.SetControlsPropertyDefineFromEditorParams(prop.Definition);
                    }
                    else
                    {
                        throw new KeyNotFoundException("属性编辑器没有注册:" + key);
                    }
                }
            }
        }
예제 #3
0
        private List <EnumTypePropertyDescription> CollectEnumDescriptions()
        {
            Dictionary <string, EnumTypePropertyDescription> enumDespDict = new Dictionary <string, EnumTypePropertyDescription>();

            foreach (string enumParams in PredefinedEnumTypes)
            {
                EnumTypePropertyDescription etpd = EnumTypePropertyDescription.FromEnumTypeName(enumParams);

                if (etpd != null)
                {
                    enumDespDict.Add(etpd.EnumTypeName, etpd);
                }
            }

            foreach (PropertyValue pv in this.Properties)
            {
                if (pv.Definition.DataType == PropertyDataType.Enum && string.IsNullOrEmpty(pv.Definition.EditorParams) == false)
                {
                    string editorParamName = pv.Definition.EditorParams;
                    if (Regex.IsMatch(pv.Definition.EditorParams, @"\{[^{}]*}") == true)
                    {
                        try
                        {
                            EditorParamsDefine editorParams = JSONSerializerExecute.Deserialize <EditorParamsDefine>(pv.Definition.EditorParams);
                            editorParamName = editorParams.EnumTypeName;
                            //将配置文件里的数据源转换成下拉列表数据源
                            if (editorParams.ContainsKey("dropDownDataSourceID") == true)
                            {
                                string sourceID = editorParams["dropDownDataSourceID"];
                                if (PropertyEditorHelper.AllDropdownPropertyDataSource.ContainsKey(sourceID) == true)
                                {
                                    EnumTypePropertyDescription etpd = PropertyEditorHelper.GenerateEnumTypePropertyDescription(PropertyEditorHelper.AllDropdownPropertyDataSource[sourceID]);
                                    if (etpd != null)
                                    {
                                        enumDespDict.Add(etpd.EnumTypeName, etpd);
                                    }
                                }
                            }
                        }
                        catch (Exception)
                        {   //这里吃掉异常,主要原因是兼容老已上线的流程配置文件
                            editorParamName = pv.Definition.EditorParams;
                        }
                    }

                    if (string.IsNullOrEmpty(editorParamName) == false)
                    {
                        if (enumDespDict.ContainsKey(editorParamName) == false)
                        {
                            EnumTypePropertyDescription etpd = EnumTypePropertyDescription.FromEnumTypeName(editorParamName);

                            if (etpd != null)
                            {
                                enumDespDict.Add(etpd.EnumTypeName, etpd);
                            }
                        }
                    }
                }
            }

            List <EnumTypePropertyDescription> result = new List <EnumTypePropertyDescription>();

            foreach (KeyValuePair <string, EnumTypePropertyDescription> kp in enumDespDict)
            {
                result.Add(kp.Value);
            }

            return(result);
        }