예제 #1
0
 /// <summary>
 /// Método usado para converter o loader.
 /// </summary>
 /// <param name="loader"></param>
 /// <returns></returns>
 private static VirtualListLoader <DataWrapper <T> > ConverterLoader(VirtualListLoaderHandler <T> loader)
 {
     return(VirtualListLoader <DataWrapper <T> > .Create((sender, e) => {
         var result = loader(sender, e);
         if (result.Error != null)
         {
             return new VirtualListLoaderResult <DataWrapper <T> >(result.Error);
         }
         IEnumerable <DataWrapper <T> > items = result.Items != null ? result.Items.Select(f => new DataWrapper <T>(0, f)) : null;
         if (result.UpdateCount)
         {
             return new VirtualListLoaderResult <DataWrapper <T> >(items, result.NewCount);
         }
         return new VirtualListLoaderResult <DataWrapper <T> >(items);
     }));
 }
예제 #2
0
 public VirtualList(int pageSize, VirtualListLoaderHandler <T> loader, object referenceObject) : this(pageSize, VirtualListLoader <T> .Create(loader), referenceObject)
 {
 }
예제 #3
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="loader"></param>
 /// <param name="refObject"></param>
 /// <param name="pageSize"></param>
 public AsyncVirtualList(int pageSize, VirtualListLoaderHandler <T> loader, object refObject) : base(pageSize, ConverterLoader(loader), refObject)
 {
     _synchronizationContext = SynchronizationContext.Current;
 }
예제 #4
0
 /// <summary>
 /// Libera a instancia.
 /// </summary>
 /// <param name="disposing"></param>
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     _handler = null;
 }
예제 #5
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="handler"></param>
 public Default(VirtualListLoaderHandler <T> handler)
 {
     handler.Require("handler").NotNull();
     _handler = handler;
 }
예제 #6
0
 /// <summary>
 /// Cria uma instancia do loader com base no metodo informado.
 /// </summary>
 /// <param name="method"></param>
 /// <returns></returns>
 public static VirtualListLoader <T> Create(VirtualListLoaderHandler <T> method)
 {
     return(new Default(method));
 }