Silk
Well-Known Member
Disclaimer: Yes it's bad design, no I did not design it and if I were to design it, it'd be database driven.
I have a class that has literally hundreds of properties.
I have an app that needs to compare instances of this class. One or more properties may be different when comapring class A to class B, and they need flagging up if they are. Every single property is looped around and differences are flagged.
But for the best part in this app, there are no differences at all so the loop was needless work.
The classes being compared are different in such that they reference different areas of memory, that is, this test returns false:
ClassA is ClassB
.. That's because for the purpose of my test, they are actually copies of each other, i.e. I've got a Copy method which literally makes a new version of the class with the same contents in every property. As far as VB is concerned, they are different, but as far as a human is concerned, they are the same.
So I'm wondering if there's some quick way of making VB understand that they contain the same information rather than me having to loop around and check each property; as it turns out this is very time consuming (especially when some of the properties have loops to do summing.. sigh). Or if there's some clever way of snapshotting the entire contents of a class to a string/stream and doing a straight comparison there.
Any thoughts?
I have a class that has literally hundreds of properties.
I have an app that needs to compare instances of this class. One or more properties may be different when comapring class A to class B, and they need flagging up if they are. Every single property is looped around and differences are flagged.
But for the best part in this app, there are no differences at all so the loop was needless work.
The classes being compared are different in such that they reference different areas of memory, that is, this test returns false:
ClassA is ClassB
.. That's because for the purpose of my test, they are actually copies of each other, i.e. I've got a Copy method which literally makes a new version of the class with the same contents in every property. As far as VB is concerned, they are different, but as far as a human is concerned, they are the same.
So I'm wondering if there's some quick way of making VB understand that they contain the same information rather than me having to loop around and check each property; as it turns out this is very time consuming (especially when some of the properties have loops to do summing.. sigh). Or if there's some clever way of snapshotting the entire contents of a class to a string/stream and doing a straight comparison there.
Any thoughts?