/* ----------------------------------------------------------------- */ /// /// SetProperty /// /// <summary> /// Set the specified value in the specified field if they are not /// equal. /// </summary> /// /// <param name="field">Reference to the target field.</param> /// <param name="value">Value being set.</param> /// <param name="compare">Function to compare.</param> /// <param name="name">Name of the property.</param> /// /// <returns>True for done; false for cancel.</returns> /// /* ----------------------------------------------------------------- */ protected bool SetProperty <T>(ref T field, T value, IEqualityComparer <T> compare, [CallerMemberName] string name = null) { var set = compare.Set(ref field, value); if (set) { Refresh(name); } return(set); }
/* ----------------------------------------------------------------- */ /// /// SetProperty /// /// <summary> /// Sets the specified value to the inner field of the specified /// name if they are not equal. /// </summary> /// /// <param name="value">Value being set.</param> /// <param name="compare">Function to compare.</param> /// <param name="name">Name of the property.</param> /// /// <returns>True for done; false for cancel.</returns> /// /* ----------------------------------------------------------------- */ protected bool SetProperty <T>(T value, IEqualityComparer <T> compare, [CallerMemberName] string name = null) { var src = GetProperty <T>(name); var set = compare.Set(ref src, value); if (set) { _fields[name] = src; Refresh(name); } return(set); }