0

I am having a ASP.NET MVC project where I need to read a dynamic table and display it in a Grid.

My framework supports binding static types to Grids, simply by adding attributes to the static type properties e.g. [Grid], [Key], [GridColumn(Name="Id", Order=1, IsHidden=true)]

I am therefore building a dynamic object with reflection and I am assigning all the required metadata to allow the framework read my dynamic object Grid.

Although I have managed to assign with reflection all the required attributes that have no properties and I think I know how to do it for attributes that take constructor parameters, I am struggling to set the properties of Name, Order, IsHidden of the GridColumnAttribute (which does not accept parameters in the framework)

Do you know any way of doing it?

I found that Jon in How to set attributes values using reflection mentioned it is not possible but then why is it possible to do it with constructor parameters and not public properties of the attribute?

If you think it is possible, I would appreciate code example.

Many Thanks

Community
  • 1
  • 1
gpanagopoulos
  • 2,842
  • 2
  • 24
  • 19

1 Answers1

0

I don't know how to prove this is not possible... but that would somehow frighten me if reflection could change, for example, passive security checks.

[PrincipalPermission(Security.Demand, Role="BUILTIN\\Administrators"]
void SomeVerySecuredStuff()
{
   //...
}

I'm probably not the most trusted source for reflection, but I really hope that it cannot be achieved.

xum59
  • 841
  • 9
  • 16