CodeDirectionExpression Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents an expression used as a method invoke parameter along with a reference direction indicator.
public ref class CodeDirectionExpression : System::CodeDom::CodeExpression
public class CodeDirectionExpression : System.CodeDom.CodeExpression
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeDirectionExpression : System.CodeDom.CodeExpression
type CodeDirectionExpression = class
inherit CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeDirectionExpression = class
inherit CodeExpression
Public Class CodeDirectionExpression
Inherits CodeExpression
- Inheritance
- Attributes
Examples
The following example demonstrates use of a CodeDirectionExpression to specify a field direction modifier for an expression to pass as a method parameter.
// Declares a parameter passed by reference using a CodeDirectionExpression.
array<CodeDirectionExpression^>^param1 = {gcnew CodeDirectionExpression( FieldDirection::Ref,gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"TestParameter" ) )};
// Invokes a method on this named TestMethod using the direction expression as a parameter.
CodeMethodInvokeExpression^ methodInvoke1 = gcnew CodeMethodInvokeExpression( gcnew CodeThisReferenceExpression,"TestMethod",param1 );
// A C# code generator produces the following source code for the preceeding example code:
// this.TestMethod(ref TestParameter);
// Declares a parameter passed by reference using a CodeDirectionExpression.
CodeDirectionExpression param1 = new CodeDirectionExpression(FieldDirection.Ref, new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), "TestParameter" ));
// Invokes a method on this named TestMethod using the direction expression as a parameter.
CodeMethodInvokeExpression methodInvoke1 = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "TestMethod", param1 );
// A C# code generator produces the following source code for the preceeding example code:
// this.TestMethod(ref TestParameter);
' Declares a parameter passed by reference using a CodeDirectionExpression.
Dim param1 As New CodeDirectionExpression(FieldDirection.Ref, New CodeFieldReferenceExpression(New CodeThisReferenceExpression(), "TestParameter"))
' Invokes a method on this named TestMethod using the direction expression as a parameter.
Dim methodInvoke1 As New CodeMethodInvokeExpression(New CodeThisReferenceExpression(), "TestMethod", param1)
' A Visual Basic code generator produces the following source code for the preceeding example code:
' Me.TestMethod("TestParameter")
Remarks
CodeDirectionExpression can represent a parameter passed to a method and the reference direction of the parameter.
The Expression property indicates the expression to qualify with a direction. The Direction property indicates the direction of the parameter using one of the FieldDirection enumeration values.
Note
CodeDirectionExpression is intended to be used as a method invoke parameter, and should not be used when declaring methods.
Constructors
CodeDirectionExpression() |
Initializes a new instance of the CodeDirectionExpression class. |
CodeDirectionExpression(FieldDirection, CodeExpression) |
Initializes a new instance of the CodeDirectionExpression class using the specified field direction and expression. |
Properties
Direction |
Gets or sets the field direction for this direction expression. |
Expression |
Gets or sets the code expression to represent. |
UserData |
Gets the user-definable data for the current object. (Inherited from CodeObject) |
Methods
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |