public static TValue GetOrCreateValue <TValue>( this IPropertyHolder propertyBag, string propertyName, TValue newValue, Action <TValue> onCreated = null) { TValue actualNewValueProvider() { return(newValue); }; return(propertyBag.GetOrCreateValue( propertyName, actualNewValueProvider, onCreated)); }
public static TValue GetOrCreateValue <TValue>( this IPropertyHolder propertyBag, string propertyName, Func <TValue> newValueProvider, Action <TValue> onCreated = null) { if (newValueProvider == null) { throw new ArgumentNullException(nameof(newValueProvider)); } TValue actualNewValueProvider() { return(newValueProvider.Invoke()); }; return(propertyBag.GetOrCreateValue( propertyName, actualNewValueProvider, onCreated)); }