/// <summary> /// Maps the given function to the contents of the result. If the result is a success, the /// function will be applied to the success value; otherwise, the function will not be applied. /// </summary> /// <typeparam name="TNewValue">The type that the success value will be mapped to.</typeparam> /// <param name="function">The function to apply to the success value of the result.</param> /// <returns>A copy of the result with the mapping applied.</returns> public Exceptional <TNewValue> Map <TNewValue>(Func <T, TNewValue> function) { if (function == null) { throw new ArgumentNullException("function"); } if (IsSuccess) { return(Exceptional <TNewValue> .Success(function(Value), PagingInfo)); } else { return(Exceptional <TNewValue> .Failure(Exception)); } }