public LazyList(ILazyLoadResolver <IEnumerable <T> > resolver, LazyLoadParameter parameter = null) { _resolver = resolver; _parameter = parameter ?? LazyLoadParameter.Null; _list = new List <T>(); _isLoaded = false; }
private async Task <T> InternalResolveAsync(LazyLoadParameter parameter) { var resolved = await LoadAsync(parameter); if (resolved != null) { _resolvedObjects.Add(parameter, resolved); } return(resolved); }
public Task <T> ResolveAsync(LazyLoadParameter parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } if (_resolvedObjects.TryGetValue(parameter, out var resolved)) { return(Task.FromResult(resolved)); } return(InternalResolveAsync(parameter)); }
public IList <T> Create <T>(LazyLoadParameter parameter) { var resolver = (ILazyLoadResolver <IEnumerable <T> >)_provider.GetService(typeof(ILazyLoadResolver <IEnumerable <T> >)); return(new LazyList <T>(resolver, parameter)); }
protected abstract Task <T> LoadAsync(LazyLoadParameter parameter);
public T Resolve(LazyLoadParameter parameter) { return(ResolveAsync(parameter).GetAwaiter().GetResult()); }
protected override async Task <T> LoadAsync(LazyLoadParameter parameter) { return(await _resolveAsync(parameter)); }