Пример #1
0
        public IList<PackageItem> Search(string term)
        {
            if (string.IsNullOrEmpty (term) )
                throw new ArgumentNullException ("term");

            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.FileName = SEARCH_COMMAND;
            startInfo.Arguments = " search " + term;
            startInfo.UseShellExecute = false;
            startInfo.RedirectStandardOutput = true;

            Process search = new Process();
            search.StartInfo = startInfo;
            search.Start();

            string[] lines = search.StandardOutput.ReadToEnd ().Split ('\n');
            IList<PackageItem> result = new List<PackageItem> ();
            foreach (var line in lines)
            {
                var l = line.Trim ();
                if (!string.IsNullOrEmpty (l))
                {
                    int blank = l.IndexOf (" ");

                    var package = new PackageItem (
                                                   line.Substring(0, blank).Trim (),
                                                   line.Substring(blank + 2).Trim ()
                                                   );
                    result.Add (package);
                }
            }
            return result.OrderBy (r => r.Name).ToArray ();
        }
Пример #2
0
 public void Install(PackageItem package)
 {
     if (null == package)
         throw new ArgumentNullException ("package");
     // Many thanks to the author of the apturl plugin for this solution!!!
     Process.Start ("apturl apt:" + package.Name);
 }