PageRenderTime 11ms CodeModel.GetById 9ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/V2.2/trunk/CAL/Desktop/Composite/CollectionExtensions.cs

#
C# | 44 lines | 16 code | 2 blank | 26 comment | 0 complexity | 72ebd176983cca83d67c646d4559fefe MD5 | raw file
 1//===================================================================================
 2// Microsoft patterns & practices
 3// Composite Application Guidance for Windows Presentation Foundation and Silverlight
 4//===================================================================================
 5// Copyright (c) Microsoft Corporation.  All rights reserved.
 6// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
 7// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
 8// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 9// FITNESS FOR A PARTICULAR PURPOSE.
10//===================================================================================
11// The example companies, organizations, products, domain names,
12// e-mail addresses, logos, people, places, and events depicted
13// herein are fictitious.  No association with any real company,
14// organization, product, domain name, email address, logo, person,
15// places, or events is intended or should be inferred.
16//===================================================================================
17using System.Collections.Generic;
18using System.Collections.ObjectModel;
19
20namespace Microsoft.Practices.Composite
21{
22    /// <summary>
23    /// Class that provides extension methods to Collection
24    /// </summary>
25    public static class CollectionExtensions
26    {
27        /// <summary>
28        /// Add a range of items to a collection.
29        /// </summary>
30        /// <typeparam name="T">Type of objects within the collection.</typeparam>
31        /// <param name="collection">The collection to add items to.</param>
32        /// <param name="items">The items to add to the collection.</param>
33        /// <returns>The collection.</returns>
34        public static Collection<T> AddRange<T>(this Collection<T> collection, IEnumerable<T> items)
35        {
36            foreach (var each in items)
37            {
38                collection.Add(each);
39            }
40
41            return collection;
42        }
43    }
44}