System.Runtime.Remoting.Contexts.ContextAttribute Class

Assembly: Mscorlib.dll
Namespace: System.Runtime.Remoting.Contexts
This type supports the Shared Source CLI infrastructure and is not intended to be used directly from your code.
Summary
Provides the default implementations of IContextAttribute and IContextProperty.
C# Syntax:
[AttributeUsage(AttributeTargets.Class)]
[Serializable]
public class ContextAttribute : Attribute
Remarks
ContextAttribute is the root for all context attributes. Simple Context properties can be derived from ContextAttribute with the context attribute and the context property being in the class. For more specialized or more sophisticated needs the context attribute can derive from ContextAttribute and the context property can be split into a separated class. For more information about using attributes, see the conceptual topic at MSDN: extendingmetadatausingattributes.

Notes to inheritors: The ContextAttribute.Name property must not be overridden in any user derived class. The current ContextAttribute.Equals and ContextAttribute.GetHashCode method implementations depend on the default functionality. If you wish to provide advanced behavior for a class extending the ContextAttribute and override the ContextAttribute.Name property, you have to also override the default implementation of the ContextAttribute.Equals and ContextAttribute.GetHashCode methods.
See also:
System.Runtime.Remoting.Contexts Namespace

System.Runtime.Remoting.Contexts.ContextAttribute Member List:

Public Constructors
ctor #1
Public Properties
Name Read-only

Gets the name of the context attribute.
TypeId
(inherited from System.Attribute)
Read-only

See base class member description: System.Attribute.TypeId


When implemented in a derived class, gets a unique identifier for this Attribute.
Public Methods
Equals Overridden:
Freeze Called when the context is frozen.
GetHashCode Overridden:
Returns the hashcode for this instance of ContextAttribute.
GetPropertiesForNewContext Adds the current context property to the given IConstructionCallMessagectorMsg.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
IsContextOK Returns a Boolean value indicating whether the context parameter meets the context attribute's requirements.
IsDefaultAttribute
(inherited from System.Attribute)
See base class member description: System.Attribute.IsDefaultAttribute


When overridden in a derived class, returns an indication whether the value of this instance is the default value for the derived class.
IsNewContextOK Returns a Boolean value indicating whether the context property is OK with the new context.
Match
(inherited from System.Attribute)
See base class member description: System.Attribute.Match


When overridden in a derived class, returns a value indicating whether this instance equals a specified object.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Fields
AttributeName Indicates the name of the context attribute.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
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:


System.Runtime.Remoting.Contexts.ContextAttribute Member Details

ctor #1
Summary
Creates an instance of the ContextAttribute class with the specified name.
This type supports the Shared Source CLI infrastructure and is not intended to be used directly from your code.
C# Syntax:
public ContextAttribute(
   string name
);
Parameters:

name

The name of the context attribute.

Remarks


Notes to inheritors: The derived class must call: base(name);

Return to top


Field: AttributeName
Summary
Indicates the name of the context attribute.
This type supports the Shared Source CLI infrastructure and is not intended to be used directly from your code.
C# Syntax:
protected string AttributeName;

Return to top


Property: Name (read-only)
Summary
Gets the name of the context attribute.
This type supports the Shared Source CLI infrastructure and is not intended to be used directly from your code.
C# Syntax:
public virtual string Name {get;}
Implements:
IContextProperty.Name
Remarks
Default implementation of this property provides ContextAttribute.AttributeName as the property name.

Notes to inheritors: The current property must not be overridden in any user derived class. The current ContextAttribute.Equals and ContextAttribute.GetHashCode method implementations depend on the default functionality. If you wish to provide advanced behavior for a class extending the ContextAttribute and override the ContextAttribute.Name property, you have to also override the default implementation of the ContextAttribute.Equals and ContextAttribute.GetHashCode methods.

Return to top


Property: TypeId (read-only)
Inherited
See base class member description: System.Attribute.TypeId

Summary
When implemented in a derived class, gets a unique identifier for this Attribute.
C# Syntax:
public virtual object TypeId {get;}
Remarks
As implemented, this identifier is merely the Type of the attribute. However, it is intended that the unique identifier be used to identify two attributes of the same type.

Return to top


Overridden Method: Equals(
   object o
)
Summary
Returns a Boolean value indicating whether this instance is equal to the specified object.
This type supports the Shared Source CLI infrastructure and is not intended to be used directly from your code.
C# Syntax:
public override bool Equals(
   object o
);
Parameters:

o

The object to compare with this instance.

Return Value:
true if o is not null, and if the attribute names are equivalent; false otherwise.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~ContextAttribute();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Freeze(
   Context newContext
)
Summary
Called when the context is frozen.
This type supports the Shared Source CLI infrastructure and is not intended to be used directly from your code.
C# Syntax:
public virtual void Freeze(
   Context newContext
);
Parameters:

newContext

The context to freeze.

Implements:
IContextProperty.Freeze
Remarks
Context properties cannot be added after the context has been frozen.

Return to top


Overridden Method: GetHashCode()
Summary
Returns the hashcode for this instance of ContextAttribute.
This type supports the Shared Source CLI infrastructure and is not intended to be used directly from your code.
C# Syntax:
public override int GetHashCode();
Return Value:
The hashcode for this instance of ContextAttribute.

Return to top


Method: GetPropertiesForNewContext(
   IConstructionCallMessage ctorMsg
)
Summary
Adds the current context property to the given IConstructionCallMessagectorMsg.
This type supports the Shared Source CLI infrastructure and is not intended to be used directly from your code.
C# Syntax:
public virtual void GetPropertiesForNewContext(
   IConstructionCallMessage ctorMsg
);
Parameters:

ctorMsg

The IConstructionCallMessage to which to add the context property.

Exceptions
Exception Type Condition
ArgumentNullException The ctorMsg parameter is null.
Implements:
IContextAttribute.GetPropertiesForNewContext
Remarks
The ContextAttribute is an implementation of an IContextProperty. The ContextAttribute.GetPropertiesForNewContext method adds the property to the given IConstructionCallMessage so that when the message is received, the new object could be created in the required context environment.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: IsContextOK(
   Context ctx,
   IConstructionCallMessage ctorMsg
)
Summary
Returns a Boolean value indicating whether the context parameter meets the context attribute's requirements.
This type supports the Shared Source CLI infrastructure and is not intended to be used directly from your code.
C# Syntax:
public virtual bool IsContextOK(
   Context ctx,
   IConstructionCallMessage ctorMsg
);
Parameters:

ctx

The context in which to check.

ctorMsg

Return Value:
true if the passed in context is OK; false otherwise.
Exceptions
Exception Type Condition
ArgumentNullException The ctx or ctorMsg parameter is null.
Implements:
IContextAttribute.IsContextOK

Return to top


Method: IsDefaultAttribute()
Inherited
See base class member description: System.Attribute.IsDefaultAttribute

Summary
When overridden in a derived class, returns an indication whether the value of this instance is the default value for the derived class.
C# Syntax:
public virtual bool IsDefaultAttribute();
Return Value:
true if this instance is the default attribute for the class; otherwise, false.
Remarks
The default implementation of this class returns false, and must be implemented in the derived class to be useful to that class.

The implementation of this method in a derived class compares the value of this instance to a standard, default value obtained by some means, then returns a Boolean value that indicates whether the value of this instance is equal to the standard. The standard value is typically coded as a constant in the implementation, or stored programmatically in a field used by the implementation.

Return to top


Method: IsNewContextOK(
   Context newCtx
)
Summary
Returns a Boolean value indicating whether the context property is OK with the new context.
This type supports the Shared Source CLI infrastructure and is not intended to be used directly from your code.
C# Syntax:
public virtual bool IsNewContextOK(
   Context newCtx
);
Parameters:

newCtx

The new Context in which the ContextProperty has been created.

Return Value:
true if the context property is OK with the new context; false otherwise.
Implements:
IContextProperty.IsNewContextOK
Remarks
Once all the context properties have been added to the new context, they are all asked whether they are OK in the new context. The context property could look at the other context properties in Context.ContextProperties of the new context, and determine whether it is compatible with these other context properties.

Note Default implementation of the method returns true.

Return to top


Method: Match(
   object obj
)
Inherited
See base class member description: System.Attribute.Match

Summary
When overridden in a derived class, returns a value indicating whether this instance equals a specified object.
C# Syntax:
public virtual bool Match(
   object obj
);
Parameters:

obj

An Object to compare with this instance of Attribute.

Return Value:
true if this instance equals obj; otherwise, false.
Remarks
This method determines if one Attribute equals another. Its default implementation is the same as Attribute.Equals, which performs a value and reference comparison. Override this method to implement support for attribute values, such as flags or bitfields, that consist of components that are meaningful in themselves. For example, consider an attribute whose value is a binary field divided into a bitfield of flags. Two instances of this attribute have one flag in set in common while all the other flags differ. The Equal method cannot determine that the two instances have the same flag set, but the Match method can.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.