PageRenderTime 41ms CodeModel.GetById 16ms 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. //===================================================================================
  17. using System.Collections.Generic;
  18. using System.Collections.ObjectModel;
  19. namespace Microsoft.Practices.Composite
  20. {
  21. /// <summary>
  22. /// Class that provides extension methods to Collection
  23. /// </summary>
  24. public static class CollectionExtensions
  25. {
  26. /// <summary>
  27. /// Add a range of items to a collection.
  28. /// </summary>
  29. /// <typeparam name="T">Type of objects within the collection.</typeparam>
  30. /// <param name="collection">The collection to add items to.</param>
  31. /// <param name="items">The items to add to the collection.</param>
  32. /// <returns>The collection.</returns>
  33. public static Collection<T> AddRange<T>(this Collection<T> collection, IEnumerable<T> items)
  34. {
  35. foreach (var each in items)
  36. {
  37. collection.Add(each);
  38. }
  39. return collection;
  40. }
  41. }
  42. }