using System;
using System.Collections.Generic;
namespace Zero.Common
{
///
/// Extension methods for cleaner code.
///
public static class ExtensionMethods
{
///
/// Adds range of items into collection.
///
///
///
///
public static void AddRange(this ICollection collection, IEnumerable items)
{
if (items == null)
{
System.Diagnostics.Debug.WriteLine("Do extension metody AddRange byly poslany items == null");
return;
}
foreach (var item in items)
{
collection.Add(item);
}
}
///
/// Clears collection and adds range of items into it.
///
///
///
///
public static void ClearAndAddRange(this ICollection collection, IEnumerable items)
{
collection.Clear();
collection.AddRange(items);
}
///
/// Strong-typed object cloning for objects that implement
///
///
///
///
public static T Clone(this T obj) where T : ICloneable
{
return (T)(obj as ICloneable).Clone();
}
}
}