Hey Codeproject,
I have a class called UIControl, and I've also made derived class like UIControlButton, UIControlImageBox. I've stored all of these in a List<uicontrol>.
Is there any way to check if any changes have been made to the objects in the List that isn't just Added or Removed an object?
I really want to make sure there's no cleaner way to check if any changes have been made than to compare all properties each time they're set in each individual class.
So in a nutshell, how do I figure out if an object's properties have changed by not using the object.Equal method since that would compare whether or not an object is in the same memory location -- and also using a method that would not require a dirty method like checking all properties for each method directly within the object itself.
Best Regards,
- Eds.
What I have tried:
I've tried doing a dirty method by just comparing one list to another list, one containing the objects whilst not changed, and one that could possibly changed, comparing those objects and in case they're different setting the old item to the new item and trigger an event like so:
public bool IsIdentical(UIControl Control, UIControl Other)
{
if(Control.GetType() != Other.GetType())
{
return false;
}
if(!Control.Name.Equals(Other.Name))
{
return false;
}
return false;
}
The problem however is that some derived controls have other or multiple values, and I don't think it's a great idea to make 100s of overloads for each different control.