Reputation: 1401
I would like to understand the concept of BindingRestrictions. The official documentation is a little bit short, an I have not found any other resource.
Up to now, I used the samples when implementing DynamicMetaObject - without really understanding what the BindingRestriction are or how I can take control over them. It would be nice to have some examples.
Upvotes: 2
Views: 182
Reputation: 244868
The article A Simple DLR Binder explains this (emphasis mine):
There’s a few key pieces you need to understand here. First you’re returning an expression tree back to the DLR to tell the DLR what to do. The DLR will compile this expression tree and run it. You’re also returning a set of “restrictions”. These will be evaluated by the DLR to see if it can re-use the same code for other objects in the future. You’re unlimited in what you can do with restrictions as they can be arbitrary Expression trees. But here I’m simply restricting based upon the arguments .NET types which is one of the most common restrictions. Both the expression tree and restrictions get packaged up in a DynamicMetaObject which is conveniently the same type of object you receive as your arguments.
Upvotes: 2