private Load ( |
||
iad | ||
return |
internal AddinDescription Load(Addin iad)
{
ainfo = iad;
AddinDescription description = iad.Description;
id = description.AddinId;
baseDirectory = description.BasePath;
module = description.MainModule;
module.RuntimeAddin = this;
if (description.Localizer != null) {
string cls = description.Localizer.GetAttribute ("type");
// First try getting one of the stock localizers. If none of found try getting the type.
object fob = null;
Type t = Type.GetType ("Mono.Addins.Localization." + cls + "Localizer, " + GetType().Assembly.FullName, false);
if (t != null)
fob = Activator.CreateInstance (t);
if (fob == null)
fob = CreateInstance (cls, true);
IAddinLocalizerFactory factory = fob as IAddinLocalizerFactory;
if (factory == null)
throw new InvalidOperationException ("Localizer factory type '" + cls + "' must implement IAddinLocalizerFactory");
localizer = new AddinLocalizer (factory.CreateLocalizer (this, description.Localizer));
}
return description;
}
bool InsertAddin(IProgressStatus statusMonitor, Addin iad) { try { RuntimeAddin p = new RuntimeAddin(); // Read the config file and load the add-in assemblies AddinDescription description = p.Load(iad); // Register the add-in loadedAddins [Addin.GetIdName(p.Id)] = p; if (!AddinDatabase.RunningSetupProcess) { // Load the extension points and other addin data foreach (ExtensionNodeSet rel in description.ExtensionNodeSets) { RegisterNodeSet(rel); } foreach (ConditionTypeDescription cond in description.ConditionTypes) { Type ctype = p.GetType(cond.TypeName, true); defaultContext.RegisterCondition(cond.Id, ctype); } } foreach (ExtensionPoint ep in description.ExtensionPoints) { InsertExtensionPoint(p, ep); } foreach (Assembly asm in p.Assemblies) { loadedAssemblies [asm] = p; } // Fire loaded event defaultContext.NotifyAddinLoaded(p); AddinManager.ReportAddinLoad(p.Id); return(true); } catch (Exception ex) { AddinManager.ReportError("Extension could not be loaded", iad.Id, ex, false); if (statusMonitor != null) { statusMonitor.ReportError("Extension '" + iad.Id + "' could not be loaded.", ex); } return(false); } }