|
@@ -2674,5 +2674,22 @@ namespace InABox.Core
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+ #region IEnumerable Utilities
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Returns <paramref name="enumerable"/> as a <see cref="List{T}"/>;
|
|
|
+ /// if it is already a <see cref="List{T}"/>, it is directly returned, instead of copying.
|
|
|
+ /// </summary>
|
|
|
+ public static List<T> AsList<T>(this IEnumerable<T> enumerable)
|
|
|
+ {
|
|
|
+ if(enumerable is List<T> list)
|
|
|
+ {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ return enumerable.ToList<T>();
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
}
|
|
|
}
|