2023-01-07 19:11:43 +00:00
|
|
|
|
#nullable enable
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2016-04-22 22:29:38 +00:00
|
|
|
|
|
2020-04-21 09:12:17 +00:00
|
|
|
|
namespace Flow.Launcher.Infrastructure
|
2016-04-22 22:29:38 +00:00
|
|
|
|
{
|
2016-05-07 18:16:13 +00:00
|
|
|
|
public static class Helper
|
2016-04-22 22:29:38 +00:00
|
|
|
|
{
|
2016-04-27 21:51:31 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// http://www.yinwang.org/blog-cn/2015/11/21/programming-philosophy
|
|
|
|
|
|
/// </summary>
|
2023-01-07 19:11:43 +00:00
|
|
|
|
public static T NonNull<T>(this T? obj)
|
2016-04-22 22:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (obj == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NullReferenceException();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return obj;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-05-07 18:16:13 +00:00
|
|
|
|
|
|
|
|
|
|
public static void RequireNonNull<T>(this T obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (obj == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NullReferenceException();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-04-22 22:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|