System.CodeDom.CodeTypeDelegate Class

Assembly: System.dll
Namespace: System.CodeDom
Summary
Represents a delegate declaration.
C# Syntax:
[Serializable]
public class CodeTypeDelegate : CodeTypeDeclaration
Remarks
CodeTypeDelegate can be used to declare a delegate type, or event handler. A delegate defines a method signature that can be used by calback methods or event handlers. Delegates can be declared at the namespace level or nested inside other types. Delegates cannot be nested inside other delegates.

CodeTypeDelegate should not be used for enumeration, interface, or type declaration. Instead, use CodeTypeDeclaration for those.



Note Not all languages support the declaration of delegates. Call ICodeGenerator.Supports with the GeneratorSupport.DeclareDelegates flag to determine if it is supported in a particular language.
See also:
System.CodeDom Namespace

System.CodeDom.CodeTypeDelegate Member List:

Public Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the CodeTypeDelegate class.
ctor #2 Overloaded:
.ctor(string name)

Initializes a new instance of the CodeTypeDelegate class.
Public Properties
Attributes
(inherited from System.CodeDom.CodeTypeMember)
Read-write

See base class member description: System.CodeDom.CodeTypeMember.Attributes


Gets or sets the attributes of the member.
BaseTypes
(inherited from System.CodeDom.CodeTypeDeclaration)
Read-only

See base class member description: System.CodeDom.CodeTypeDeclaration.BaseTypes


Gets the base types of the types.
Comments
(inherited from System.CodeDom.CodeTypeMember)
Read-only

See base class member description: System.CodeDom.CodeTypeMember.Comments


Gets the comment collection for the type member.
CustomAttributes
(inherited from System.CodeDom.CodeTypeMember)
Read-write

See base class member description: System.CodeDom.CodeTypeMember.CustomAttributes


Gets or sets the custom attributes of the member.
IsClass
(inherited from System.CodeDom.CodeTypeDeclaration)
Read-write

See base class member description: System.CodeDom.CodeTypeDeclaration.IsClass


Gets or sets a value indicating whether the type is a class or reference type.
IsEnum
(inherited from System.CodeDom.CodeTypeDeclaration)
Read-write

See base class member description: System.CodeDom.CodeTypeDeclaration.IsEnum


Gets or sets a value indicating whether the type is an enumeration.
IsInterface
(inherited from System.CodeDom.CodeTypeDeclaration)
Read-write

See base class member description: System.CodeDom.CodeTypeDeclaration.IsInterface


Gets or sets a value indicating whether the type is an interface.
IsStruct
(inherited from System.CodeDom.CodeTypeDeclaration)
Read-write

See base class member description: System.CodeDom.CodeTypeDeclaration.IsStruct


Gets or sets a value indicating whether the types is a value type (struct).
LinePragma
(inherited from System.CodeDom.CodeTypeMember)
Read-write

See base class member description: System.CodeDom.CodeTypeMember.LinePragma


Gets or sets the line the statement occurs on.
Members
(inherited from System.CodeDom.CodeTypeDeclaration)
Read-only

See base class member description: System.CodeDom.CodeTypeDeclaration.Members


Gets the collection of class members for the represented type.
Name
(inherited from System.CodeDom.CodeTypeMember)
Read-write

See base class member description: System.CodeDom.CodeTypeMember.Name


Gets or sets the name of the member.
Parameters Read-only

Gets the parameters of the delegate.
ReturnType Read-write

Gets or sets the return type of the delegate.
TypeAttributes
(inherited from System.CodeDom.CodeTypeDeclaration)
Read-write

See base class member description: System.CodeDom.CodeTypeDeclaration.TypeAttributes


Gets or sets the attributes of the type.
UserData
(inherited from System.CodeDom.CodeObject)
Read-only

See base class member description: System.CodeDom.CodeObject.UserData


Gets or sets the user-definable data for the current object.
Public Methods
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Public Events
PopulateBaseTypes
(inherited from System.CodeDom.CodeTypeDeclaration)
See base class member description: System.CodeDom.CodeTypeDeclaration.PopulateBaseTypes


Occurs when the CodeTypeDeclaration.BaseTypes collection is accessed for the first time.
PopulateMembers
(inherited from System.CodeDom.CodeTypeDeclaration)
See base class member description: System.CodeDom.CodeTypeDeclaration.PopulateMembers


Occurs when the CodeTypeDeclaration.Members collection is accessed for the first time.
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.CodeDom.CodeTypeDelegate Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the CodeTypeDelegate class.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public CodeTypeDelegate();

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the CodeTypeDelegate class.
C# Syntax:
public CodeTypeDelegate(
   string name
);
Parameters:

name

The name of the delegate.

Return to top


Property: Attributes (read-write)
Inherited
See base class member description: System.CodeDom.CodeTypeMember.Attributes

Summary
Gets or sets the attributes of the member.
C# Syntax:
public MemberAttributes Attributes {get; set;}
Remarks
This property is used to specify attributes of the type member. Some types of attributes are Access (Public/Private) and Scope (Final/Override).
See also:
MemberAttributes

Return to top


Property: BaseTypes (read-only)
Inherited
See base class member description: System.CodeDom.CodeTypeDeclaration.BaseTypes

Summary
Gets the base types of the types.
C# Syntax:
public CodeTypeReferenceCollection BaseTypes {get;}
See also:
CodeTypeReferenceCollection

Return to top


Property: Comments (read-only)
Inherited
See base class member description: System.CodeDom.CodeTypeMember.Comments

Summary
Gets the comment collection for the type member.
C# Syntax:
public CodeCommentStatementCollection Comments {get;}
Remarks
Any comments in this collection will be written to the generated source file just before the declaration of the member.
See also:
CodeCommentStatementCollection

Return to top


Property: CustomAttributes (read-write)
Inherited
See base class member description: System.CodeDom.CodeTypeMember.CustomAttributes

Summary
Gets or sets the custom attributes of the member.
C# Syntax:
public CodeAttributeDeclarationCollection CustomAttributes {get; set;}
Remarks
This property can be used to add metadata attributes to the declaration of the member. This property is null by default and should be checked before referencing.
See also:
CodeAttributeDeclarationCollection

Return to top


Property: IsClass (read-write)
Inherited
See base class member description: System.CodeDom.CodeTypeDeclaration.IsClass

Summary
Gets or sets a value indicating whether the type is a class or reference type.
C# Syntax:
public bool IsClass {get; set;}

Return to top


Property: IsEnum (read-write)
Inherited
See base class member description: System.CodeDom.CodeTypeDeclaration.IsEnum

Summary
Gets or sets a value indicating whether the type is an enumeration.
C# Syntax:
public bool IsEnum {get; set;}

Return to top


Property: IsInterface (read-write)
Inherited
See base class member description: System.CodeDom.CodeTypeDeclaration.IsInterface

Summary
Gets or sets a value indicating whether the type is an interface.
C# Syntax:
public bool IsInterface {get; set;}

Return to top


Property: IsStruct (read-write)
Inherited
See base class member description: System.CodeDom.CodeTypeDeclaration.IsStruct

Summary
Gets or sets a value indicating whether the types is a value type (struct).
C# Syntax:
public bool IsStruct {get; set;}

Return to top


Property: LinePragma (read-write)
Inherited
See base class member description: System.CodeDom.CodeTypeMember.LinePragma

Summary
Gets or sets the line the statement occurs on.
C# Syntax:
public CodeLinePragma LinePragma {get; set;}
Remarks
This property indicates the location of the type member declaration. This property can be used for purposes of error reporting and debugging. This can be useful when code is generated based on a template file. This value is null by default and should be checked before referencing.
See also:
CodeLinePragma

Return to top


Property: Members (read-only)
Inherited
See base class member description: System.CodeDom.CodeTypeDeclaration.Members

Summary
Gets the collection of class members for the represented type.
C# Syntax:
public CodeTypeMemberCollection Members {get;}
See also:
CodeTypeMemberCollection

Return to top


Property: Name (read-write)
Inherited
See base class member description: System.CodeDom.CodeTypeMember.Name

Summary
Gets or sets the name of the member.
C# Syntax:
public string Name {get; set;}

Return to top


Property: Parameters (read-only)
Summary
Gets the parameters of the delegate.
C# Syntax:
public CodeParameterDeclarationExpressionCollection Parameters {get;}
See also:
CodeParameterDeclarationExpressionCollection

Return to top


Property: ReturnType (read-write)
Summary
Gets or sets the return type of the delegate.
C# Syntax:
public CodeTypeReference ReturnType {get; set;}

Return to top


Property: TypeAttributes (read-write)
Inherited
See base class member description: System.CodeDom.CodeTypeDeclaration.TypeAttributes

Summary
Gets or sets the attributes of the type.
C# Syntax:
public TypeAttributes TypeAttributes {get; set;}
Remarks
The TypeAttributes property contains the same type of values used by System.Reflection when investigating a type at run time. Many of these flags do not correspond to the type declaration syntax for some languages. As a result, only the following flags are significant to CodeTypeDeclaration: TypeAttributes.Class, TypeAttributes.Interface, TypeAttributes.Abstract, TypeAttributes.Sealed, TypeAttributes.Public, TypeAttributes.NotPublic, TypeAttributes.NestedPublic, and TypeAttributes.NestedPrivate.

Note Some of the flags such as TypeAttributes.Abstract overlap with the meaning of flags in the the CodeTypeMember.Attributes property of CodeTypeDeclaration that is inherited from CodeTypeMember. The CodeTypeMember.Attributes property is a side-effect of the CodeTypeDeclaration class inheriting from CodeTypeMember so that classes can be nested. The flags in the CodeTypeDeclaration.TypeAttributes property should be used instead of the flags in the CodeTypeMember.Attributes property.
See also:
TypeAttributes

Return to top


Property: UserData (read-only)
Inherited
See base class member description: System.CodeDom.CodeObject.UserData

Summary
Gets or sets the user-definable data for the current object.
C# Syntax:
public IDictionary UserData {get;}
Remarks


Notes to inheritors: An inheritor can design the way this user data is stored, retrieved, and used.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

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

Return to top


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

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

Return to top


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

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

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: 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


Event: PopulateBaseTypes
Inherited
See base class member description: System.CodeDom.CodeTypeDeclaration.PopulateBaseTypes

Summary
Occurs when the CodeTypeDeclaration.BaseTypes collection is accessed for the first time.
C# Syntax:
public event EventHandler PopulateBaseTypes;

Return to top


Event: PopulateMembers
Inherited
See base class member description: System.CodeDom.CodeTypeDeclaration.PopulateMembers

Summary
Occurs when the CodeTypeDeclaration.Members collection is accessed for the first time.
C# Syntax:
public event EventHandler PopulateMembers;

Return to top


Top of page

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