|
@@ -2731,6 +2731,19 @@ namespace InABox.Core
|
|
|
return enumerable.ToList<T>();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Returns <paramref name="enumerable"/> as an <see cref="IList{T}"/>;
|
|
|
+ /// if it is already a <see cref="IList{T}"/>, it is directly returned, instead of copying.
|
|
|
+ /// </summary>
|
|
|
+ public static IList<T> AsIList<T>(this IEnumerable<T> enumerable)
|
|
|
+ {
|
|
|
+ if (enumerable is IList<T> list)
|
|
|
+ {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ return enumerable.ToList<T>();
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Returns <paramref name="enumerable"/> as an array;
|
|
|
/// if it is already an array, it is directly returned, instead of copying.
|