O'Reilly logo

Essential .NET, Volume 1: The Common Language Runtime by Chris Sells, Don Box

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Contexts and Interception

The CLR gives context attributes the chance to put context properties in place as a context is being created. The CLR gives context properties the chance to inject message sinks between a proxy and a context-bound object when the object's proxy is created. One could argue that the primary motivation for context properties is to act as a factory for message sinks.

The message sinks injected by a context property are responsible for implementing the aspect that their property (and its attribute) represents. For example, our thread priority property would need to inject a message sink to adjust the thread priority prior to entering the context and then reset it upon leaving the context. Message sinks typically manipulate ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required