internal static string GetBlockConfigFilePath(BlockConfigKey key) { if (!IsCustomizing && key.Type == BlockConfigType.Customization) { throw new InvalidProgramException("当前不在客户化状态中,无法找到客户化文件:" + key.GetDescription()); } var sb = new StringBuilder(); if (key.IsDefaultView()) { sb.Append("MetaModel/Block/Default/"); sb.Append(key.EntityType.FullName); } else { sb.Append("MetaModel/Block/Extend/"); sb.Append(key.EntityType.FullName); sb.Append(" "); sb.Append(key.ExtendView); } sb.Append(".xml"); var versionPath = sb.ToString(); //暂时只支持一个主干版本和一个客户化版本:common, customer var pathes = RafyEnvironment.BranchProvider.MapAllPathes(versionPath, true); if (key.Type == BlockConfigType.Customization) { return pathes[1]; } return pathes[0]; }
/// <summary> /// 通过 key 查找 BlockConfig。 /// </summary> /// <param name="key"></param> /// <returns></returns> public BlockConfig GetBlockConfig(BlockConfigKey key) { if (key.Type == BlockConfigType.Config || XmlConfigFileSystem.IsCustomizing) { var path = key.GetFilePath(); if (File.Exists(path)) { var xDoc = XDocument.Load(path); var blockCfg = new BlockConfig { Key = key, Xml = xDoc.Root }; return(blockCfg); } } return(null); }
internal static string GetBlockConfigFilePath(BlockConfigKey key) { if (!IsCustomizing && key.Type == BlockConfigType.Customization) { throw new InvalidProgramException("当前不在客户化状态中,无法找到客户化文件:" + key.GetDescription()); } var sb = new StringBuilder(); if (key.IsDefaultView()) { sb.Append("MetaModel/Block/Default/"); sb.Append(key.EntityType.FullName); } else { sb.Append("MetaModel/Block/Extend/"); sb.Append(key.EntityType.FullName); sb.Append(" "); sb.Append(key.ExtendView); } sb.Append(".xml"); var versionPath = sb.ToString(); //暂时只支持一个主干版本和一个客户化版本:common, customer var pathes = RafyEnvironment.BranchProvider.MapAllPathes(versionPath, true); if (key.Type == BlockConfigType.Customization) { return(pathes[1]); } return(pathes[0]); }
/// <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; }
protected BlockConfigKey GetInputKey() { if (!string.IsNullOrEmpty(this.Model)) { var key = new BlockConfigKey { EntityType = ClientEntities.Find(this.Model).EntityType, ExtendView = this.ViewName, Type = RafyEnvironment.BranchProvider.HasBranch ? BlockConfigType.Customization : BlockConfigType.Config }; var dv = ViewConfigurationModel.ViewNameProperty.GetMeta(typeof(ViewConfigurationModel)).DefaultValue; if (key.ExtendView == dv) { key.ExtendView = null; } return key; } return null; }