mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-16 04:29:16 +08:00
25 lines
533 B
C#
25 lines
533 B
C#
using System;
|
|
|
|
namespace Wox.Helper
|
|
{
|
|
public static class SyntaxSugars
|
|
{
|
|
public static TResult CallOrRescueDefault<TResult>(Func<TResult> callback)
|
|
{
|
|
return CallOrRescueDefault(callback, default(TResult));
|
|
}
|
|
|
|
public static TResult CallOrRescueDefault<TResult>(Func<TResult> callback, TResult def)
|
|
{
|
|
try
|
|
{
|
|
return callback();
|
|
}
|
|
catch
|
|
{
|
|
return def;
|
|
}
|
|
}
|
|
}
|
|
}
|