mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 03:37:10 +08:00
28 lines
605 B
C#
28 lines
605 B
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
|
|||
|
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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|