DelegatingSupplier<TResult>
public struct DelegatingSupplier<TResult> : ISupplier<TResult>, IFunctional<Func<TResult>>, IEquatable<DelegatingSupplier<TResult>>
Represents implementation of ISupplier<T> that delegates
invocation to the delegate of type Func<T>.
using DotNext.Runtime.CompilerServices;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace DotNext
{
[StructLayout(LayoutKind.Auto)]
public readonly struct DelegatingSupplier<[System.Runtime.CompilerServices.Nullable(2)] TResult> : ISupplier<TResult>, IFunctional<Func<TResult>>, IEquatable<DelegatingSupplier<TResult>>
{
private readonly Func<TResult> func;
public bool IsEmpty => func == null;
[System.Runtime.CompilerServices.NullableContext(1)]
public DelegatingSupplier(Func<TResult> func)
{
if (func == null)
throw new ArgumentNullException("func");
this.func = func;
}
TResult ISupplier<TResult>.Invoke()
{
return func();
}
Func<TResult> IFunctional<Func<TResult>>.ToDelegate()
{
return func;
}
[System.Runtime.CompilerServices.NullableContext(2)]
public override string ToString()
{
return func?.ToString();
}
public static implicit operator DelegatingSupplier<TResult>(Func<TResult> func)
{
return new DelegatingSupplier<TResult>(func);
}
[CompilerGenerated]
private bool PrintMembers(StringBuilder builder)
{
builder.Append("IsEmpty = ");
builder.Append(IsEmpty.ToString());
return true;
}
public static bool operator !=(DelegatingSupplier<TResult> left, DelegatingSupplier<TResult> right)
{
return !(left == right);
}
public static bool operator ==(DelegatingSupplier<TResult> left, DelegatingSupplier<TResult> right)
{
return left.Equals(right);
}
[CompilerGenerated]
public override int GetHashCode()
{
return EqualityComparer<Func<TResult>>.Default.GetHashCode(func);
}
[CompilerGenerated]
public override bool Equals(object obj)
{
if (obj is DelegatingSupplier<TResult>)
return Equals((DelegatingSupplier<TResult>)obj);
return false;
}
[CompilerGenerated]
public bool Equals(DelegatingSupplier<TResult> other)
{
return EqualityComparer<Func<TResult>>.Default.Equals(func, other.func);
}
}
}