Пример #1
0
        /// <summary>
        /// 创建指定自定义块类型对应的视图。
        /// </summary>
        /// <param name="evm"></param>
        /// <param name="customBlockType"></param>
        /// <returns></returns>
        private LogicalView CreateCustomBlockView(EntityViewMeta evm, BlockType customBlockType)
        {
            ICustomViewFactory factory = null;
            if (!this._factories.TryGetValue(customBlockType, out factory)) throw new InvalidOperationException("还没有注册对应块类型 {" + customBlockType + "} 的视图构造器。请使用 RegisterBlockType 方法注册。");

            var view = factory.CreateView(evm);

            this.OnViewCreated(view);

            return view;
        }
Пример #2
0
        /// <summary>
        /// 注册一个新的块类型。
        /// </summary>
        /// <param name="blockType">新的块类型</param>
        /// <param name="factory">该块类型对应的视图构造工厂。</param>
        public void RegisterCustomBlock(BlockType blockType, ICustomViewFactory factory)
        {
            if (blockType.Id <= 10) throw new InvalidOperationException("自定义块的类型值,需要大于 10。(10 以内的值是 Rafy 系统预留块)。");

            this._factories[blockType] = factory;
        }