コード例 #1
0
        void DoAddRelationMap(AddinRecord addin)
        {
            //_uid2AddinRecords.Add(addin.Uid, addin);
            //_guid2AddinRecords.Add(addin.Guid, addin);
            _addinRecords.Add(addin);

            if (addin.AssemblyFiles != null)
            {
                foreach (var assemblyFile in addin.AssemblyFiles)
                {
                    AddinRecordSet addinSet;
                    if (!_assemblyUid2AddinSets.TryGetValue(assemblyFile.Uid, out addinSet))
                    {
                        addinSet = new AddinRecordSet();
                        _assemblyUid2AddinSets.Add(assemblyFile.Uid, addinSet);
                    }
                    addinSet.Add(addin);
                }
            }

            if (addin.ExtensionPoints != null)
            {
                foreach (var extensionPoint in addin.ExtensionPoints)
                {
                    extensionPoint.AddinRecord = addin;
                    _path2ExtensionPoints.Add(extensionPoint.Path, extensionPoint);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Get a list of addins that the sepecified addin directly depended (refers to or extends), whose status change will affect this addin.
        /// </summary>
        internal AddinRecordSet TryGetDependedAddins(AddinRecord addin)
        {
            var result = new AddinRecordSet();

            if (addin.ExtendedAddins != null)
            {
                foreach (var extendedAddin in addin.ExtendedAddins)
                {
                    result.Add(GetAddinByUid(extendedAddin.Uid));
                }
            }
            if (addin.ReferencedAssemblies != null)
            {
                foreach (var referencedAssembly in addin.ReferencedAssemblies)
                {
                    var referencedAddins = _assemblyUid2AddinSets[referencedAssembly.Uid];
                    var referencedAddin  = referencedAddins.SelectFirst();
                    if (!result.Contains(referencedAddin))
                    {
                        result.Add(referencedAddin);
                    }
                }
            }
            return(result.Count > 0 ? result : null);
        }
コード例 #3
0
        /// <summary>
        /// Get a list of addins that extend the specified extension point (provide extensions for it),
        /// sorted by the dependence relationship between them.
        /// </summary>
        /// <param name="extensionPoint">The extension point.</param>
        /// <returns></returns>
        internal AddinRecordSet TryGetSortedExtendingAddins(ExtensionPointRecord extensionPoint)
        {
            var result = new AddinRecordSet();

            for (int i = 0; i < _addinRecords.Count; i++)
            {
                var addin = _addinRecords[i];
                if (addin.Enabled && addin.ExtendsExtensionPoint(extensionPoint.Uid))
                {
                    result.Add(addin);
                }
            }

            return(result);
        }
コード例 #4
0
        /// <summary>
        /// Get a list of addins that directly refers to or extends the sepecified addin, which will be affected by the
        /// status change of the later.
        /// </summary>
        /// <param name="addin">The addin that should be checked for affected addins.</param>
        /// <returns></returns>
        internal AddinRecordSet TryGetAffectingAddins(AddinRecord addin)
        {
            var result = new AddinRecordSet();

            // 获取当前扩展了指定插件 (addin) 的现有插件
            foreach (var existingAddin in _addinRecords)
            {
                if (!existingAddin.Enabled)
                {
                    continue;
                }
                if (existingAddin.ExtendsAddin(addin.Uid))
                {
                    result.Add(existingAddin);
                }
            }

            // 获取当前引用了该插件 (addin) 程序集的其他现有插件
            if (addin.AssemblyFiles != null)
            {
                foreach (var assemblyFile in addin.AssemblyFiles)
                {
                    if (!IsDefaultSelectedAddinForAssembly(assemblyFile, addin))
                    {
                        continue; // 如果当前插件 (addin) 并非被选为默认提供该程序集 (assemblyFile) 的插件,则不会有其他插件依赖当前插件
                    }
                    foreach (var existingAddin in _addinRecords)
                    {
                        if (!existingAddin.RefersToAssembly(assemblyFile.Uid))
                        {
                            continue;
                        }
                        if (!result.Contains(existingAddin))
                        {
                            result.Add(existingAddin);
                        }
                    }
                }
            }

            return(result.Count > 0 ? result : null);
        }
コード例 #5
0
 static AddinRecord SelectReferencedAddin(AddinRecordSet referencedAddinSet)
 {
     // if any of the referenced addin is loaded, use it
     foreach (var referencedAddin in referencedAddinSet)
     {
         if (referencedAddin.AssembliesRegistered)
         {
             return(referencedAddin);
         }
     }
     // otherwise, select the first (top priority) referenced addin directly
     foreach (var referencedAddin in referencedAddinSet)
     {
         if (referencedAddin.Enabled)
         {
             return(referencedAddin);
         }
     }
     return(null);
 }