动态添加特性

特性属于元数据,一般不能改,但可以通过TypeDescriptor添加类级别的特性,也只能通过TypeDescriptor获取到这个类特性

Entity e=new Entity();
ColumnAttribute c = new ColumnAttribute()
            {
                LogicDeleteValue = "wang"
            };

            TypeDescriptionProvider ty = TypeDescriptor.AddAttributes(e, c);

            var x = TypeDescriptor.GetAttributes(e);

 

posted on 2017-08-11 08:45  编程007  阅读(235)  评论(0编辑  收藏  举报