Exemplo n.º 1
0
        protected override List <Item> LatestVersionInFilteredLanguages(Item item)
        {
            var languagePatterns = new List <WildcardPattern>();
            IEnumerable <string> fullyQualifiedLanguages = new List <string>();

            if (Language != null && Language.Any())
            {
                languagePatterns =
                    Language.Where(lang => lang.Contains('*') || lang.Contains('?')).Select(
                        language =>
                        new WildcardPattern(language,
                                            WildcardOptions.IgnoreCase | WildcardOptions.CultureInvariant))
                    .ToList();
                fullyQualifiedLanguages = Language.Where(lang => !lang.Contains('*') && !lang.Contains('?'));
            }


            var publishedLangs = new List <string>();
            var result         = new List <Item>();

            foreach (var langName in fullyQualifiedLanguages)
            {
                var language = LanguageManager.GetLanguage(langName);
                var langItem = item.Database.GetItem(item.ID, language);
                if (!publishedLangs.Contains(langItem.Language.Name))
                {
                    publishedLangs.Add(langItem.Language.Name);
                    result.Add(langItem);
                }
            }

            // if there are any wildcards - filter item in all languages
            if (languagePatterns.Any())
            {
                foreach (
                    var langItem in
                    item.Versions.GetVersions(true).Reverse())
                {
                    // publish latest version of each language
                    if (LanguageWildcardPatterns.Any(wildcard => !publishedLangs.Contains(langItem.Language.Name) &&
                                                     wildcard.IsMatch(langItem.Language.Name)))
                    {
                        publishedLangs.Add(langItem.Language.Name);
                        result.Add(langItem);
                    }
                }
            }
            return(result);
        }
 protected override void BeginProcessing()
 {
     if (Language == null || !Language.Any())
     {
         LanguageWildcardPatterns = new List <WildcardPattern>();
     }
     else
     {
         LanguageWildcardPatterns =
             Language.Select(
                 language =>
                 new WildcardPattern(language, WildcardOptions.IgnoreCase | WildcardOptions.CultureInvariant))
             .ToList();
     }
     base.BeginProcessing();
 }
        protected override void BeginProcessing()
        {
            if (ExcludeLanguage == null || !ExcludeLanguage.Any())
            {
                ExcludeLanguageWildcardPatterns = new List <WildcardPattern>();
            }
            else
            {
                ExcludeLanguageWildcardPatterns =
                    ExcludeLanguage.Select(
                        language =>
                        new WildcardPattern(language, WildcardOptions.IgnoreCase | WildcardOptions.CultureInvariant))
                    .ToList();

                if (Language == null || !Language.Any())
                {
                    Language = new[] { "*" };
                }
            }

            var langsList            = Language?.Aggregate((seed, curr) => seed + ", " + curr) ?? "not specified";
            var excludedLangsMessage = (ExcludeLanguage == null || ExcludeLanguage.Length == 0)
                ? ""
                : $"excluding {ExcludeLanguage.Aggregate((seed, curr) => seed + ", " + curr)} language(s)";

            confirmMessage =
                $"R{(Recurse ? "ecursively r" : "")}emove versions for language(s) '{langsList}' {excludedLangsMessage}";

            if (Version != null && Version.Any())
            {
                VersionPatterns =
                    Version.Select(
                        version => new WildcardPattern(version, WildcardOptions.IgnoreCase | WildcardOptions.Compiled))
                    .ToList();
            }
            else
            {
                VersionPatterns = new List <WildcardPattern>();
            }

            base.BeginProcessing();
        }
Exemplo n.º 4
0
 public void TestAnyException2()
 {
     Language.Any(EmptyList <int>(), null);
 }
Exemplo n.º 5
0
 public void TestAnyException1()
 {
     Language.Any <int>(null, null);
 }