Geordielads
New member
- Joined
- Nov 14, 2006
- Messages
- 3
- Programming Experience
- 5-10
Hi
Im trying to create a class that can hold historical information about the state of the object.
i.e. I have a Surname object which on loading holds the string "Bloggs", when this is updated it keeps a record of "Bloggs" incase it needs to revert back, similar to how a datarow uses the DataRowVersion.
This isnt a huge problem until I want to access the object like a string using a default property i.e. mySurname = "Bloggs" and not mySurname.Value = "Bloggs"
Does anyone know a way of assigning a default property where I dont need to pass a parameter?
How does the String class actually work to do this?
Here is what I have so far, but this requires the assignment like mySurname.Value = "Bloggs".
Public Class SystemString
Private Current As String = ""
Private Original As String = ""
Public Property Value(Optional ByVal version As ItemVersion = ItemVersion.Current) As String
Get
If version = ItemVersion.Original Then
Return Original
Else
Return Current
End If
End Get
Set(ByVal Value As String)
Original = Current
Current = Value
End Set
End Property
End Class
Public Enum ItemVersion
Current = 0
Original = 1
End Enum
Im trying to create a class that can hold historical information about the state of the object.
i.e. I have a Surname object which on loading holds the string "Bloggs", when this is updated it keeps a record of "Bloggs" incase it needs to revert back, similar to how a datarow uses the DataRowVersion.
This isnt a huge problem until I want to access the object like a string using a default property i.e. mySurname = "Bloggs" and not mySurname.Value = "Bloggs"
Does anyone know a way of assigning a default property where I dont need to pass a parameter?
How does the String class actually work to do this?
Here is what I have so far, but this requires the assignment like mySurname.Value = "Bloggs".
Public Class SystemString
Private Current As String = ""
Private Original As String = ""
Public Property Value(Optional ByVal version As ItemVersion = ItemVersion.Current) As String
Get
If version = ItemVersion.Original Then
Return Original
Else
Return Current
End If
End Get
Set(ByVal Value As String)
Original = Current
Current = Value
End Set
End Property
End Class
Public Enum ItemVersion
Current = 0
Original = 1
End Enum