public void AddAddinReference() { var arc = (AddinReferenceCollection)CurrentNode.DataItem; var existingAddins = new HashSet <string> ( arc.Project.AddinReferences.Select(a => a.Id) ); var allAddins = arc.Project.AddinRegistry.GetAddins() .Where(a => !existingAddins.Contains(AddinHelpers.GetUnversionedId(a))) .ToArray(); if (allAddins.Length == 0) { MessageService.ShowMessage( GettextCatalog.GetString("You have already referenced all available addins") ); return; } var dialog = new AddAddinReferenceDialog(allAddins); Addin[] selectedAddins; try { if (MessageService.RunCustomDialog(dialog) != (int)Gtk.ResponseType.Ok) { return; } selectedAddins = dialog.GetSelectedAddins(); } finally { dialog.Destroy(); } //HACK: we have to ToList() or the event handlers attached to the //collection will all enumerate the list and get different copies var references = selectedAddins.Select(a => new AddinReference { Id = AddinHelpers.GetUnversionedId(a) }).ToList(); arc.Project.AddinReferences.AddRange(references); IdeApp.ProjectOperations.Save(arc.Project); }
public void AddAddinReference () { var addins = (AddinReferenceCollection) CurrentNode.DataItem; var existingAddins = new HashSet<string> ( addins.Select (a => a.Include) ); var allAddins = addins.Parent.AddinRegistry.GetAddins () .Where (a => !existingAddins.Contains (AddinHelpers.GetUnversionedId (a))) .ToArray (); if (allAddins.Length == 0) { MessageService.ShowMessage ( GettextCatalog.GetString ("You have already referenced all available addins") ); return; } var dialog = new AddAddinReferenceDialog (allAddins); Addin[] selectedAddins; try { if (MessageService.RunCustomDialog (dialog) != (int)Gtk.ResponseType.Ok) return; selectedAddins = dialog.GetSelectedAddins (); } finally { dialog.Destroy (); } //HACK: we have to ToList() or the event handlers attached to the //collection will all enumerate the list and get different copies var references = selectedAddins.Select (a => new AddinReference (AddinHelpers.GetUnversionedId (a))).ToList (); addins.AddRange (references); IdeApp.ProjectOperations.SaveAsync (addins.Parent.Project); }