I need to represent that a property on an object is different from that of another datasourace. I have two data sources, and when I pull from one of the datasources, I need a way to determine if any of the properties of the object from that datasource are different from the other datasource.
DSA
Object1.Value = 3
DSB
Object1.Value = 4
Obviously, determining that they are different is easy. What i want, however, is the ability to say that DSB.Object1.Value is “different” without needing to also pass the object from DSA to a view.
My initial approach is to have a PropertyWrapper class
public class PropertyWrapper<T>
{
T value;
bool different;
}
Is there a better way to represent this through attributes or extensions?
EDIT: Changed from a “Changed” to a “Different” representation. I don’t need real time “changes”, instead I need a representation that the property is not the same as the same property of the same object from another data source.
Considering that you pull it from datasource, the first solution that comes to me is using some inside
booleanfield, sayIsChanged.In other words:
The “operator” who operates over that objects should take care of changing a state/field inside it, in order to notify to outside world that something was changed in that object.
There is no easy solution for this, but you can define some generic interface, like
INotifyPropertyChanged, or invent your own, whom methodSignalChangedis called on every propertysetfunction.Just an idea, there are could be plenty other solutions.