/// <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); })); }
public VirtualList(int pageSize, VirtualListLoaderHandler <T> loader, object referenceObject) : this(pageSize, VirtualListLoader <T> .Create(loader), referenceObject) { }
/// <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; }
/// <summary> /// Libera a instancia. /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { base.Dispose(disposing); _handler = null; }
/// <summary> /// Construtor padrão. /// </summary> /// <param name="handler"></param> public Default(VirtualListLoaderHandler <T> handler) { handler.Require("handler").NotNull(); _handler = handler; }
/// <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)); }