나는 그런 다음 사용자 지정 특성 클래스속성 속성 목록을 가져 오는 방법은 무엇입니까?
[System.AttributeUsage(System.AttributeTargets.Property)]
public class Format : Attribute
{
public string DisplayName { get; set; }
public ColumnType ColumnType { get; set; }
public double Width { get; set; }
public bool ReadOnly { get; set; }
public Format()
{
ReadOnly = true;
}
}
을 만든 나는
public class GridTestData
{
[Format(ColumnType = grdOpt.Column.ColumnType.BoundInteger, DisplayName = "Auto ID", ReadOnly = true)]
int AutoID {get; set;}
[Format(ColumnType = grdOpt.Column.ColumnType.BoundString, DisplayName = "String", ReadOnly = true)]
string String {get; set;}
[Format(ColumnType = grdOpt.Column.ColumnType.BoundInteger, DisplayName = "Integer", ReadOnly = true)]
int? Integer {get; set;}
[Format(ColumnType = grdOpt.Column.ColumnType.BoundDouble, DisplayName = "Double", ReadOnly = true)]
double? Double {get; set;}
[Format(ColumnType = grdOpt.Column.ColumnType.BoundBooleanTriState, DisplayName = "Boolean", ReadOnly = true)]
bool? Boolean {get; set;}
[Format(ColumnType = grdOpt.Column.ColumnType.BoundDateTime, DisplayName = "Date Time", ReadOnly = true)]
DateTime? DateTime {get; set;}
}
가 지금은 매개 변수로 내보기 모델 클래스에 걸릴 것입니다 방법을 만들려면 뷰 모델 클래스 다음이 사용자 지정 특성을 구현
List<Format> MyFormatAttributes = GetFormatAttributes(typeof(GridTestData))