SupplierClosure<TContext, T1, T2, TResult>
Represents implementation of ISupplier<T, U> interface
with the support of closure that is not allocated on the heap.
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace DotNext
{
[StructLayout(LayoutKind.Auto)]
[System.Runtime.CompilerServices.NullableContext(2)]
[System.Runtime.CompilerServices.Nullable(0)]
[CLSCompliant(false)]
public readonly struct SupplierClosure<TContext, T1, T2, TResult> : ISupplier<T1, T2, TResult>
{
[System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1,
1,
1
})]
private readonly IntPtr ptr;
[System.Runtime.CompilerServices.Nullable(1)]
private readonly TContext context;
public unsafe bool IsEmpty => ptr == (IntPtr)(void*)null;
[System.Runtime.CompilerServices.NullableContext(1)]
public unsafe SupplierClosure(TContext context, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1,
1,
1
})] IntPtr ptr)
{
if (ptr == (IntPtr)(void*)null)
throw new ArgumentNullException("ptr");
this.ptr = ptr;
this.context = context;
}
[System.Runtime.CompilerServices.NullableContext(1)]
TResult ISupplier<T1, T2, TResult>.Invoke(T1 arg1, T2 arg2)
{
IntPtr intPtr = ptr;
return (TResult);
}
}
}