Supplier<T1, T2, TResult>
public struct Supplier<T1, T2, TResult> : ISupplier<T1, T2, TResult>, IFunctional<Func<T1, T2, TResult>>
Represents typed function pointer implementing ISupplier<T, U, V>.
using DotNext.Runtime.CompilerServices;
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)]
[CLSCompliant(false)]
public readonly struct Supplier<[System.Runtime.CompilerServices.Nullable(2)] T1, [System.Runtime.CompilerServices.Nullable(2)] T2, [System.Runtime.CompilerServices.Nullable(2)] TResult> : ISupplier<T1, T2, TResult>, IFunctional<Func<T1, T2, TResult>>
{
private readonly IntPtr ptr;
public unsafe bool IsEmpty => ptr == (IntPtr)(void*)null;
public unsafe Supplier([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1,
1
})] IntPtr ptr)
{
if (ptr == (IntPtr)(void*)null)
throw new ArgumentNullException("ptr");
this.ptr = ptr;
}
TResult ISupplier<T1, T2, TResult>.Invoke(T1 arg1, T2 arg2)
{
IntPtr intPtr = ptr;
return (TResult);
}
public unsafe override string ToString()
{
return new IntPtr((void*)(long)ptr).ToString("X");
}
public Func<T1, T2, TResult> ToDelegate()
{
return DelegateHelpers.CreateDelegate<T1, T2, TResult>(ptr);
}
public static implicit operator Supplier<T1, T2, TResult>([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1,
1
})] IntPtr ptr)
{
return new Supplier<T1, T2, TResult>(ptr);
}
public static explicit operator Func<T1, T2, TResult>([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1,
1
})] Supplier<T1, T2, TResult> supplier)
{
return supplier.ToDelegate();
}
}
}