Skip to content

Instantly share code, notes, and snippets.

@evilz
Created April 3, 2016 10:00
Show Gist options
  • Save evilz/c3ba1b11c91a6b53a9f7c17a2adb33e2 to your computer and use it in GitHub Desktop.
Save evilz/c3ba1b11c91a6b53a9f7c17a2adb33e2 to your computer and use it in GitHub Desktop.
SetField for notify
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