Context Context Context Context Class

Definition

Defines an environment for the objects that are resident inside it and for which a policy can be enforced.

This API supports the product infrastructure and is not intended to be used directly from your code.

public ref class Context
[System.Runtime.InteropServices.ComVisible(true)]
public class Context
type Context = class
Public Class Context
Inheritance
ContextContextContextContext
Attributes

Remarks

A context is an ordered sequence of properties that define an environment for the objects resident inside it. Contexts get created during the activation process for objects that are configured to require certain automatic services, such as synchronization, transactions, just-in-time activation, security, and so on. Multiple objects can live inside a context.

Classes are marked with an instance of the ContextAttribute class, which provides the usage rules. Whenever a new object is instantiated, the .NET Framework finds a compatible or creates a new instance of the Context class for the object. Once an object is placed in a context, it stays in it for life. Classes that can be bound to a context are called context-bound classes. When accessed from another context, such classes are referenced directly by using a proxy. Any call from an object in one context to an object in another context will go through a context proxy and be affected by the policy that the combined context properties enforce.

A new object's context is generally chosen based on meta-data attributes on the class. This mechanism is extensible through custom attributes. These are known as static-context properties, which are compiled into the class meta-data. Dynamic-context properties (also known as configuration properties) can be applied and configured by administrators.

For more information on contexts, see Boundaries: Processes and Application Domains.

Constructors

Context() Context() Context() Context()

Initializes a new instance of the Context class.

Properties

ContextID ContextID ContextID ContextID

Gets the context ID for the current context.

ContextProperties ContextProperties ContextProperties ContextProperties

Gets the array of the current context properties.

DefaultContext DefaultContext DefaultContext DefaultContext

Gets the default context for the current application domain.

Methods

AllocateDataSlot() AllocateDataSlot() AllocateDataSlot() AllocateDataSlot()

Allocates an unnamed data slot.

AllocateNamedDataSlot(String) AllocateNamedDataSlot(String) AllocateNamedDataSlot(String) AllocateNamedDataSlot(String)

Allocates a named data slot.

DoCallBack(CrossContextDelegate) DoCallBack(CrossContextDelegate) DoCallBack(CrossContextDelegate) DoCallBack(CrossContextDelegate)

Executes code in another context.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

Cleans up the backing objects for the nondefault contexts.

FreeNamedDataSlot(String) FreeNamedDataSlot(String) FreeNamedDataSlot(String) FreeNamedDataSlot(String)

Frees a named data slot on all the contexts.

Freeze() Freeze() Freeze() Freeze()

Freezes the context, making it impossible to add or remove context properties from the current context.

GetData(LocalDataStoreSlot) GetData(LocalDataStoreSlot) GetData(LocalDataStoreSlot) GetData(LocalDataStoreSlot)

Retrieves the value from the specified slot on the current context.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetNamedDataSlot(String) GetNamedDataSlot(String) GetNamedDataSlot(String) GetNamedDataSlot(String)

Looks up a named data slot.

GetProperty(String) GetProperty(String) GetProperty(String) GetProperty(String)

Returns a specific context property, specified by name.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
RegisterDynamicProperty(IDynamicProperty, ContextBoundObject, Context) RegisterDynamicProperty(IDynamicProperty, ContextBoundObject, Context) RegisterDynamicProperty(IDynamicProperty, ContextBoundObject, Context) RegisterDynamicProperty(IDynamicProperty, ContextBoundObject, Context)

Registers a dynamic property implementing the IDynamicProperty interface with the remoting service.

SetData(LocalDataStoreSlot, Object) SetData(LocalDataStoreSlot, Object) SetData(LocalDataStoreSlot, Object) SetData(LocalDataStoreSlot, Object)

Sets the data in the specified slot on the current context.

SetProperty(IContextProperty) SetProperty(IContextProperty) SetProperty(IContextProperty) SetProperty(IContextProperty)

Sets a specific context property by name.

ToString() ToString() ToString() ToString()

Returns a String class representation of the current context.

UnregisterDynamicProperty(String, ContextBoundObject, Context) UnregisterDynamicProperty(String, ContextBoundObject, Context) UnregisterDynamicProperty(String, ContextBoundObject, Context) UnregisterDynamicProperty(String, ContextBoundObject, Context)

Unregisters a dynamic property implementing the IDynamicProperty interface.

Applies to