添加 MX-PD-盘古 项目文件
将 MX-PD-盘古 - new 目录下的所有文件添加到主仓库
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace MainShell.Common
|
||||
{
|
||||
[MarkupExtensionReturnType(typeof(string))]
|
||||
public class PropDescExtension : MarkupExtension
|
||||
{
|
||||
public Type ForType { get; set; }
|
||||
public string Property { get; set; }
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
if (ForType == null || string.IsNullOrWhiteSpace(Property)) return Property;
|
||||
|
||||
var pd = TypeDescriptor.GetProperties(ForType)[Property];
|
||||
if (pd == null) return Property;
|
||||
|
||||
var desc = pd.Attributes.OfType<DescriptionAttribute>().FirstOrDefault();
|
||||
return string.IsNullOrWhiteSpace(desc?.Description) ? Property : desc.Description;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user