288
❘
CHAPTER 14
InteractIng wIth the DLr
➤➤
Extensions to Language Integrated Query (LINQ) ExpressionTree: Normally, a language would
need to convert data, objects, and code into Microsoft Intermediate Language (MSIL) before it
could translate anything into another language. Because all .NET languages eventually end up
as MSIL, MSIL is the common language for all higher-level .NET languages. These extensions
make it possible for language compilers to create higher-level constructs for communication pur-
poses, rather than always relying on MSIL. The result is that the marshaling process takes less
time and the application runs faster.
➤
➤
DynamicSite
: This feature provides a call-site cache that dynamic languages use in place
of making constant calls to other .NET languages. Because the call-site cache is already in a
form that the dynamic language can use, the overall speed of the dynamic language applica-
tion improves.
➤
➤
IDynamicObject
: An interface used to interact with dynamic objects directly. If you create
a class that implements
IDynamicObject
, DLR lets the class perform the required conver-
sions, rather than rely on the built-in functionality. Essentially, you create an object that
can have methods, properties, and events added dynamically during run time. You use
IDynamicObject
when you want to implement custom behaviors in your class.
➤
➤
ActionBinder
: The
ActionBinder
is a utility that helps support .NET interoperability. The
ActionBinder
is language specific. It ensures that conversions of variable data, return values,
and arguments all follow language-specific behaviors so that the host language sees the data
in a form it understands.
These are the main tasks that DLR performs. Of course, it also provides other compiler utilities
that you need to know about. The final section in this chapter provides an overview of these other
features.
DLR is a constantly changing technology today, so you’ll want to keep up
with the additions and changes to DLR. One of the better places to find
general DLR resources online is at
http://blogs.msdn.com/ironpython/
archive/2008/03/16/dlr-resources.aspx
. This chapter also provides a
number of specific resources you can use to discover more about DLR. The
point is to keep track of what’s going on with this exciting technology and
review your code as things change.
ObTAININg DLR
It’s important to remember that IronPython relies on DLR to perform just about every task that
IronPython executes. Therefore, you already have access to a certain level of DLR, even if you don’t
install anything or do anything special. In fact, you’re using DLR in the background every time you
use IronPython. However, you’re using DLR without really knowing it exists and without under-
standing what DLR itself can do for your application. So while you can use the direct approach to
DLR, it can prove frustrating and less than friendly.
548592c14.indd 288
2/24/10 12:49:03 PM
www.finebook.ir
Do'stlaringiz bilan baham: |