using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Models.PublishedContent;
namespace Umbraco.Core
{
///
/// Provides extension methods for IPublishedElement.
///
public static class PublishedElementExtensions
{
#region OfTypes
// the .OfType() filter is nice when there's only one type
// this is to support filtering with multiple types
public static IEnumerable OfTypes(this IEnumerable contents, params string[] types)
where T : IPublishedElement
{
if (types == null || types.Length == 0) return Enumerable.Empty();
return contents.Where(x => types.InvariantContains(x.ContentType.Alias));
}
#endregion
}
}