예제 #1
0
        /// <summary>
        /// Find packages
        /// </summary>
        /// <param name="take">Items to take</param>
        /// <param name="skip">Items to skip</param>
        /// <param name="filter">Filter expression</param>
        /// <param name="order">Sort order</param>
        /// <returns>List of packages</returns>
        public IEnumerable <Package> Find(int take = 10, int skip = 0, string filter = "", string order = "")
        {
            if (!Security.IsAuthorizedTo(BlogEngine.Core.Rights.AccessAdminPages))
            {
                throw new System.UnauthorizedAccessException();
            }

            if (take == 0)
            {
                take = CachedPackages.Count();
            }
            if (string.IsNullOrEmpty(filter))
            {
                filter = "1==1";
            }
            if (string.IsNullOrEmpty(order))
            {
                order = "LastUpdated desc";
            }

            var packages = new List <Package>();
            var query    = CachedPackages.AsQueryable().Where(filter);

            foreach (var item in query.OrderBy(order).Skip(skip).Take(take))
            {
                packages.Add(item);
            }
            return(packages);
        }
        public IQueryable <ServerPackage> GetPackages(ClientCompatibility compatibility)
        {
            var cache = CachedPackages.AsQueryable();

            if (!compatibility.AllowSemVer2)
            {
                cache = cache.Where(p => !p.Version.IsSemVer2());
            }

            return(cache);
        }
예제 #3
0
 public override IQueryable <IPackage> GetPackages()
 {
     return(CachedPackages.AsQueryable());
 }