/// <summary> /// Adds an assembly set that is referenced by the assemblies of this addin. /// </summary> /// <param name="referencedAssemblySet">The referenced assembly set.</param> internal void AddReferencedAssemblySet(AssemblyResolutionSet referencedAssemblySet) { // if the referenced assembly is provided by this addin itself, don't bother to resolve it at the runtime. foreach (var referencedAssembly in referencedAssemblySet) { if (ReferenceEquals(referencedAssembly.DeclaringAddin, this)) { return; } } _referencedAssemblySets = _referencedAssemblySets ?? new List <AssemblyResolutionSet>(); if (_referencedAssemblySets.Contains(referencedAssemblySet)) { return; } _referencedAssemblySets.Add(referencedAssemblySet); var addinSet = new AddinResolutionSet(); if (RunningStatus == AddinRunningStatus.Enabled) { var shouldEnable = false; foreach (var referencedAssembly in referencedAssemblySet) { addinSet.Add(referencedAssembly.DeclaringAddin); if (referencedAssembly.DeclaringAddin.RunningStatus == AddinRunningStatus.Enabled) { shouldEnable = true; } } RunningStatus = shouldEnable ? AddinRunningStatus.Enabled : AddinRunningStatus.Disabled; } else { foreach (var referencedAssembly in referencedAssemblySet) { addinSet.Add(referencedAssembly.DeclaringAddin); if (RunningStatus == AddinRunningStatus.Enabled && referencedAssembly.DeclaringAddin.RunningStatus == AddinRunningStatus.Disabled) { RunningStatus = AddinRunningStatus.Disabled; } } } _referencedAddinSets = _referencedAddinSets ?? new List <AddinResolutionSet>(); _referencedAddinSets.Add(addinSet); }
/// <summary> /// Adds an assembly set that is referenced by the assemblies of this addin. /// </summary> /// <param name="referencedAssemblySet">The referenced assembly set.</param> internal void AddReferencedAssemblySet(AssemblyResolutionSet referencedAssemblySet) { // if the referenced assembly is provided by this addin itself, don't bother to resolve it at the runtime. foreach (var referencedAssembly in referencedAssemblySet) { if (ReferenceEquals(referencedAssembly.DeclaringAddin, this)) { return; } } _referencedAssemblySets = _referencedAssemblySets ?? new List <AssemblyResolutionSet>(); if (_referencedAssemblySets.Contains(referencedAssemblySet)) { return; } _referencedAssemblySets.Add(referencedAssemblySet); var addinSet = new AddinResolutionSet(); if (Enabled) { // 如果插件初始状态定义为 Enabled,那么只要它引用的任何一个插件是 Enabled 的,插件最终解析状态就是 Enabled 的 var shouldEnable = false; foreach (var referencedAssembly in referencedAssemblySet) { addinSet.Add(referencedAssembly.DeclaringAddin); if (referencedAssembly.DeclaringAddin.Enabled) { shouldEnable = true; } } Enabled = shouldEnable; } else { foreach (var referencedAssembly in referencedAssemblySet) { addinSet.Add(referencedAssembly.DeclaringAddin); } } _referencedAddinSets = _referencedAddinSets ?? new List <AddinResolutionSet>(); _referencedAddinSets.Add(addinSet); }