Exemple #1
0
        /// <summary>
        /// 获取默认的编辑控制器
        /// </summary>
        /// <param name="objectType">对象类型</param>
        /// <param name="editorType">编辑器类型</param>
        /// <returns>默认编辑控制器</returns>
        public static BaseEditController GetOrCreateEditControllerFromStorage(Type objectType, Type editorType)
        {
            var editController = EditorPublic.GetEditControllerFromStorage(objectType, editorType);

            if (editController == null)
            {
                editController = editorType.CreateInstance() as BaseEditController;
                EditorPublic.SetEditControllerToStorage(objectType, editController);
            }
            return(editController);
        }
Exemple #2
0
        /// 通用获取或创建编辑器步骤:(BaseObjectEditController中)
        /// 1. 从BaseObjectEditController中的PredefinedEditors属性中获取编辑控制器;
        /// 2. 通过类或属性的EditorTypeAttribute获取编辑控制器类型;
        /// 3. 根据类型获取默认的编辑控制器;
        /// 4. 从客户端存储中获取编辑控制器的配置;
        /// 5. 创建编辑器;
        ///
        /// 指定数据类型获取编辑器的步骤:
        /// 1. 通过类或属性的EditorTypeAttribute获取编辑控制器类型;
        /// 2. 根据类型获取默认的编辑控制器;
        /// 3. 从客户端存储中获取编辑控制器的配置;
        /// 4. 创建编辑器;
        ///
        /// 指定编辑器类型创建编辑器的步骤:
        /// 1. 从客户端存储中获取编辑控制器的配置;
        /// 3. 创建编辑器;

        public static BaseEditController GetEditController(Type objectType)
        {
            BaseEditController editController = null;
            var editorType = EditorPublic.GetEditorTypeByReflection(objectType);

            if (editorType == null)
            {
                editorType = GetDefaultEditorType(objectType);
            }

            if (editorType == null)
            {
                return(null);
            }

            editController = EditorPublic.GetEditControllerFromStorage(objectType, editorType);
            if (editController == null)
            {
                editController = editorType.CreateInstance() as BaseEditController;
                EditorPublic.SetEditControllerToStorage(objectType, editController);
            }
            return(editController);
        }