Beispiel #1
0
        protected virtual WorkshopValidatedItem TestTags()
        {
            var originalTags = new TagsCollection(Target.Tags);
            var newTags      = new TagsCollection(originalTags.Where(x => x != null && IsTagAllowed(x.ToLowerInvariant()))
                                                  .Concat(GetForcedTags()).NonNull()).CleanUp().Sort();

            for (var i = newTags.Count - 1; i >= MaxTagsCount; --i)
            {
                newTags.RemoveAt(i);
            }

            if (newTags.SequenceEqual(originalTags))
            {
                return(new WorkshopValidatedItem("Tags are correct"));
            }

            return(new WorkshopValidatedItem($"Tags will be changed to {newTags.Select(x => $"“{x}”").JoinToString(", ")}",
                                             () => Target.Tags = newTags, () => Target.Tags = originalTags));
        }