Beispiel #1
0
        public static string GetPackageDownloadUrl(Package package)
        {
            var routesValues = new RouteValueDictionary { 
                { "packageId", package.Id },
                { "version", package.Version.ToString() } 
            };

            var context = HttpContext.Current;

            RouteBase route = RouteTable.Routes["DownloadPackage"];

            var vpd = route.GetVirtualPath(context.Request.RequestContext, routesValues);

            string applicationPath = Helpers.EnsureTrailingSlash(context.Request.ApplicationPath);

            return applicationPath + vpd.VirtualPath;
        }
        /// <summary>
        /// Gives the Package containing both the IPackage and the derived metadata.
        /// The returned Package will be null if <paramref name="package" /> no longer exists in the cache.
        /// </summary>
        public Package GetMetadataPackage(IPackage package)
        {
            Package metadata = null;

            // The cache may have changed, and the metadata may no longer exist
            DerivedPackageData data = null;
            if (PackageCache.TryGetValue(package, out data))
            {
                metadata = new Package(package, data);
            }

            return metadata;
        }