Refactored Option<T> to have opertator lifting and removed ref struct for now.
All checks were successful
Build NuGet / build (push) Successful in 1m43s
All checks were successful
Build NuGet / build (push) Successful in 1m43s
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
namespace SJK.Functional;
|
||||
// [Obsolete]
|
||||
// public class Cache<T> where T : class
|
||||
// {
|
||||
// private T? _cache;
|
||||
// private Func<T> _provider;
|
||||
// private readonly Func<T, bool>? _isvalid;
|
||||
|
||||
public class Cache<T> where T : class
|
||||
{
|
||||
private T? _cache;
|
||||
private Func<T> _provider;
|
||||
private readonly Func<T, bool>? _isvalid;
|
||||
// public Cache(Func<T> provider, Func<T, bool>? isvalid = null)
|
||||
// {
|
||||
// _provider = provider;
|
||||
// _isvalid = isvalid;
|
||||
// }
|
||||
// public bool IsCached() => _cache is not null;
|
||||
// public T Value => _cache is null || (_isvalid is not null && !_isvalid(_cache)) ? _cache = _provider() : _cache;
|
||||
|
||||
public Cache(Func<T> provider, Func<T, bool>? isvalid = null)
|
||||
{
|
||||
_provider = provider;
|
||||
_isvalid = isvalid;
|
||||
}
|
||||
public bool IsCached() => _cache is not null;
|
||||
public T Value => _cache is null || (_isvalid is not null && !_isvalid(_cache)) ? _cache = _provider() : _cache;
|
||||
|
||||
}
|
||||
// }
|
||||
Reference in New Issue
Block a user