-
Notifications
You must be signed in to change notification settings - Fork 1
Object extensions
string ToStringSafe(this object obj)
string ToStringSafe(this object obj, string defaultValue)
If object is null then returns null or defaultValue, otherwise result of ToString().
TInput IfNotNull<TInput>(this TInput obj, Action<TInput> evaluator)
TResult IfNotNull<TInput, TResult>(this TInput obj, Func<TInput, TResult> evaluator)
TResult IfNotNull<TInput, TResult>(this TInput obj, Func<TInput, TResult> evaluator, TResult def)
If object is not null then evaluator is colled on this object.
Returned value depends which function was called:
-
TInput IfNotNull<TInput>(this TInput obj, Action<TInput> evaluator)Returns object on which function was called
-
TResult IfNotNull<TInput, TResult>(this TInput obj, Func<TInput, TResult> evaluator)Returns value returned by evaluator or
default(TResult) -
TResult IfNotNull<TInput, TResult>(this TInput obj, Func<TInput, TResult> evaluator, TResult def)Returns value returned by evaluator or given def value