|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ObservableCollectionExtensions.cs" company="Catel development team">
// Copyright (c) 2008 - 2011 Catel development team. All rights reserved.
// </copyright>
// <summary>
// Extension methods for <see cref="System.Collections.ObjectModel.ObservableCollection{T}" />.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Catel.Collections.ObjectModel
{
/// <summary>
/// Extension methods for <see cref="System.Collections.ObjectModel.ObservableCollection{T}"/>.
/// </summary>
public static class ObservableCollectionExtensions
{
#region Methods
/// <summary>
/// Add an range of items to the specified <see cref="System.Collections.ObjectModel.ObservableCollection{T}"/>.
/// </summary>
/// <typeparam name="T">Type of items within the observable collection.</typeparam>
/// <param name="collection">The <see cref="System.Collections.ObjectModel.ObservableCollection{T}"/>.</param>
/// <param name="range">An range of items.</param>
/// <exception cref="ArgumentNullException">when <paramref name="collection"/> is <c>null</c>.</exception>
/// <exception cref="ArgumentNullException">when <paramref name="range"/> is <c>null</c>.</exception>
public static void AddRange<T>(this ObservableCollection<T> collection, IEnumerable<T> range)
{
if (collection == null)
{
throw new ArgumentNullException("collection");
}
if (range == null)
{
throw new ArgumentNullException("range");
}
foreach (T curItem in range)
{
collection.Add(curItem);
}
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.