Exemplo n.º 1
0
 public LazyList(ILazyLoadResolver <IEnumerable <T> > resolver, LazyLoadParameter parameter = null)
 {
     _resolver  = resolver;
     _parameter = parameter ?? LazyLoadParameter.Null;
     _list      = new List <T>();
     _isLoaded  = false;
 }
Exemplo n.º 2
0
        private async Task <T> InternalResolveAsync(LazyLoadParameter parameter)
        {
            var resolved = await LoadAsync(parameter);

            if (resolved != null)
            {
                _resolvedObjects.Add(parameter, resolved);
            }
            return(resolved);
        }
Exemplo n.º 3
0
 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));
 }
Exemplo n.º 4
0
        public IList <T> Create <T>(LazyLoadParameter parameter)
        {
            var resolver = (ILazyLoadResolver <IEnumerable <T> >)_provider.GetService(typeof(ILazyLoadResolver <IEnumerable <T> >));

            return(new LazyList <T>(resolver, parameter));
        }
Exemplo n.º 5
0
 protected abstract Task <T> LoadAsync(LazyLoadParameter parameter);
Exemplo n.º 6
0
 public T Resolve(LazyLoadParameter parameter)
 {
     return(ResolveAsync(parameter).GetAwaiter().GetResult());
 }
 protected override async Task <T> LoadAsync(LazyLoadParameter parameter)
 {
     return(await _resolveAsync(parameter));
 }