DelegatingSupplier<T1, T2, TResult>
public struct DelegatingSupplier<T1, T2, TResult> : ISupplier<T1, T2, TResult>, IEquatable<DelegatingSupplier<T1, T2, TResult>>
Represents implementation of ISupplier<T, U, V> that delegates
invocation to the delegate of type Func<T, U, V>.
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)] T1, [System.Runtime.CompilerServices.Nullable(2)] T2, [System.Runtime.CompilerServices.Nullable(2)] TResult> : ISupplier<T1, T2, TResult>, IEquatable<DelegatingSupplier<T1, T2, TResult>>
{
private readonly Func<T1, T2, TResult> func;
public bool IsEmpty => func == null;
public DelegatingSupplier(Func<T1, T2, TResult> func)
{
if (func == null)
throw new ArgumentNullException("func");
this.func = func;
}
TResult ISupplier<T1, T2, TResult>.Invoke(T1 arg1, T2 arg2)
{
return func(arg1, arg2);
}
public bool Equals([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1,
1
})] DelegatingSupplier<T1, T2, TResult> other)
{
return (object)func == other.func;
}
[System.Runtime.CompilerServices.NullableContext(2)]
public override bool Equals(object other)
{
if (other is DelegatingSupplier<T1, T2, TResult>) {
DelegatingSupplier<T1, T2, TResult> other2 = (DelegatingSupplier<T1, T2, TResult>)other;
return Equals(other2);
}
return false;
}
public override int GetHashCode()
{
return RuntimeHelpers.GetHashCode(func);
}
public static implicit operator DelegatingSupplier<T1, T2, TResult>(Func<T1, T2, TResult> func)
{
return new DelegatingSupplier<T1, T2, TResult>(func);
}
public static bool operator ==([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1,
1
})] DelegatingSupplier<T1, T2, TResult> x, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1,
1
})] DelegatingSupplier<T1, T2, TResult> y)
{
return x.Equals(y);
}
public static bool operator !=([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1,
1
})] DelegatingSupplier<T1, T2, TResult> x, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1,
1
})] DelegatingSupplier<T1, T2, TResult> y)
{
return !x.Equals(y);
}
}
}