Thanks to visit codestin.com
Credit goes to github.com

Skip to content

mausch/ReadOnlyCollections

Repository files navigation

ReadOnlyCollections

Backported read-only collection interfaces and extensions/adapters around them.

This repository contains two projects:

ReadOnlyCollectionsInterfaces is a backport of the new IReadOnly* interfaces, making them available to .NET 2.0 up to .NET 4.6.2 and .NET Standard 1.0+

The interfaces are:

ReadOnlyCollectionsExtensions provides minimal extension methods around these interfaces, converting or exposing IList as IReadOnlyList, etc These are designed to be similar to System.Linq.Enumerable.ToList(), etc

IReadOnlyCollection<T> AsReadOnlyCollection<T>(this ICollection<T> source)
IReadOnlyList<T> AsReadOnlyList<T>(this IList<T> source)
IReadOnlyList<T> ToReadOnlyList<T>(this IEnumerable<T> source)
IReadOnlyDictionary<TKey, TValue> ToReadOnlyDictionary<TSource, TKey, TValue>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TValue> valueSelector, IEqualityComparer<TKey> comparer)
IReadOnlyDictionary<TKey, TValue> ToReadOnlyDictionary<TSource, TKey, TValue>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TValue> valueSelector)
IReadOnlyDictionary<TKey, TValue> ToReadOnlyDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> dict)
IReadOnlyDictionary<TKey, TValue> ToReadOnlyDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> dict, IEqualityComparer<TKey> comparer)
IReadOnlyDictionary<TKey, TValue> AsReadOnlyDictionary<TKey, TValue>(this IDictionary<TKey, TValue> dict)
IReadOnlySet<T> AsReadOnlySet<T>(this ISet<T> source)
IReadOnlySet<T> ToReadOnlySet<T>(this IEnumerable<T> source)

Binaries available on NuGet.

About

Backported read-only collection interfaces and extensions/adapters around them

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •