public class Context
|
Classes are marked with ContextAttribute, which provide the usage rules. Whenever a new object is instantiated, the .NET Framework finds a compatible or creates a new Context 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 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 (also known as configuration) context properties can be applied and configured by administrators.
For more information on contexts see the conceptual topic at MSDN: boundariesprocessesapplicationdomainscontexts.ctor #1 | Default constructor. This constructor is called by derived class constructors to initialize state in this type. Initializes a new instance of the Context class. |
ContextID | Read-only Gets the context ID for the current Context. |
ContextProperties | Read-only Gets the array of current context properties. |
DefaultContext | Read-only Gets the default context for the current AppDomain. |
AllocateDataSlot | Allocates an un-named data slot. |
AllocateNamedDataSlot | Allocates a named data slot. |
DoCallBack | Executes code in another Context. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
FreeNamedDataSlot | Frees a named data slot on all the contexts. |
Freeze | Freezes the context, making it impossible to add or remove context properties from the current Context. |
GetData | Retrieves the value from the specified slot on the current context. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetNamedDataSlot | Looks up a named data slot. |
GetProperty | Returns a specific context property specified by name. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
RegisterDynamicProperty | Registers a dynamic property implementing IDynamicProperty interface with the remoting service. |
SetData | Sets the data in the specified slot on the current context. |
SetProperty | Sets a specific context property by name. |
ToString | Overridden: Returns a String representation of the current context. |
UnregisterDynamicProperty | Unregisters a dynamic property implementing IDynamicProperty. |
Finalize | Overridden: Cleans up the backing objects for the nondefault contexts. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public Context(); |
public virtual int ContextID {get;}
|
public virtual IContextProperty[] ContextProperties {get;}
|
public static Context DefaultContext {get;}
|
public static LocalDataStoreSlot AllocateDataSlot(); |
public static LocalDataStoreSlot AllocateNamedDataSlot( |
name
public void DoCallBack( |
deleg
~Context(); |
public static void FreeNamedDataSlot( |
name
public virtual void Freeze(); |
Exception Type | Condition |
---|---|
InvalidOperationException | The Context is already frozen. |
public static object GetData( |
slot
public virtual int GetHashCode(); |
public static LocalDataStoreSlot GetNamedDataSlot( |
name
public virtual IContextProperty GetProperty( |
name
public Type GetType(); |
protected object MemberwiseClone(); |
public static bool RegisterDynamicProperty( |
prop
obj
ctx
Exception Type | Condition |
---|---|
ArgumentNullException | The prop parameter or its name is null, or it is not dynamic (it does not implement IDynamicProperty). |
ArgumentException | Both an object as well as a context are specified (both obj and ctx parameters are not null). |
If the obj parameter is not null then if it is a proxy, all calls made on the proxy are intercepted. Otherwise, if obj is a real object, all calls on the object are intercepted. The ctx argument must be null.
If the ctx parameter is not null then the obj parameter must be null and all calls entering and leaving the context are intercepted.
If both ctx and obj parameters are null, then all calls entering and leaving all contexts are intercepted.
public static void SetData( |
slot
data
public virtual void SetProperty( |
prop
Exception Type | Condition |
---|---|
InvalidOperationException | There is an attempt to add properties to the default context. |
InvalidOperationException | The context is frozen. |
ArgumentNullException | The property or the property name is null. |
public override string ToString(); |
public static bool UnregisterDynamicProperty( |
name
obj
ctx
Exception Type | Condition |
---|---|
ArgumentNullException | The name parameter is null. |
ArgumentException | Both an object as well as a context are specified (both obj and ctx parameters are not null). |