/// <exclude /> public override IEnumerable <PackageFragmentValidationResult> Validate() { List <PackageFragmentValidationResult> validationResults = new List <PackageFragmentValidationResult>(); if (this.Configuration.Count(f => f.Name == "Locales") > 1) { validationResults.AddFatal(GetText("VirtualElementProviderNodePackageFragmentUninstaller.OnlyOneElement")); return(validationResults); } XElement localesElement = this.Configuration.SingleOrDefault(f => f.Name == "Locales"); _culturesToUninstall = new List <CultureInfo>(); if (localesElement != null) { XAttribute oldDefaultAttribute = localesElement.Attribute("oldDefault"); if (oldDefaultAttribute != null) { _oldDefaultCultureInfo = CultureInfo.CreateSpecificCulture(oldDefaultAttribute.Value); } foreach (XElement localeElement in localesElement.Elements("Locale").Reverse()) { CultureInfo locale = CultureInfo.CreateSpecificCulture(localeElement.Attribute("name").Value); if ((_oldDefaultCultureInfo == null) && (LocalizationFacade.IsDefaultLocale(locale))) { // Locale is default -> not possible to unintall validationResults.AddFatal(GetText("VirtualElementProviderNodePackageFragmentUninstaller.OnlyOneElement")); continue; } if (LocalizationFacade.IsOnlyActiveLocaleForSomeUsers(locale)) { // only active for the a user validationResults.AddFatal(GetText("VirtualElementProviderNodePackageFragmentUninstaller.OnlyOneElement")); continue; } if (LocalizationFacade.IsLocaleInstalled(locale)) { _culturesToUninstall.Add(locale); } } } if (validationResults.Count > 0) { _culturesToUninstall = null; _oldDefaultCultureInfo = null; } return(validationResults); }
private void IsOnlyActiveLocaleForSomeUsers(object sender, ConditionalEventArgs e) { CultureInfo cultureInfo = CreateCultureInfo(); e.Result = LocalizationFacade.IsOnlyActiveLocaleForSomeUsers(cultureInfo); }