Exemple #1
0
        /// <summary>
        /// Initialises the package.
        /// </summary>
        /// <param name="pkgdir">the package directory</param>
        /// <param name="cat">the category this package belongs to</param>
        private Package(DirectoryInfo pkgdir, Category cat)
        {
            _pkgdir = pkgdir;
            _category = cat;
            _dists = new List<IDistribution>(Distribution.Enumerate(this));

            /* load package info */
            FileInfo[] fiarr = pkgdir.GetFiles("metadata.xml");
            if (fiarr.Length == 1) {
                XmlDocument infoxml = new XmlDocument();
                infoxml.Load(fiarr[0].FullName);

                XmlElement elem = (XmlElement)infoxml.SelectSingleNode("//Package/Description");
                if (elem != null && !String.IsNullOrWhiteSpace(elem.InnerText))
                    _description = elem.InnerText;

                elem = (XmlElement)infoxml.SelectSingleNode("//Package/Homepage");
                if (elem != null && !String.IsNullOrWhiteSpace(elem.InnerText))
                    _homepage = elem.InnerText;

                elem = (XmlElement)infoxml.SelectSingleNode("//Package/License");
                if (elem != null && !String.IsNullOrWhiteSpace(elem.InnerText))
                    _license = elem.InnerText;
            }
        }
Exemple #2
0
        /// <summary>
        /// Scans the category directory for packages.
        /// </summary>
        /// <param name="catdir">the associated category</param>
        /// <returns>a list of packages in the category directory</returns>
        internal static List<Package> Enumerate(Category cat)
        {
            DirectoryInfo[] diarr = cat.CategoryDirectory
                .EnumerateDirectories()
                .Where(d => d.Name.Length <= 50 && Package.ValidateName(d.Name))
                .ToArray();
            _log.DebugFormat(
                "{0} packages: {1}",
                cat.Name, String.Join(", ", diarr.Select(i => i.Name).ToArray()));
            List<Package> results = new List<Package>();

            foreach (DirectoryInfo di in diarr)
                results.Add(new Package(di, cat));

            return results;
        }