似乎过高地确定一种无效的类型的价值,并实行冻结。 是否有更好的办法这样做?
Private _WorkPhone As Long?
Public Property [WorkPhone]() As Long?
Get
Return _WorkPhone
End Get
Set(ByVal value As Long?)
If value.HasValue = False Then
If _WorkPhone.HasValue = True Then
MyBase.RaisePropertyChanging("WorkPhone")
_WorkPhone = Nothing
MyBase.MarkDirty()
MyBase.RaisePropertyChanged("WorkPhone")
End If
Else
If _WorkPhone.HasValue Then
If _WorkPhone.Value <> value.Value Then
MyBase.RaisePropertyChanging("WorkPhone")
_WorkPhone = value
MyBase.MarkDirty()
MyBase.RaisePropertyChanged("WorkPhone")
End If
Else
MyBase.RaisePropertyChanging("WorkPhone")
_WorkPhone = value
MyBase.MarkDirty()
End If
MyBase.RaisePropertyChanged("WorkPhone")
End If
End Set
End Property
我尝试使用简单的法典,但我在上的休息点。 MyBase.RaisePropertyChanging(“WorkPhone”)从未受到过任何打击,其价值从未发生变化。
If _WorkPhone <> value Then
MyBase.RaisePropertyChanging("WorkPhone")
_WorkPhone = value
MyBase.MarkDirty()
MyBase.RaisePropertyChanged("WorkPhone")
End If