Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is expando object internally implemented

Tags:

.net

I am really curious to know how the Expando Object in .Net 4.0 has been internally implemented?

like image 946
priyanka.bangalore Avatar asked Dec 13 '22 23:12

priyanka.bangalore


2 Answers

You don't have to mess with Reflector, the source code for the DLR is readily available for download here. Nicely commented too. You'll find the source code for ExpandoObject in src\Runtime\Microsoft.Scripting.Core\Actions\ExpandoObject.cs

The data store for an ExpandoObject is an ExpandoData, available in the same source file. The values are stored in a simple object[]. The ExpandoClass (same directory) keeps track of the keys in a simple string[]. ExpandoObject definitely doesn't use a Dictionary as earlier stated, but it does implement IDictionary.

like image 88
Hans Passant Avatar answered Jan 08 '23 13:01

Hans Passant


It's implemented as a dictionary internally.

Check out Alexandra Rusina's blog on the topic here, and mine here.

like image 39
David Morton Avatar answered Jan 08 '23 14:01

David Morton