RuntimeAddin[] GetDepAddins() { if (depAddins != null) { return(depAddins); } var plugList = new List <RuntimeAddin> (); string ns = ainfo.Description.Namespace; // Collect dependent ids foreach (Dependency dep in module.Dependencies) { AddinDependency pdep = dep as AddinDependency; if (pdep != null) { RuntimeAddin adn = addinEngine.GetAddin(Addin.GetFullId(ns, pdep.AddinId, pdep.Version)); if (adn != null) { plugList.Add(adn); } else { addinEngine.ReportError("Add-in dependency not loaded: " + pdep.FullAddinId, module.ParentAddinDescription.AddinId, null, false); } } } return(depAddins = plugList.ToArray()); }
bool ResolveLoadDependencies(List <Addin> addins, Stack depCheck, string id, bool optional) { if (IsAddinLoaded(id)) { return(true); } if (depCheck.Contains(id)) { throw new InvalidOperationException("A cyclic addin dependency has been detected."); } Addin iad = Registry.GetAddin(id); if (iad == null || !iad.Enabled) { if (optional) { return(false); } else if (iad != null && !iad.Enabled) { throw new MissingDependencyException(GettextCatalog.GetString("The required addin '{0}' is disabled.", id)); } else { throw new MissingDependencyException(GettextCatalog.GetString("The required addin '{0}' is not installed.", id)); } } // If this addin has already been requested, bring it to the head // of the list, so it is loaded earlier than before. addins.Remove(iad); addins.Add(iad); depCheck.Push(id); try { foreach (Dependency dep in iad.AddinInfo.Dependencies) { AddinDependency adep = dep as AddinDependency; if (adep != null) { try { string adepid = Addin.GetFullId(iad.AddinInfo.Namespace, adep.AddinId, adep.Version); ResolveLoadDependencies(addins, depCheck, adepid, false); } catch (MissingDependencyException) { if (optional) { return(false); } else { throw; } } } } if (iad.AddinInfo.OptionalDependencies != null) { foreach (Dependency dep in iad.AddinInfo.OptionalDependencies) { AddinDependency adep = dep as AddinDependency; if (adep != null) { string adepid = Addin.GetFullId(iad.Namespace, adep.AddinId, adep.Version); if (!ResolveLoadDependencies(addins, depCheck, adepid, true)) { return(false); } } } } } finally { depCheck.Pop(); } return(true); }