CollectionExtensions Class

Namespace:
Weavy.Core.Helpers
Assembly:
Weavy.Core.dll

Helper and extension methods for collections.

public static class CollectionExtensions
Inheritance:
System.Object → CollectionExtensions

Methods

Append(IDictionary, string, string) Adds an element with the provided key and value to the dictionary. If the key already exists, the specified value will be appended to the existing value (the values will be space separated).
AsHtmlAttributes(NameValueCollection, bool) Converts a NameValueCollection to a html attribute string.
AsPagedList(IEnumerable, QueryOptions, long?) Extension method to make it easier to create a PagedList.
AsQueryString(NameValueCollection, bool, bool) Converts a NameValueCollection to a query string including the leading ? or &.
Assert(ICollection, Permission) Throws a ForbiddenException if the requested permission does not exist in the list of supplied permissions.
AsSmartEnumerable(IEnumerable) Extension method to make it easier to create a SmartEnumerable.
CleanTags(IEnumerable) Cleans up a collection of tags by removing invalid characters. Duplicate and empty tags are removed before returning the remaining tags sorted in alphabetical order.
ContainsAny(ICollection, Permission[]) Extension method to check if a list of permissions contains any of the the specified permissions.
DistinctBy(IEnumerable, Func) Returns all distinct elements of the given source, where "distinctness" is determined via a projection and the default equality comparer for the projected type, e.g. var distinct = list.DistinctBy(x => x.ID).
Flip(Dictionary) Returna a reverse dictionary.
HasItems(IEnumerable) Indicates whether the specified generic collection has any items.
IsNullOrDefault(T) Gets a value indicating if the specified value has the default value of the generic type.
IsNullOrEmpty(IEnumerable) Indicates whether the specified generic collection is null or empty.
Join(IEnumerable, string, Converter) Concatenates a specified separator string between each element of a collection, yielding a single concatenated string.
Join(IEnumerable, string, string, Converter) Concatenates a specified separator string between each element of a collection, yielding a single concatenated string.
JoinTags(IEnumerable) Joins a list of tags into an alphabetically sorted comma separated string.
Rebuild(NameValueCollection, Object[]) Rebuilds a NameValueCollection, optionally adding, removing and/or replacing the values in the replacement params.
Shuffle(IEnumerable, Random) Shuffle the elements.