Esempio n. 1
0
        protected virtual string ReadProperty(WPFEntityPropertyViewMeta property)
        {
            var data = string.Empty;

            try
            {
                if (property.IsReference)
                {
                    var displayPath = property.DisplayPath();
                    var value = ObjectHelper.GetPropertyValue(this._currentRow, displayPath);
                    if (value != null) data = value.ToString();
                }
                else
                {
                    var mp = property.PropertyMeta.ManagedProperty;
                    if (mp != null)
                    {
                        var value = this._currentRow.GetProperty(mp);
                        if (value != null)
                        {
                            if (TypeHelper.IsEnumNullable(mp.PropertyType))
                            {
                                data = EnumViewModel.EnumToLabel((Enum)value).Translate();
                            }
                            else
                            {
                                data = value.ToString();
                            }
                        }
                    }
                }
            }
            catch
            {
                //尽量尝试读取值,读取出错,则忽略错误。
            }

            return data;
        }