public static Dictionary <string, PropertyEditorBase> GetAllEditors() { Dictionary <string, PropertyEditorBase> result = new Dictionary <string, PropertyEditorBase>(); lock (_GlobalPropertyEditors) { foreach (var item in _GlobalPropertyEditors) { result[item.Key] = item.Value; } } TypeConfigurationCollection editorTypes = PropertyEditorConfigurationSection.GetConfig().Editors; foreach (TypeConfigurationElement typeElem in editorTypes) { PropertyEditorBase editor = (PropertyEditorBase)typeElem.CreateInstance(); if (result.ContainsKey(editor.EditorKey) == false) { result[editor.EditorKey] = editor; } } return(result); }
public static void RegisterEditor(PropertyEditorBase editor) { if (editor == null) throw new ArgumentNullException("editor"); lock (_GlobalPropertyEditors) { _GlobalPropertyEditors[editor.EditorKey] = editor; } var page = HttpContextExtension.GetCurrentPage(HttpContext.Current); if (page != null) page.Items.Remove(PageAllEditorCacheKey); }
public static void RegisterEditor(PropertyEditorBase editor) { if (editor == null) { throw new ArgumentNullException("editor"); } lock (_GlobalPropertyEditors) { _GlobalPropertyEditors[editor.EditorKey] = editor; } var page = HttpContextExtension.GetCurrentPage(HttpContext.Current); if (page != null) { page.Items.Remove(PageAllEditorCacheKey); } }
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); } } } }