Class CollectionExtensions
Extensions for the
Inheritance
Namespace: ISynergy.Framework.Core.Extensions
Assembly: ISynergy.Framework.Core.dll
Syntax
public static class CollectionExtensions : object
Methods
View SourceAddNewRange<T>(ICollection<T>, IEnumerable<T>)
Add an new range of items to the specified
Declaration
public static void AddNewRange<T>(this ICollection<T> collection, IEnumerable<T> range)
Parameters
Type | Name | Description |
---|---|---|
ICollection<T> | collection | The collection. |
IEnumerable<T> | range | An range of items. |
Type Parameters
Name | Description |
---|---|
T | Type of items within the collection. |
AddRange<T>(ICollection<T>, IEnumerable<T>)
Add an range of items to the specified
Declaration
public static void AddRange<T>(this ICollection<T> collection, IEnumerable<T> range)
Parameters
Type | Name | Description |
---|---|---|
ICollection<T> | collection | The collection. |
IEnumerable<T> | range | An range of items. |
Type Parameters
Name | Description |
---|---|
T | Type of items within the collection. |
AsReadOnly<T>(IList<T>)
Converts the dictionary to a readonly collection.
Declaration
public static ReadOnlyCollection<T> AsReadOnly<T>(this IList<T> collection)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | collection | The collection to convert. |
Returns
Type | Description |
---|---|
ReadOnlyCollection<T> | The readonly version of the collection. |
Type Parameters
Name | Description |
---|---|
T | Type of the items inside the collection. |
CanMoveItemDown(IList, Object)
Determines whether the item can be moved down in the list.
Declaration
public static bool CanMoveItemDown(this IList list, object item)
Parameters
Type | Name | Description |
---|---|---|
IList | list | The list. |
System.Object | item | The item to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
CanMoveItemUp(IList, Object)
Determines whether the item can be moved up in the list.
Declaration
public static bool CanMoveItemUp(this IList list, object item)
Parameters
Type | Name | Description |
---|---|---|
IList | list | The list. |
System.Object | item | The item to check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
ForEach<T>(IEnumerable<T>, Action<T>)
The for each extension on
Declaration
public static void ForEach<T>(this IEnumerable<T> items, Action<T> action)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | items | The items. |
Action<T> | action | The action. |
Type Parameters
Name | Description |
---|---|
T |
FromHierarchy<TSource>(TSource, Func<TSource, TSource>)
Froms the hierarchy.
Declaration
public static IEnumerable<TSource> FromHierarchy<TSource>(this TSource source, Func<TSource, TSource> nextItem)
where TSource : class
Parameters
Type | Name | Description |
---|---|---|
TSource | source | The source. |
Func<TSource, TSource> | nextItem | The next item. |
Returns
Type | Description |
---|---|
IEnumerable<TSource> | IEnumerable<TSource>. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the t source. |
FromHierarchy<TSource>(TSource, Func<TSource, TSource>, Func<TSource, Boolean>)
Froms the hierarchy.
Declaration
public static IEnumerable<TSource> FromHierarchy<TSource>(this TSource source, Func<TSource, TSource> nextItem, Func<TSource, bool> canContinue)
Parameters
Type | Name | Description |
---|---|---|
TSource | source | The source. |
Func<TSource, TSource> | nextItem | The next item. |
Func<TSource, System.Boolean> | canContinue | The can continue. |
Returns
Type | Description |
---|---|
IEnumerable<TSource> | IEnumerable<TSource>. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the t source. |
MoveItemDown(IList, Object)
Moves the specified item down in the list.
Declaration
public static bool MoveItemDown(this IList list, object item)
Parameters
Type | Name | Description |
---|---|---|
IList | list | The list. |
System.Object | item | The item to move down. |
Returns
Type | Description |
---|---|
System.Boolean |
|
MoveItemDownByIndex(IList, Int32)
Moves the item at the specified index down in the list.
Declaration
public static bool MoveItemDownByIndex(this IList list, int index)
Parameters
Type | Name | Description |
---|---|---|
IList | list | The list. |
System.Int32 | index | The index of the item to move down. |
Returns
Type | Description |
---|---|
System.Boolean |
|
MoveItemUp(IList, Object)
Moves the specified item up in the list.
Declaration
public static bool MoveItemUp(this IList list, object item)
Parameters
Type | Name | Description |
---|---|---|
IList | list | The list. |
System.Object | item | The item to move up. |
Returns
Type | Description |
---|---|
System.Boolean |
|
MoveItemUpByIndex(IList, Int32)
Moves the item at the specified index up in the list.
Declaration
public static bool MoveItemUpByIndex(this IList list, int index)
Parameters
Type | Name | Description |
---|---|---|
IList | list | The list. |
System.Int32 | index | The index of the item to move up. |
Returns
Type | Description |
---|---|
System.Boolean |
|
RemoveFirst(IList)
Removes the first entry from the list.
When there are no items in the list, this method will silently exit.
Declaration
public static void RemoveFirst(this IList list)
Parameters
Type | Name | Description |
---|---|---|
IList | list | The list. |
RemoveLast(IList)
Removes the last entry from the list.
When there are no items in the list, this method will silently exit.
Declaration
public static void RemoveLast(this IList list)
Parameters
Type | Name | Description |
---|---|---|
IList | list | The list. |
ReplaceRange<T>(ICollection<T>, IEnumerable<T>)
Replaces the whole range of the specified collection
. This is done by internally
calling AddRange{T}
.
Declaration
public static void ReplaceRange<T>(this ICollection<T> collection, IEnumerable<T> range)
Parameters
Type | Name | Description |
---|---|---|
ICollection<T> | collection | The collection. |
IEnumerable<T> | range | The range of items to add to the observable collection. |
Type Parameters
Name | Description |
---|---|
T | Type of items within the collection. |
Sort<T>(IList<T>, Func<T, T, Int32>)
Sorts the specified existing set.
Declaration
public static void Sort<T>(this IList<T> existingSet, Func<T, T, int> comparer = null)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | existingSet | The existing set. |
Func<T, T, System.Int32> | comparer | The comparer. |
Type Parameters
Name | Description |
---|---|
T | The type of elements. |
SynchronizeCollection<T>(IList<T>, IEnumerable<T>, Boolean)
Synchronizes the collection by adding / removing items that are in the new set.
Declaration
public static IEnumerable<T> SynchronizeCollection<T>(this IList<T> existingSet, IEnumerable<T> newSet, bool updateExistingSet = true)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | existingSet | The existing set. |
IEnumerable<T> | newSet | The new set. |
System.Boolean | updateExistingSet | if set to |
Returns
Type | Description |
---|---|
IEnumerable<T> | IEnumerable<T>. |
Type Parameters
Name | Description |
---|---|
T | The type of the collection item. |
ToArray(IEnumerable, Type)
Converts the collection to an array.
Declaration
public static Array ToArray(this IEnumerable collection, Type elementType)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable | collection | The collection. |
Type | elementType | Type of the element. |
Returns
Type | Description |
---|---|
Array | Array. |
ToDataTable(ICollection, Type, String)
Converts to datatable.
Declaration
public static DataTable ToDataTable(this ICollection collection, Type type, string tableName)
Parameters
Type | Name | Description |
---|---|---|
ICollection | collection | The collection. |
Type | type | The type. |
System.String | tableName | Name of the table. |
Returns
Type | Description |
---|---|
DataTable | DataTable. |
ToDataTable<T>(ICollection<T>, String)
Converts to datatable.
Declaration
public static DataTable ToDataTable<T>(this ICollection<T> collection, string tableName)
Parameters
Type | Name | Description |
---|---|---|
ICollection<T> | collection | The collection. |
System.String | tableName | Name of the table. |
Returns
Type | Description |
---|---|
DataTable | DataTable. |
Type Parameters
Name | Description |
---|---|
T |