internal bool LoadAddin(IProgressStatus statusMonitor, string id, bool throwExceptions)
{
try {
lock (LocalLock) {
if (IsAddinLoaded (id))
return true;
if (!Registry.IsAddinEnabled (id)) {
string msg = GettextCatalog.GetString ("Disabled add-ins can't be loaded.");
ReportError (msg, id, null, false);
if (throwExceptions)
throw new InvalidOperationException (msg);
return false;
}
ArrayList addins = new ArrayList ();
Stack depCheck = new Stack ();
ResolveLoadDependencies (addins, depCheck, id, false);
addins.Reverse ();
if (statusMonitor != null)
statusMonitor.SetMessage ("Loading Addins");
for (int n=0; n<addins.Count; n++) {
if (statusMonitor != null)
statusMonitor.SetProgress ((double) n / (double)addins.Count);
Addin iad = (Addin) addins [n];
if (IsAddinLoaded (iad.Id))
continue;
if (statusMonitor != null)
statusMonitor.SetMessage (string.Format(GettextCatalog.GetString("Loading {0} add-in"), iad.Id));
if (!InsertAddin (statusMonitor, iad))
return false;
}
return true;
}
}
catch (Exception ex) {
ReportError ("Add-in could not be loaded: " + ex.Message, id, ex, false);
if (statusMonitor != null)
statusMonitor.ReportError ("Add-in '" + id + "' could not be loaded.", ex);
if (throwExceptions)
throw;
return false;
}
}