Skip to content

EqualityChecking

Simon Cropp edited this page Jul 8, 2012 · 3 revisions

#summary What code is injected for equality checking

Equality check will be done before setting the field and firing the event.

{{{ public string Property1 { get { return property1; } set { if (!String.Equals(property1, value)) { property1 = value; OnPropertyChanged("Property1"); } } } }}}

The method used for equality checking is based on the property Type. The evaluation is done in the following order.

Check if the Type is a Nullable<T> and use Nullable.Equals<T>(T?,T?).

Check if the Type has a static Equals method with two parameters matching Type.

Check if the Type has and Equality Operator (==) with both parameters matching Type.

Use Object.Equals(object, object).

Clone this wiki locally