I have a property in a composite control that checks to see if the value has changed prior to actually setting the related private field and doing a few other things.
However, it appears that it is never evaluating the statement.
Here is the code for the property:
public T SearchCriteria
{
get
{
return mySearchCriteria;
}
set
{
if (value != mySearchCriteria)
{
mySearchCriteria = value;
EnsureChildControls();
SearchGridParser parser = SearchGridParserFactory.GetParser(this.Type);
parser.SetSearchPanelControls<T>(this.mySearchCriteria, ref mySearchParametersPanel);
GridView.PageIndex = 0;
}
}
}
I have stepped through the code, and everytime it gets to "value != mySearchCriteria" it evaluates to false and skips the code inside the if statement. In fact, it does this even when I change it to "value == mySearchCriteria".. if just completely skips it no matter how it evaluates!
What the hey?
I've tried changing the order of the arguments in the check, and also using object.Equals() but none of these changes have made any difference.
I have overridden Equals, !=, == and GetHashCode.
There are other places in the code where it uses the "==" and "!=" for these object types without a problem, so I know that my overriding is working correctly.
Problem is, this never even hits the overriden methods. I put breaks on "==", "!=", "Equals" and "GetHashCode" and none of them are being called when the "value != mySearchCriteria" statement is being evaluated.
It's like it completely skips evaluating it.