Custom business object comparer
Posted
by
gruber
on Stack Overflow
See other posts from Stack Overflow
or by gruber
Published on 2011-01-04T09:52:23Z
Indexed on
2011/01/04
9:53 UTC
Read the original article
Hit count: 215
Hello,
I need to implement mechanism that compares two business objects and return the list of differences (past value, new value, isDifferenceBetter).
Because not all fields of class has to be compared and one fields need to be compared with different function then the other (sometimes < is better sometimes > is better ... ) I figured out that I need to implelemnt custom attribute and give it to each field that has to be compared in this object.
This attribute must have: - name - delegate or sth to point to the function which would be applied for comparision (dont know how to do it so far)
So could anyone suggest me if its a good idea? Maybe any other ideas.
Using attributes I would be able to use refflection to iterate through each field with attribute and invoke needed delegate.
thanks for help bye
© Stack Overflow or respective owner