public void Uninstall(string packageId, string applicationPath) { var extensionToUninstall = _extensionManager.AvailableExtensions() .FirstOrDefault(extension => PackageBuilder.BuildPackageId(extension.Id, extension.ExtensionType) == packageId); if (extensionToUninstall == null) { throw new OrchardException(T("There is no extension that has the package ID \"{0}\".", packageId)); } var featureIdsToUninstall = extensionToUninstall.Features.Select(feature => feature.Id); var shellState = _shellStateManager.GetShellState(); var featureStates = shellState.Features.Where(featureState => featureIdsToUninstall.Contains(featureState.Name)); // This means that no feature from this extension wasn enabled yet, can be uninstalled directly. if (!featureStates.Any()) { _packageUninstallHandler.QueuePackageUninstall(packageId); } else { _featureManager.DisableFeatures(extensionToUninstall.Features.Select(feature => feature.Id), true); // Installed state can't be deduced from the shell state changes like for enabled state, so have to // set that explicitly. foreach (var featureState in featureStates) { _shellStateManager.UpdateInstalledState(featureState, Environment.State.Models.ShellFeatureState.State.Falling); } } }
void IShellDescriptorManagerEventHandler.Changed(ShellDescriptor descriptor, string tenant) { // deduce and apply state changes involved var shellState = _stateManager.GetShellState(); foreach (var feature in descriptor.Features) { var featureName = feature.Name; var featureState = shellState.Features.SingleOrDefault(f => f.Name == featureName); if (featureState == null) { featureState = new ShellFeatureState { Name = featureName }; shellState.Features = shellState.Features.Concat(new[] { featureState }); } if (!featureState.IsInstalled) { _stateManager.UpdateInstalledState(featureState, ShellFeatureState.State.Rising); } if (!featureState.IsEnabled) { _stateManager.UpdateEnabledState(featureState, ShellFeatureState.State.Rising); } } foreach (var featureState in shellState.Features) { var featureName = featureState.Name; if (descriptor.Features.Any(f => f.Name == featureName)) { continue; } if (!featureState.IsDisabled) { _stateManager.UpdateEnabledState(featureState, ShellFeatureState.State.Falling); } } FireApplyChangesIfNeeded(); }