Exemple #1
0
 /// <summary>
 /// Returns a value indicating whether a collection is read-only.
 /// </summary>
 /// <param name="collection">The collection to examine.</param>
 /// <returns>A value indicating whether a collection is read-only.</returns>
 public static bool IsReadOnly(this IEnumerable collection)
 {
     return
         (collection.GetType().IsArray ||
          CollectionExtensions
          .Iterate(collection.GetType(), type => type.BaseType)
          .TakeWhile(type => type != null)
          .Any(type => type.FullName.StartsWith("System.Collections.ObjectModel.ReadOnlyCollection`1", StringComparison.Ordinal)));
 }