2017-07-20 11:21:28 +02:00
|
|
|
|
using System.Collections;
|
2016-08-16 10:25:19 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
2017-05-30 15:46:25 +02:00
|
|
|
|
namespace Umbraco.Core.Composing
|
2016-08-16 10:25:19 +02:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Provides a base class for builder collections.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="TItem">The type of the items.</typeparam>
|
|
|
|
|
|
public abstract class BuilderCollectionBase<TItem> : IBuilderCollection<TItem>
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly TItem[] _items;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="BuilderCollectionBase{TItem}"/> with items.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="items">The items.</param>
|
|
|
|
|
|
protected BuilderCollectionBase(IEnumerable<TItem> items)
|
|
|
|
|
|
{
|
|
|
|
|
|
_items = items.ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public int Count => _items.Length;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets an enumerator.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public IEnumerator<TItem> GetEnumerator()
|
|
|
|
|
|
{
|
2016-07-29 10:58:57 +02:00
|
|
|
|
return ((IEnumerable<TItem>) _items).GetEnumerator();
|
2016-08-16 10:25:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets an enumerator.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetEnumerator();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|