I have a set of methods that allows users to easily user the PropertHasChanged event and allows then to do some extra processing. Here is the method:
public virtual void SetPropertyValue<T>(ref T currentValue, T newValue, Action<T> extraFunction = null, Action voidAfterSetAction = null) where T : class
{
if (currentValue == newValue) return;
currentValue = newValue;
PropertyHasChanged();
if (extraFunction != null) extraFunction(newValue);
if (voidAfterSetAction != null) voidAfterSetAction();
}
It has become apparent to me that I would sometimes need the old value in the extraFunction action. This is how I intended to do that:
public virtual void SetPropertyValue<T>(ref T currentValue, T newValue, Action<T, T> extraFunction = null, Action voidAfterSetAction = null) where T : class
{
var oldVal = currentValue;
if (currentValue == newValue) return;
currentValue = newValue;
PropertyHasChanged();
if (extraFunction != null) extraFunction(oldVal, newValue);
if (voidAfterSetAction != null) voidAfterSetAction();
}
As you may notice, the extraFunction action now takes two parameters. VS didnt have an issue with me creating the method (no red qwigglies) but when I build it throws MANY errors that say that the usage between the first method and the second method is ambiguous. If that is the case then how can I achieve what I am looking for?
EDIT
Here is the usual usage of the method:
SetPropertyValue(ref _streetAddress1, value, null, () => SalesData.StreetAddress1 = value);