GetFullId() публичный статический Метод

Returns the identifier of an add-in
public static GetFullId ( string ns, string id, string version ) : string
ns string /// Namespace of the add-in ///
id string /// Name of the add-in ///
version string /// Version of the add-in ///
Результат string
Пример #1
0
        RuntimeAddin[] GetDepAddins()
        {
            if (depAddins != null)
            {
                return(depAddins);
            }

            ArrayList plugList = new ArrayList();
            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 = (RuntimeAddin[])plugList.ToArray(typeof(RuntimeAddin)));
        }
Пример #2
0
        void LoadModule(ModuleDescription module, string ns, ArrayList plugList, ArrayList asmList)
        {
            // Load the assemblies
            foreach (string s in module.Assemblies)
            {
                Assembly asm = null;

                // don't load the assembly if it's already loaded
                string asmPath = Path.Combine(baseDirectory, s);
                foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
                {
                    // Sorry, you can't load addins from
                    // dynamic assemblies as get_Location
                    // throws a NotSupportedException
                    if (a is System.Reflection.Emit.AssemblyBuilder)
                    {
                        continue;
                    }

                    if (a.Location == asmPath)
                    {
                        asm = a;
                        break;
                    }
                }

                if (asm == null)
                {
                    asm = Assembly.LoadFrom(asmPath);
                }

                asmList.Add(asm);
            }

            // Collect dependent ids
            foreach (Dependency dep in module.Dependencies)
            {
                AddinDependency pdep = dep as AddinDependency;
                if (pdep != null)
                {
                    RuntimeAddin adn = AddinManager.SessionService.GetAddin(Addin.GetFullId(ns, pdep.AddinId, pdep.Version));
                    if (adn != null)
                    {
                        plugList.Add(adn);
                    }
                    else
                    {
                        AddinManager.ReportError("Add-in dependency not loaded: " + pdep.FullAddinId, module.ParentAddinDescription.AddinId, null, false);
                    }
                }
            }
        }
Пример #3
0
 bool CheckOptionalAddinDependencies(AddinDescription conf, ModuleDescription module)
 {
     foreach (Dependency dep in module.Dependencies)
     {
         AddinDependency pdep = dep as AddinDependency;
         if (pdep != null)
         {
             Addin pinfo = AddinManager.Registry.GetAddin(Addin.GetFullId(conf.Namespace, pdep.AddinId, pdep.Version));
             if (pinfo == null || !pinfo.Enabled)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #4
0
        bool ResolveLoadDependencies(ArrayList 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.");
            }

            depCheck.Push(id);

            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);

            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);
                        }
                    }
                }
            }

            depCheck.Pop();
            return(true);
        }