Esempio n. 1
0
        /// <summary>
        /// Gets the object extended by this extension
        /// </summary>
        /// <returns>
        /// The extended object can be an <see cref="ExtensionPoint"/> or
        /// an <see cref="ExtensionNodeDescription"/>.
        /// </returns>
        /// <remarks>
        /// This method only works when the add-in description to which the extension belongs has been
        /// loaded from an add-in registry.
        /// </remarks>
        public ObjectDescription GetExtendedObject()
        {
            AddinDescription desc = ParentAddinDescription;

            if (desc == null)
            {
                return(null);
            }
            ExtensionPoint ep = FindExtensionPoint(desc, path);

            if (ep == null && desc.OwnerDatabase != null)
            {
                foreach (Dependency dep in desc.MainModule.Dependencies)
                {
                    AddinDependency adep = dep as AddinDependency;
                    if (adep == null)
                    {
                        continue;
                    }
                    Addin ad = desc.OwnerDatabase.GetInstalledAddin(ParentAddinDescription.Domain, adep.FullAddinId);
                    if (ad != null && ad.Description != null)
                    {
                        ep = FindExtensionPoint(ad.Description, path);
                        if (ep != null)
                        {
                            break;
                        }
                    }
                }
            }
            if (ep != null)
            {
                string subp = path.Substring(ep.Path.Length).Trim('/');
                if (subp.Length == 0)
                {
                    return(ep);                    // The extension is directly extending the extension point
                }
                // The extension is extending a node of the extension point

                return(desc.FindExtensionNode(path, true));
            }
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Checks if this module depends on the specified add-in.
        /// </summary>
        /// <returns>
        /// <c>true</c> if there is a dependency.
        /// </returns>
        /// <param name='addinId'>
        /// Identifier of the add-in
        /// </param>
        public bool DependsOnAddin(string addinId)
        {
            AddinDescription desc = Parent as AddinDescription;

            if (desc == null)
            {
                throw new InvalidOperationException();
            }

            foreach (Dependency dep in Dependencies)
            {
                AddinDependency adep = dep as AddinDependency;
                if (adep == null)
                {
                    continue;
                }
                if (Addin.GetFullId(desc.Namespace, adep.AddinId, adep.Version) == addinId)
                {
                    return(true);
                }
            }
            return(false);
        }