Information Technology Reference
In-Depth Information
In all cases, you must examine the Binder object to see what member was
requested and perform whatever operation is needed. Where there are
return values, you'll need to set those (in the specified out parameter) and
return whether or not your overload handled the member.
If you're going to create a type that enables dynamic behavior, using
DynamicObject as the base class is the easiest way to do it. Of course, a
dynamic property bag is okay, but let's look at one more sample that shows
when a dynamic type is more useful.
LINQ to XML made some great improvements to working with XML, but
it still left something to be desired. Consider this snippet of XML that con-
tains some information about our solar system:
<Planets>
<Planet>
<Name>Mercury</Name>
</Planet>
<Planet>
<Name>Venus</Name>
</Planet>
<Planet>
<Name>Earth</Name>
<Moons>
<Moon>Moon</Moon>
</Moons>
</Planet>
<Planet>
<Name>Mars</Name>
<Moons>
<Moon>Phobos</Moon>
<Moon>Deimos</Moon>
</Moons>
</Planet>
<!-- other data elided -->
</Planets>
To g e t t h e fi r s t p l a n e t , y o u w o u l d w r i t e s o m e t h i n g l i k e t h i s :
// Create an XElement document containing
// solar system data:
 
Search WWH ::




Custom Search