public static Collections.VirtualList <TEntity> ToVirtualResultLazy <TEntity>(this Colosoft.Query.Queryable queryable, int pageSize = 0, string countExpression = null, string uiContext = null, Colosoft.Query.IQueryResultBindStrategy bindStrategy = null, Colosoft.Query.IQueryResultObjectCreator objectCreator = null) where TEntity : class
        {
            queryable.Require("queryable").NotNull();
            Collections.VirtualListLoader <TEntity>           virtualListLoader = null;
            Colosoft.Query.QueryableExecuterHandler <TEntity> executeSelect     = null;
            if (bindStrategy == null && objectCreator == null)
            {
                var ts = Colosoft.Query.TypeBindStrategyCache.GetItem(typeof(TEntity), t => new Colosoft.Query.QueryResultObjectCreator(t));
                objectCreator = ts;
                bindStrategy  = ts;
            }
            if (bindStrategy == null)
            {
                bindStrategy = new Colosoft.Query.TypeBindStrategy(typeof(TEntity), objectCreator);
            }
            var queryable2 = (Colosoft.Query.Queryable)queryable.Clone();

            if (typeof(Colosoft.Business.IEntity).IsAssignableFrom(typeof(TEntity)))
            {
                virtualListLoader = Colosoft.Business.EntityManager.Instance.GetEntityVirtualListLoader <TEntity>(queryable2, countExpression, true, uiContext, null);
                executeSelect     = (queryable3, dataSource, bindStrategy1, objectCreator1) => queryable3.ExecuteSelectProcessLazyResult <TEntity>(uiContext, null, bindStrategy1, objectCreator1);
            }
            else
            {
                virtualListLoader = new Colosoft.Business.QueryableVirtualListLoader <TEntity>(queryable2, countExpression, bindStrategy, objectCreator, null);
            }
            return(new Business.QueryableVirtualList <TEntity>(queryable2, pageSize, virtualListLoader, executeSelect, null, bindStrategy, objectCreator));
        }
Ejemplo n.º 2
0
 public VirtualList(int pageSize, VirtualListLoader <T> loader, object referenceObject)
 {
     if (loader == null)
     {
         throw new ArgumentNullException("loader");
     }
     PageSize        = pageSize;
     Loader          = loader;
     ReferenceObject = referenceObject;
     Refresh();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Método usado para converter o loader.
 /// </summary>
 /// <param name="loader"></param>
 /// <returns></returns>
 private static VirtualListLoader <DataWrapper <T> > ConverterLoader(VirtualListLoader <T> loader)
 {
     return(VirtualListLoader <DataWrapper <T> > .Create((sender, e) => {
         var result = loader.Load((IObservableCollection)sender, e.StartRow, e.PageSize, e.NeedItemsCount, e.ReferenceObject);
         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);
     }));
 }
Ejemplo n.º 4
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);
     }));
 }
        public static Collections.VirtualList <TEntity> ToVirtualResultLazy <TEntity>(this Colosoft.Query.Queryable queryable, int pageSize, Collections.VirtualListLoader <TEntity> listLoader, Colosoft.Query.IQueryResultBindStrategy bindStrategy = null, Colosoft.Query.IQueryResultObjectCreator objectCreator = null) where TEntity : class
        {
            queryable.Require("queryable").NotNull();
            var queryable2 = (Colosoft.Query.Queryable)queryable.Clone();

            Colosoft.Query.QueryableExecuterHandler <TEntity> executeSelect = null;
            if (typeof(Colosoft.Business.IEntity).IsAssignableFrom(typeof(TEntity)))
            {
                executeSelect = (queryable3, dataSource, bindStragety1, objectCreator1) => queryable3.ExecuteSelectProcessLazyResult <TEntity>(null, null, bindStragety1, objectCreator1);
            }
            return(new Business.QueryableVirtualList <TEntity>(queryable2, pageSize, listLoader, executeSelect, null, bindStrategy, objectCreator));
        }
Ejemplo n.º 6
0
 public VirtualList(int pageSize, VirtualListLoaderHandler <T> loader, object referenceObject) : this(pageSize, VirtualListLoader <T> .Create(loader), referenceObject)
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="loader"></param>
 /// <param name="refObject"></param>
 /// <param name="pageSize"></param>
 public AsyncVirtualList(int pageSize, VirtualListLoader <T> loader, object refObject) : base(pageSize, ConverterLoader(loader), refObject)
 {
     _synchronizationContext = SynchronizationContext.Current;
 }