Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CodePropertySetValueReferenceExpression Class

Represents the value argument of a property set method call within a property set method.

For a list of all members of this type, see CodePropertySetValueReferenceExpression Members.

System.Object
   System.CodeDom.CodeObject
      System.CodeDom.CodeExpression
         System.CodeDom.CodePropertySetValueReferenceExpression

[Visual Basic]
<Serializable>
<ClassInterface(ClassInterfaceType.AutoDispatch)>
<ComVisible(True)>
Public Class CodePropertySetValueReferenceExpression
   Inherits CodeExpression
[C#]
[Serializable]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ComVisible(true)]
public class CodePropertySetValueReferenceExpression :
   CodeExpression
[C++]
[Serializable]
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ComVisible(true)]
public __gc class CodePropertySetValueReferenceExpression :
   public CodeExpression
[JScript]
public
   Serializable
 ClassInterface(ClassInterfaceType.AutoDispatch)
 ComVisible(true)
class CodePropertySetValueReferenceExpression extends
   CodeExpression

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

CodePropertySetValueReferenceExpression represents the value argument of a property set method call within a property set method declaration.

A property set method typically assigns or uses the value assigned to the property. Within the property set method, this value is represented by an implicit variable represented in CodeDOM by a CodePropertySetValueReferenceExpression.

Example

[Visual Basic, C#, C++] This example demonstrates use of a CodePropertySetValueReferenceExpression to represent the value argument passed to a property set value statement block.

[Visual Basic] 
' 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

[C#] 
// 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;
//            }
//        }
//    }

[C++] 
// Declares a type.
CodeTypeDeclaration* type1 = new CodeTypeDeclaration(S"Type1");

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

// Declares an integer field.
CodeMemberField* field1 = new CodeMemberField(S"System.Int32", S"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(), S"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(), S"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;
//            }
//        }
//    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.CodeDom

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

CodePropertySetValueReferenceExpression Members | System.CodeDom Namespace

Show:
© 2015 Microsoft