/// <summary> /// 查询某个实体类型所对应的基础视图信息 /// </summary> /// <param name="entityType"></param> /// <param name="destination"></param> /// <returns></returns> public EntityViewMeta CreateBaseView(Type entityType, BlockConfigType? destination = BlockConfigType.Customization) { var res = this.CreateBaseViewCore(entityType, destination); //res.Freeze(); return res; }
/// <summary> /// 获取某个类型的默认视图或扩展视图 /// </summary> /// <param name="entityType"></param> /// <param name="extendViewName"></param> /// <param name="destination"></param> /// <returns></returns> public EntityViewMeta Create(Type entityType, string extendViewName = null, BlockConfigType? destination = BlockConfigType.Customization) { if (string.IsNullOrEmpty(extendViewName)) { return this.CreateBaseView(entityType, destination); } return this.CreateExtendView(entityType, extendViewName, destination); }
/// <summary> /// 获取某个类型的扩展视图 /// </summary> /// <param name="entityType"></param> /// <param name="extendViewName"></param> /// <param name="destination"></param> /// <returns></returns> public EntityViewMeta CreateExtendView(Type entityType, string extendViewName, BlockConfigType? destination = BlockConfigType.Customization) { var raw = this.CreateBaseViewCore(entityType, destination); //使用扩展视图配置对象进行配置 if (raw is WebEntityViewMeta) { foreach (var config in RafyEnvironment.WebConfigurations.FindViewConfigurations(entityType, extendViewName)) { lock (config) { config.View = raw as WebEntityViewMeta; config.ConfigView(); } } } else { foreach (var config in RafyEnvironment.WPFConfigurations.FindViewConfigurations(entityType, extendViewName)) { lock (config) { config.View = raw as WPFEntityViewMeta; config.ConfigView(); } } } if (destination != null) { //Config var key = new BlockConfigKey { EntityType = entityType, ExtendView = extendViewName, Type = BlockConfigType.Config }; var blockCfg = this._xmlCfgMgr.GetBlockConfig(key); if (blockCfg != null) { blockCfg.Config(raw); } //Customization if (destination == BlockConfigType.Customization) { key = new BlockConfigKey { EntityType = entityType, ExtendView = extendViewName, Type = BlockConfigType.Customization }; blockCfg = this._xmlCfgMgr.GetBlockConfig(key); if (blockCfg != null) { blockCfg.Config(raw); } } } raw.ExtendView = extendViewName; //raw.Freeze(); return raw; }
private EntityViewMeta CreateBaseViewCore(Type entityType, BlockConfigType? destination) { var meta = CommonModel.Entities.Get(entityType); var raw = this._codeReader.Read(meta); this.UseSysCommands(raw); //使用配置对象进行配置 if (raw is WebEntityViewMeta) { foreach (var config in RafyEnvironment.WebConfigurations.FindViewConfigurations(entityType)) { lock (config) { config.View = raw as WebEntityViewMeta; config.ConfigView(); } } } else { foreach (var config in RafyEnvironment.WPFConfigurations.FindViewConfigurations(entityType)) { lock (config) { config.View = raw as WPFEntityViewMeta; config.ConfigView(); } } } if (destination != null) { var key = new BlockConfigKey { EntityType = entityType, Type = BlockConfigType.Config }; var blockCfg = this._xmlCfgMgr.GetBlockConfig(key); if (blockCfg != null) { blockCfg.Config(raw); } } if (destination == BlockConfigType.Customization) { var key = new BlockConfigKey { EntityType = entityType, Type = BlockConfigType.Customization }; var blockCfg = this._xmlCfgMgr.GetBlockConfig(key); if (blockCfg != null) { blockCfg.Config(raw); } } return raw; }