using System.Diagnostics.CodeAnalysis; namespace InnovEnergy.Lib.Utils; public static class NullableUtilsClass { public static IEnumerable ToEnumerable(this T? t) where T : class { if (t is not null) yield return t; } public static T ThrowIfNull(this T? t) where T : class => ThrowIfNull(t, null); public static T ThrowIfNull(this T? t, String? message) where T : class { if (t is null) throw new NullReferenceException(message); return t; } public static Boolean IsNull([NotNullWhen(returnValue: false)] this T? t) where T : class => t is null; public static T? As(this Object t) where T : class => t as T; }