DotNext by Roman Sakno

<PackageReference Include="DotNext" Version="3.1.0" />

.NET API 362,496 bytes

 DelegatingSupplier<TResult>

public struct DelegatingSupplier<TResult> : ISupplier<TResult>, IEquatable<DelegatingSupplier<TResult>>
Represents implementation of ISupplier<T> that delegates invocation to the delegate of type Func<T>.
using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace DotNext { [StructLayout(LayoutKind.Auto)] [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public readonly struct DelegatingSupplier<[System.Runtime.CompilerServices.Nullable(2)] TResult> : ISupplier<TResult>, IEquatable<DelegatingSupplier<TResult>> { private readonly Func<TResult> func; public bool IsEmpty => func == null; public DelegatingSupplier(Func<TResult> func) { if (func == null) throw new ArgumentNullException("func"); this.func = func; } TResult ISupplier<TResult>.Invoke() { return func(); } public bool Equals([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] DelegatingSupplier<TResult> other) { return (object)func == other.func; } [System.Runtime.CompilerServices.NullableContext(2)] public override bool Equals(object other) { if (other is DelegatingSupplier<TResult>) { DelegatingSupplier<TResult> other2 = (DelegatingSupplier<TResult>)other; return Equals(other2); } return false; } public override int GetHashCode() { return RuntimeHelpers.GetHashCode(func); } public static implicit operator DelegatingSupplier<TResult>(Func<TResult> func) { return new DelegatingSupplier<TResult>(func); } public static bool operator ==([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] DelegatingSupplier<TResult> x, [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] DelegatingSupplier<TResult> y) { return x.Equals(y); } public static bool operator !=([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] DelegatingSupplier<TResult> x, [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] DelegatingSupplier<TResult> y) { return !x.Equals(y); } } }