Compartilhar via


ComplexObject.ValidateProperty Method (String, Object)

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Validate whether the specified value is valid for the specified property of the current complex object.

Namespace:  System.ServiceModel.DomainServices.Client
Assembly:  System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)

Syntax

'Declaration
Protected Sub ValidateProperty ( _
    propertyName As String, _
    value As Object _
)
'Usage
Dim propertyName As String
Dim value As Object

Me.ValidateProperty(propertyName, _
    value)
protected void ValidateProperty(
    string propertyName,
    Object value
)
protected:
void ValidateProperty(
    String^ propertyName, 
    Object^ value
)
member ValidateProperty : 
        propertyName:string * 
        value:Object -> unit 
protected function ValidateProperty(
    propertyName : String, 
    value : Object
)

Parameters

  • propertyName
    Type: System.String
    The name of the property to validate.
  • value
    Type: System.Object
    The value to test. It may be nulla null reference (Nothing in Visual Basic) if nulla null reference (Nothing in Visual Basic) is valid for the specified property.

Exceptions

Exception Condition
ArgumentNullException

propertyName is nulla null reference (Nothing in Visual Basic).

InvalidOperationException

The property is marked with EditableAttribute configured to prevent editing.

Remarks

This method evaluates the ValidationAttribute associated with the specified property, accumulating the validation errors and surfacing them through the ValidationErrors property.

This method also verifies that the property is not read-only.

All validation logic is bypassed if this instance is currently being deserialized.

Examples

Public Property Address() As String
    Get
        Return m_address
    End Get
    Set(ByVal value As String)
        If Me.m_address <> value Then
            Me.ValidateProperty("Address", value)
            Me.m_address = value
            Me.RaisePropertyChanged("Address")
        End If
    End Set
End Property
public string Address
{
    get
    {
        return this.address;
    }
    set
    {
        if (this.address != value)
        {
            this.ValidateProperty("Address", value);
            this.Address = value;
            this.RaisePropertyChanged("Address");
        }
    }
}

See Also

Reference

ComplexObject Class

ValidateProperty Overload

System.ServiceModel.DomainServices.Client Namespace