Exemplo n.º 1
0
        public static void Create <T, TColl>(int pageSize
                                             , IPageProvider <T, TColl> pageProvider
                                             , ICountProvider countProvider
                                             , Action <TColl> created
                                             ) where T : new() where TColl : IList <T>, new()
        {
            if (null == countProvider)
            {
                throw new ArgumentNullException("countProvider");
            }
            if (null == pageProvider)
            {
                throw new ArgumentNullException("pageProvider");
            }
            countProvider.CountAvailable += (s, e)
                                            =>
            {
                var           collection    = new TColl();
                HashSet <int> fetchingPages = new HashSet <int>();

                var data = new { Count = 0 };
                for (int i = 0; i < e.Count; i += pageSize)
                {
                    var t = ProxyFactory.CreateProxy <T>(new PageInterceptor <T, TColl>(pageProvider, pageSize, collection));
                    (t as IPageableElement).PageIndex = i / pageSize;
                    for (int j = i; j < i + pageSize && j < e.Count; ++j)
                    {
                        collection.Add(t);
                    }
                }
                created(collection);
            };
            countProvider.GetCount();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Instantiates the base class <see cref="BaseCountTag"/>
        /// </summary>
        /// <param name="countProvider"></param>
        protected BaseCountTag(ICountProvider countProvider)
        {
            if (countProvider == null)
            {
                throw new ArgumentNullException("countProvider");
            }

            this.countProvider = countProvider;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Instantiates a new instance of the <see cref="ResetCountTag"/> class
 /// </summary>
 /// <remarks>Class is instantiated with the <see cref="ProfileCountProvider"/> class because no DI sucks</remarks>
 public ResetCountTag(ICountProvider countProvider) : base(countProvider)
 {
 }
Exemplo n.º 4
0
 /// <summary>
 /// Instantiates a new instance of the <see cref="ResetCountTag"/> class
 /// </summary>
 /// <remarks>Class is instantiated with the <see cref="ProfileCountProvider"/> class because no DI sucks</remarks>
 public ResetCountTag(ICountProvider countProvider)
     : base(countProvider)
 {
 }