예제 #1
0
    /// <summary>
    /// Gets the unique list of extensions with highest version
    /// </summary>
    /// <param name="exlude">Exlude these extensions</param>
    /// <returns></returns>
    public ExtensionCollection GetUniqueList(ExtensionCollection exlude)
    {
      HashSet<string> exludedIds = new HashSet<string>();
      if (exlude != null) exlude.Items.ForEach(p => exludedIds.Add(p.GeneralInfo.Id));
      Dictionary<string, PackageClass> ids = new Dictionary<string, PackageClass>();
      
      foreach (PackageClass item in Items)
      {
        if (item.IsHiden || exludedIds.Contains(item.GeneralInfo.Id))
          continue;

        PackageClass currentVersion = null;
        if (!ids.TryGetValue(item.GeneralInfo.Id, out currentVersion))
        {
          ids.Add(item.GeneralInfo.Id, item);
        }
        else
        {
          // overwrite if has a higher version
          if (item.GeneralInfo.Version.CompareTo(currentVersion.GeneralInfo.Version) > 0)
          {
            ids[item.GeneralInfo.Id] = item;
          }
        }
      }

      var collection = new ExtensionCollection();
      foreach (var package in ids.Values) collection.Add(package);
      return collection;
    }
 /// <summary>
 /// Gets the unique list of extensions with hightess version
 /// </summary>
 /// <returns></returns>
 public ExtensionCollection GetUniqueList()
 {
   List<string> ids = new List<string>();
   foreach (PackageClass item in Items)
   {
     if (item.IsHiden)
       continue;
     if (!ids.Contains(item.GeneralInfo.Id))
       ids.Add(item.GeneralInfo.Id);
   }
   var collection = new ExtensionCollection();
   foreach (string id in ids)
   {
     collection.Add(Get(id));
   }
   return collection;
 }
        /// <summary>
        /// Gets a list of extensions with same ids
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public ExtensionCollection GetList(string id)
        {
            ExtensionCollection resp = new ExtensionCollection();

            foreach (PackageClass item in Items)
            {
                if (item.IsHiden)
                {
                    continue;
                }
                if (item.GeneralInfo.Id == id)
                {
                    resp.Add(item);
                }
            }
            resp.Items.Sort(PackageClass.Compare);
            return(resp);
        }
        /// <summary>
        /// Gets the unique list of extensions with highest version
        /// </summary>
        /// <param name="exlude">Exlude these extensions</param>
        /// <returns></returns>
        public ExtensionCollection GetUniqueList(ExtensionCollection exlude)
        {
            HashSet <string> exludedIds = new HashSet <string>();

            if (exlude != null)
            {
                exlude.Items.ForEach(p => exludedIds.Add(p.GeneralInfo.Id));
            }
            Dictionary <string, PackageClass> ids = new Dictionary <string, PackageClass>();

            foreach (PackageClass item in Items)
            {
                if (item.IsHiden || exludedIds.Contains(item.GeneralInfo.Id))
                {
                    continue;
                }

                PackageClass currentVersion = null;
                if (!ids.TryGetValue(item.GeneralInfo.Id, out currentVersion))
                {
                    ids.Add(item.GeneralInfo.Id, item);
                }
                else
                {
                    // overwrite if has a higher version
                    if (item.GeneralInfo.Version.CompareTo(currentVersion.GeneralInfo.Version) > 0)
                    {
                        ids[item.GeneralInfo.Id] = item;
                    }
                }
            }

            var collection = new ExtensionCollection();

            foreach (var package in ids.Values)
            {
                collection.Add(package);
            }
            return(collection);
        }
        /// <summary>
        /// Gets the unique list of extensions with hightess version
        /// </summary>
        /// <returns></returns>
        public ExtensionCollection GetUniqueList()
        {
            List <string> ids = new List <string>();

            foreach (PackageClass item in Items)
            {
                if (item.IsHiden)
                {
                    continue;
                }
                if (!ids.Contains(item.GeneralInfo.Id))
                {
                    ids.Add(item.GeneralInfo.Id);
                }
            }
            var collection = new ExtensionCollection();

            foreach (string id in ids)
            {
                collection.Add(Get(id));
            }
            return(collection);
        }
예제 #6
0
 /// <summary>
 /// Gets a list of extensions with same ids
 /// </summary>
 /// <param name="id">The id.</param>
 /// <returns></returns>
 public ExtensionCollection GetList(string id)
 {
   ExtensionCollection resp = new ExtensionCollection();
   foreach (PackageClass item in Items)
   {
     if (item.IsHiden)
       continue;
     if (item.GeneralInfo.Id == id)
     {
       resp.Add(item);
     }
   }
   resp.Items.Sort(PackageClass.Compare);
   return resp;
 }
예제 #7
0
 private void add_list_Click(object sender, EventArgs e)
 {
   string xmlFile = txt_list1.Text;
   ExtensionCollection list = new ExtensionCollection();
   ExtensionCollection list2 = new ExtensionCollection();
   if (File.Exists(xmlFile))
     list = ExtensionCollection.Load(xmlFile);
   if (File.Exists(txt_list2.Text))
     list2 = ExtensionCollection.Load(txt_list2.Text);
   list.Add(list2);
   list.Save(xmlFile);
 }