2
public static string ProductHelper(this Product p) {
// Need to get the DisplayName value for p.Name property
}
편집 :코드에서 DisplayName 데이터 주석 값에 액세스하려면 어떻게해야합니까?
[MetadataType(typeof(ProductMetadata))]
public partial class Product {
public class ProductMetadata {
[DisplayName("Product name")]
public object Name { get; set; }
}
}
Product Name 속성의 DisplayName이 MetaData 클래스 (ProductMetaData)를 통해 제공되는 경우 어떻게됩니까? 편집 된 업데이트를 참조하십시오. – randomguy
해당 속성의 클래스를 확인하고 지정된 유형에 대한 참조를 가져옵니다. 대신 해당 유형의 속성을 반사하십시오. – jwsample
부분 클래스에 주석이 달린 속성이 있지만 customAttributes가 0 인 이유는 무엇입니까? – danihp