D
Dathan
I'm migrating a forms project from using Visual Studio's designer-
generated data binding objects (dataset, strongly typed data tables,
etc.) to binding to objects that encapsulate my application's business
logic. I'd like to provide support for transactions on these
objects. I've found the IEditableObject interface, which (correct me
if I'm wrong) provides the standard interface for objects that support
transactions. Now I'm wondering how best to implement this
internally. Is there a framework class for providing this sort of
support? If not, is there a "standard" way to implement this
functionality?
Let's say one of my objects is person. Here's more or less what I've
got so far:
public class Person
{
internal Hashtable original;
internal Hashtable current;
public Person()
{
this.original = new Hashtable();
this.original.Add("FirstName", null);
this.original.add("LastName", null);
this.current = this.original.Clone();
}
public string FirstName
{
get
{
return this.current["FirstName"];
}
set
{
this.current["FirstName"] = value;
}
}
public string LastName
{
get
{
return this.current["LastName"];
}
set
{
this.current["LastName"] = value;
}
}
public void Reset()
{
// reset current state to original state
this.current = this.original.Clone();
}
}
The original state is initialized by an adapter class that
deserializes a Person instance from my data store. Assuming the
values stored in the hashtable are immutable, initializing the current
member using original.Clone() should be fine, right? But more
importantly, is this the "right" way to provide this sort of
functionality?
generated data binding objects (dataset, strongly typed data tables,
etc.) to binding to objects that encapsulate my application's business
logic. I'd like to provide support for transactions on these
objects. I've found the IEditableObject interface, which (correct me
if I'm wrong) provides the standard interface for objects that support
transactions. Now I'm wondering how best to implement this
internally. Is there a framework class for providing this sort of
support? If not, is there a "standard" way to implement this
functionality?
Let's say one of my objects is person. Here's more or less what I've
got so far:
public class Person
{
internal Hashtable original;
internal Hashtable current;
public Person()
{
this.original = new Hashtable();
this.original.Add("FirstName", null);
this.original.add("LastName", null);
this.current = this.original.Clone();
}
public string FirstName
{
get
{
return this.current["FirstName"];
}
set
{
this.current["FirstName"] = value;
}
}
public string LastName
{
get
{
return this.current["LastName"];
}
set
{
this.current["LastName"] = value;
}
}
public void Reset()
{
// reset current state to original state
this.current = this.original.Clone();
}
}
The original state is initialized by an adapter class that
deserializes a Person instance from my data store. Assuming the
values stored in the hashtable are immutable, initializing the current
member using original.Clone() should be fine, right? But more
importantly, is this the "right" way to provide this sort of
functionality?