public partial class Class1 { [Attr1("")] public string ID { get; set; } } public class Attr1: Attribute { public string Type { get; set;} public Attr1() { } public Attr1(string type) { Type = type } }
Class1 c = new Class1(); c.ID = "ID1"; PropertyInfo propPK = c.GetType().GetProperty("ID"); object[] attrs = propPK.GetCustomAttributes(typeof(Attr1), false); if (attrs.Length > 0) { object attr = attrs.First(); attr.GetType().GetProperty("Type").SetValue(attr, "Type1" , null); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)