protected void OnAdd(object sender, EventArgs e) { NewSiteDialog dlg = new NewSiteDialog(); try { if (dlg.Run()) { string url = dlg.Url; if (!url.StartsWith("http://") && !url.StartsWith("https://") && !url.StartsWith("file://")) { url = "http://" + url; } try { new Uri(url); } catch { Services.ShowError(null, "Invalid url: " + url, null, true); } if (!service.Repositories.ContainsRepository(url)) { IProgressStatus m = new ConsoleProgressStatus(false); AddinRepository rr = service.Repositories.RegisterRepository(m, url); if (rr == null) { Services.ShowError(null, "The repository could not be registered", null, true); return; } treeStore.AppendValues(rr.Url, rr.Title); } } } finally { dlg.Destroy(); } }
internal AddinFramework(AddinOptions options) { _repository = new AddinRepository(); _messageDialog = options.MessageDialog ?? new DefaultMessageDialog(); _nameConvention = options.NameConvention ?? new DefaultNameConvention(); _fileSettings = options.FileSettings ?? new AddinFileSettings(); _assemblyLoadPolicy = options.AssemblyLoadPolicy ?? new DefaultAssemblyLoadPolicy(); _ebFactory = options.ExtensionBuilderFactory ?? new ReflectionExtensionBuilderFactory(); _epFactory = options.ExtensionPointFactory ?? new ReflectionExtensionPointFactory(); _eventBroker = options.EventBroker ?? new EventBroker(new EventBrokerOption()); _serviceProvider = options.ServiceProvider ?? new DefaultServiceProvider(); _stringLocalizer = options.StringLocalizer ?? new DefaultStringLocalizer(); LogManager.Initialize(new FileLogSetting(_fileSettings.DataDirectory, AddinFileSettings.LogFileName)); _logger = LogManager.GetDefaultLogger(); _properties = new Dictionary <HashKey, object>(); }
// Disable a repository /// <summary> /// Disables the repository. /// </summary> /// <param name='args'> /// Arguments. /// </param> public void DisableRepository(string[] args) { AddinRepository[] reps = Repositories.GetRepositories(); Array.Sort(reps, (r1, r2) => r1.Title.CompareTo(r2.Title)); if (reps.Length == 0) { MainConsole.Instance.Output("No repositories have been registered."); return; } int n = Convert.ToInt16(args[2]); if (n > (reps.Length - 1)) { MainConsole.Instance.Output("Selection out of range"); return; } AddinRepository rep = reps[n]; Repositories.SetRepositoryEnabled(rep.Url, false); return; }
public abstract Repository DownloadRepository(IProgressMonitor monitor, Uri absUri, AddinRepository rr);
void AppendRepository (AddinRepository rep) { string txt = GLib.Markup.EscapeText (rep.Title) + "\n<span color='darkgray'>" + GLib.Markup.EscapeText (rep.Url) + "</span>"; treeStore.AppendValues (rep.Url, txt, rep.Enabled); }
protected void OnAdd(object sender, EventArgs e) { NewSiteDialog dlg = new NewSiteDialog(this); try { if (dlg.Run()) { string url = dlg.Url; if (!url.StartsWith("http://") && !url.StartsWith("https://") && !url.StartsWith("file://")) { url = "http://" + url; } try { new Uri(url); } catch { Services.ShowError(null, "Invalid url: " + url, null, true); } if (!service.Repositories.ContainsRepository(url)) { ProgressDialog pdlg = new ProgressDialog(this); pdlg.Show(); pdlg.SetMessage(AddinManager.CurrentLocalizer.GetString("Registering repository")); bool done = false; AddinRepository rr = null; Exception error = null; ThreadPool.QueueUserWorkItem(delegate { try { rr = service.Repositories.RegisterRepository(pdlg, url, true); } catch (System.Exception ex) { error = ex; } finally { done = true; } }); while (!done) { if (Gtk.Application.EventsPending()) { Gtk.Application.RunIteration(); } else { Thread.Sleep(100); } } pdlg.Destroy(); if (pdlg.HadError) { if (rr != null) { service.Repositories.RemoveRepository(rr.Url); } return; } if (error != null) { Services.ShowError(error, "The repository could not be registered", null, true); return; } AppendRepository(rr); } } } finally { dlg.Destroy(); } }
void AppendRepository(AddinRepository rep) { string txt = GLib.Markup.EscapeText(rep.Title) + "\n<span color='darkgray'>" + GLib.Markup.EscapeText(rep.Url) + "</span>"; treeStore.AppendValues(rep.Url, txt, rep.Enabled); }
public override Repository DownloadRepository(IProgressMonitor monitor, Uri absUri, AddinRepository rr) { return((Repository)service.Store.DownloadObject(monitor, absUri.ToString(), typeof(Repository))); }