CodePropertySetValueReferenceExpression Clase

Definición

Representa el argumento de valor de una llamada al método set de una propiedad dentro de un método set de una propiedad.

public ref class CodePropertySetValueReferenceExpression : System::CodeDom::CodeExpression
public class CodePropertySetValueReferenceExpression : System.CodeDom.CodeExpression
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodePropertySetValueReferenceExpression : System.CodeDom.CodeExpression
type CodePropertySetValueReferenceExpression = class
    inherit CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodePropertySetValueReferenceExpression = class
    inherit CodeExpression
Public Class CodePropertySetValueReferenceExpression
Inherits CodeExpression
Herencia
CodePropertySetValueReferenceExpression
Atributos

Ejemplos

En este ejemplo se muestra el uso de para CodePropertySetValueReferenceExpression representar el argumento value pasado a un bloque de instrucción value del conjunto de propiedades.

// Declares a type.
CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "Type1" );

// Declares a constructor.
CodeConstructor^ constructor1 = gcnew CodeConstructor;
constructor1->Attributes = MemberAttributes::Public;
type1->Members->Add( constructor1 );

// Declares an integer field.
CodeMemberField^ field1 = gcnew CodeMemberField( "System.Int32","integerField" );
type1->Members->Add( field1 );

// Declares a property.
CodeMemberProperty^ property1 = gcnew CodeMemberProperty;

// Declares a property get statement to return the value of the integer field.
property1->GetStatements->Add( gcnew CodeMethodReturnStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"integerField" ) ) );

// Declares a property set statement to set the value to the integer field.
// The CodePropertySetValueReferenceExpression represents the value argument passed to the property set statement.
property1->SetStatements->Add( gcnew CodeAssignStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"integerField" ),gcnew CodePropertySetValueReferenceExpression ) );
type1->Members->Add( property1 );

// A C# code generator produces the following source code for the preceeding example code:
//    public class Type1 
//    {
//
//        private int integerField;
//
//        public Type1() 
//        {
//        }
//                            
//        private int integerProperty 
//        {
//            get 
//            {
//                return this.integerField;
//            }
//            set 
//            {
//                this.integerField = value;
//            }
//        }
//    }
// Declares a type.
CodeTypeDeclaration type1 = new CodeTypeDeclaration("Type1");

// Declares a constructor.
CodeConstructor constructor1 = new CodeConstructor();
constructor1.Attributes = MemberAttributes.Public;
type1.Members.Add( constructor1 );

// Declares an integer field.
CodeMemberField field1 = new CodeMemberField("System.Int32", "integerField");
type1.Members.Add( field1 );

// Declares a property.
CodeMemberProperty property1 = new CodeMemberProperty();
// Declares a property get statement to return the value of the integer field.
property1.GetStatements.Add( new CodeMethodReturnStatement( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "integerField") ) );
// Declares a property set statement to set the value to the integer field.
// The CodePropertySetValueReferenceExpression represents the value argument passed to the property set statement.
property1.SetStatements.Add( new CodeAssignStatement( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "integerField"),
                                    new CodePropertySetValueReferenceExpression() ) );
type1.Members.Add( property1 );

// A C# code generator produces the following source code for the preceeding example code:

//    public class Type1
//    {
//
//        private int integerField;
//
//        public Type1()
//        {
//        }
//
//        private int integerProperty
//        {
//            get
//            {
//                return this.integerField;
//            }
//            set
//            {
//                this.integerField = value;
//            }
//        }
//    }
' Declares a type.
Dim type1 As New CodeTypeDeclaration("Type1")

' Declares a constructor.
Dim constructor1 As New CodeConstructor()
constructor1.Attributes = MemberAttributes.Public
type1.Members.Add(constructor1)

' Declares an integer field.
Dim field1 As New CodeMemberField("System.Int32", "integerField")
type1.Members.Add(field1)

' Declares a property.
Dim property1 As New CodeMemberProperty()
' Declares a property get statement to return the value of the integer field.
property1.GetStatements.Add(New CodeMethodReturnStatement(New CodeFieldReferenceExpression(New CodeThisReferenceExpression(), "integerField")))
' Declares a property set statement to set the value to the integer field.
' The CodePropertySetValueReferenceExpression represents the value argument passed to the property set statement.
property1.SetStatements.Add(New CodeAssignStatement(New CodeFieldReferenceExpression(New CodeThisReferenceExpression(), "integerField"), New CodePropertySetValueReferenceExpression()))
type1.Members.Add(property1)

' A Visual Basic code generator produces the following source code for the preceeding example code:

'   Public Class Type1
'
'       Private integerField As Integer
'
'       Public Sub New()
'           MyBase.New()
'       End Sub
'
'       Private Property integerProperty() As Integer
'           Get
'               Return Me.integerField
'           End Get
'           Set(ByVal Value As Integer)
'               Me.integerField = value
'           End Set
'       End Property
'   End Class

Comentarios

CodePropertySetValueReferenceExpression representa el argumento value de una llamada de método de conjunto de propiedades dentro de una declaración de método de conjunto de propiedades.

Normalmente, un método de conjunto de propiedades asigna o usa el valor asignado a la propiedad . Dentro del método de conjunto de propiedades, este valor se representa mediante una variable implícita representada en CodeDOM por .CodePropertySetValueReferenceExpression

Constructores

CodePropertySetValueReferenceExpression()

Inicializa una nueva instancia de la clase CodePropertySetValueReferenceExpression.

Propiedades

UserData

Obtiene los datos definibles por el usuario para el objeto actual.

(Heredado de CodeObject)

Métodos

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.

(Heredado de Object)
GetHashCode()

Sirve como la función hash predeterminada.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Se aplica a