public static void Match <T>(this IStormContent <T> content, Action <T> onValue, Action <StormError> onError) { if (content == null) { throw new ArgumentNullException(nameof(content)); } if (onValue == null) { throw new ArgumentNullException(nameof(onValue)); } if (onError == null) { throw new ArgumentNullException(nameof(onError)); } object?OnValue(T v) { onValue(v); return(null); } object?OnError(StormError e) { onError(e); return(null); } content.Match(OnValue, OnError); }
public static T GetValueOrThrow <T>(this IStormContent <T> content) { if (content == null) { throw new ArgumentNullException(nameof(content)); } return(content.Match(v => v, e => throw e)); }