D
Daniel Walzenbach
Hi,
I need to track all changes made to an object. Consider the following class:
Public Class Dog
Private _Name As System.String
Private _Weight As System.Byte
Public Property Name() As System.String
Get
Return _Name
End Get
Set(ByVal Value As System.String)
_Name = Value
End Set
End Property
Public Property Weight() As System.Byte
Get
Return _Weight
End Get
Set(ByVal Value As System.Byte)
_Weight = Value
End Set
End Property
Public Sub New(ByVal Name As System.String)
_Name = Name
End Sub
End Class
For the sake of understanding let's create a dog called "Fido" and - as it is still a puppy - assign a weight of 5 (let this be kg, pound, what ever.) to it.
Dim myDog As New Dog("Fido")
myDog.Weight = 5
' Fido get's saved to a database
As Fido gains more weight with the ages the following changes are made.
' Fido get's loaded from a database
myDog.Weight = 10
I now want to be able to track all the changes made to the Fido-Object during its lifetime. I thought about creating an XML file like the following using the properties of my class to save every change to Fido:
<?xml version="1.0" encoding="utf-8" ?>
<LogFile>
<Dog>
<Name>Fido</Name>
<Weight>5</Weight>
</Dog>
</LogFile>
<?xml version="1.0" encoding="utf-8" ?>
<LogFile>
<Dog>
<Weight>10</Weight>
</Dog>
</LogFile>
I now could store all the changes as an ntext (for they might get really long depending on the underlying object) in a database and display them in a DataGrid (or any other display of my choice) if it is possible to merge all the XML-Files into one big one?? Does anybody know how this merge can be done? I also assume that I have to use the system.Xml.XmlDataDocument class to create the XML-File but I am not sure how.
I also am absolutely not positive if this is a good approach to track changes of an object. What would be a better approach to track changes of an object on your opinion?
Thank you a huge lot in advance.
Daniel Walzenbach
I need to track all changes made to an object. Consider the following class:
Public Class Dog
Private _Name As System.String
Private _Weight As System.Byte
Public Property Name() As System.String
Get
Return _Name
End Get
Set(ByVal Value As System.String)
_Name = Value
End Set
End Property
Public Property Weight() As System.Byte
Get
Return _Weight
End Get
Set(ByVal Value As System.Byte)
_Weight = Value
End Set
End Property
Public Sub New(ByVal Name As System.String)
_Name = Name
End Sub
End Class
For the sake of understanding let's create a dog called "Fido" and - as it is still a puppy - assign a weight of 5 (let this be kg, pound, what ever.) to it.
Dim myDog As New Dog("Fido")
myDog.Weight = 5
' Fido get's saved to a database
As Fido gains more weight with the ages the following changes are made.
' Fido get's loaded from a database
myDog.Weight = 10
I now want to be able to track all the changes made to the Fido-Object during its lifetime. I thought about creating an XML file like the following using the properties of my class to save every change to Fido:
<?xml version="1.0" encoding="utf-8" ?>
<LogFile>
<Dog>
<Name>Fido</Name>
<Weight>5</Weight>
</Dog>
</LogFile>
<?xml version="1.0" encoding="utf-8" ?>
<LogFile>
<Dog>
<Weight>10</Weight>
</Dog>
</LogFile>
I now could store all the changes as an ntext (for they might get really long depending on the underlying object) in a database and display them in a DataGrid (or any other display of my choice) if it is possible to merge all the XML-Files into one big one?? Does anybody know how this merge can be done? I also assume that I have to use the system.Xml.XmlDataDocument class to create the XML-File but I am not sure how.
I also am absolutely not positive if this is a good approach to track changes of an object. What would be a better approach to track changes of an object on your opinion?
Thank you a huge lot in advance.
Daniel Walzenbach