2

I have found this thread that talks a bit about it: Is it possible to add attributes to the generated members of an ExpandoObject instance?

but it seems to just focus on the powergrid.

I have spent about 1 hour looking for this on google without any luck either. Could anyone at least confirm if it can be done?.

Community
  • 1
  • 1
Notbad
  • 5,936
  • 12
  • 54
  • 100

1 Answers1

2

You could create an interface and add the Attribute to the interface.

Than use Improptu: http://code.google.com/p/impromptu-interface/

IMyInterface instance = Impromptu.ActLike<IMyInferface>(myexpando);
Jürgen Steinblock
  • 30,746
  • 24
  • 119
  • 189
  • Thanks for the answer. I really apreciate it, but would like to stick to .net built-in features if it is possible. Could it be done without using external libs? – Notbad Jun 11 '12 at 11:07
  • The question is, what do you want to achive? A custom TypeDescriptor would be a way. Another solution is to write a wrapper class around your expando object. – Jürgen Steinblock Jun 11 '12 at 11:16
  • I'm using an ORM that maps C# classes to a database tables. I want to be able to generate this dynamically. The problem is hat the ORM uses the member vars decoration to add meta information like if it is a primarykey, unique, etc... So, I can now create a ExpandoObject and populate it with the needed members but can't add the custom attributes (decoration) to let the ORM work as expected when reqeusting a query, etc... – Notbad Jun 11 '12 at 11:22