예제 #1
0
        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;
        }
예제 #2
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);
        }
예제 #3
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;
        }
예제 #4
0
        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 (WebViewConfig config in RafyEnvironment.WebConfigurations.FindViewConfigurations(entityType))
                {
                    lock (config)
                    {
                        config.View = raw as WebEntityViewMeta;
                        config.ConfigView();
                    }
                }
            }
            else
            {
                foreach (WPFViewConfig 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);
        }
예제 #5
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 (WebViewConfig config in RafyEnvironment.WebConfigurations.FindViewConfigurations(entityType, extendViewName))
                {
                    lock (config)
                    {
                        config.View = raw as WebEntityViewMeta;
                        config.ConfigView();
                    }
                }
            }
            else
            {
                foreach (WPFViewConfig 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);
        }