示例#1
0
        public void Config(EntityViewMeta evm)
        {
            if (PageSize != null && evm is WebEntityViewMeta)
            {
                evm.AsWebView().PageSize = PageSize.Value;
            }
            if (GroupBy != null)
            {
                if (GroupBy == NullString)
                {
                    evm.GroupBy = null;
                }
                else
                {
                    evm.GroupBy = evm.Property(GroupBy);
                }
            }

            foreach (var property in this.EntityProperties)
            {
                if (property.IsChanged())
                {
                    var pvm = evm.Property(property.Name);
                    if (pvm != null)
                    {
                        property.Config(pvm);
                    }
                }
            }

            if (RafyEnvironment.Location.IsWebUI)
            {
                foreach (var cmd in this.Commands)
                {
                    if (cmd.IsChanged())
                    {
                        var jsCmd = evm.AsWebView().Commands.Find(cmd.Name);
                        if (jsCmd != null)
                        {
                            cmd.Config(jsCmd);
                        }
                    }
                }
            }
            else
            {
                foreach (var cmd in this.Commands)
                {
                    if (cmd.IsChanged())
                    {
                        var wpfCmd = evm.AsWPFView().Commands.Find(cmd.Name);
                        if (wpfCmd != null)
                        {
                            cmd.Config(wpfCmd);
                        }
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// 查找逻辑:
        /// 先找元数据中的 AutomationPropertyKey
        /// 如果没有,再尝试使用 Title 属性。
        /// 如果没有,再尝试使用 "Name" 属性。
        /// </summary>
        /// <param name="evm"></param>
        /// <returns></returns>
        public static string TryGetPrimayDisplayProperty(this EntityViewMeta evm)
        {
            var autoProperty = TryGetAutomationNameBinding(evm);

            if (autoProperty != null)
            {
                return(autoProperty);
            }

            var title = evm.TitleProperty;

            if (title != null)
            {
                return(title.Name);
            }

            var nameProperty = evm.Property("Name");

            if (nameProperty != null)
            {
                return(nameProperty.Name);
            }

            return(null);
        }
示例#3
0
文件: RuleArgs.cs 项目: yungtau/oea
        /// <summary>
        /// 如果当前 Rafy 运行时环境中,已经拥有 UI 层界面的元数据,则获取属性对应的的显示名称,并进行翻译后返回。
        /// 否则,直接返回以下格式的字符串,方便替换:[属性名称]。(服务端一般都没有 UI 层元数据。)
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns></returns>
        public static string Display(IManagedProperty property)
        {
            if (RafyEnvironment.Location.IsWebUI || RafyEnvironment.Location.IsWPFUI)
            {
                //以线程安全的方式获取最后一次缓存的 View。
                EntityViewMeta safeView  = _lastViewMeta;
                var            ownerType = property.OwnerType;
                if (safeView == null || safeView.EntityType != ownerType)
                {
                    safeView      = UIModel.Views.CreateBaseView(ownerType);
                    _lastViewMeta = safeView;
                }

                string res = null;

                var pvm = safeView.Property(property);
                if (pvm != null)
                {
                    res = pvm.Label;
                }

                //如果是引用 Id 属性没有配置 Label,则尝试使用它对应的引用实体属性的 Label 来显示。
                if (string.IsNullOrEmpty(res))
                {
                    var refMP = property as IRefIdProperty;
                    if (refMP != null)
                    {
                        pvm = safeView.Property(refMP.RefEntityProperty);
                        if (pvm != null)
                        {
                            res = pvm.Label;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(res))
                {
                    return(res.Translate());
                }
            }

            return('[' + property.Name + ']');
        }
示例#4
0
        public void Config(EntityViewMeta evm)
        {
            if (PageSize != null && evm is WebEntityViewMeta) evm.AsWebView().PageSize = PageSize.Value;
            if (GroupBy != null)
            {
                if (GroupBy == NullString)
                {
                    evm.GroupBy = null;
                }
                else
                {
                    evm.GroupBy = evm.Property(GroupBy);
                }
            }

            foreach (var property in this.EntityProperties)
            {
                if (property.IsChanged())
                {
                    var pvm = evm.Property(property.Name);
                    if (pvm != null) { property.Config(pvm); }
                }
            }

            if (RafyEnvironment.Location.IsWebUI)
            {
                foreach (var cmd in this.Commands)
                {
                    if (cmd.IsChanged())
                    {
                        var jsCmd = evm.AsWebView().Commands.Find(cmd.Name);
                        if (jsCmd != null) { cmd.Config(jsCmd); }
                    }
                }
            }
            else
            {
                foreach (var cmd in this.Commands)
                {
                    if (cmd.IsChanged())
                    {
                        var wpfCmd = evm.AsWPFView().Commands.Find(cmd.Name);
                        if (wpfCmd != null) { cmd.Config(wpfCmd); }
                    }
                }
            }
        }