Created
April 3, 2016 10:00
-
-
Save evilz/c3ba1b11c91a6b53a9f7c17a2adb33e2 to your computer and use it in GitHub Desktop.
SetField for notify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class NotifyHelper | |
{ | |
public static bool SetField<T,F>(this T target,ref F field, F value, Action<T> callback) | |
{ | |
if (EqualityComparer<F>.Default.Equals(field, value)) return false; | |
field = value; | |
callback?.Invoke(target); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment