aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Extensions/CopyToExtensions.cs
diff options
context:
space:
mode:
authordkanada <dkanada@users.noreply.github.com>2019-11-02 04:03:36 +0900
committerGitHub <noreply@github.com>2019-11-02 04:03:36 +0900
commit3bfb36a67d1ace11b73c25699efe3136025cf2ed (patch)
treed3b16b8897929eab3abd8ab2cd8cc8fc1e8c1dad /MediaBrowser.Common/Extensions/CopyToExtensions.cs
parent48a99366b6bd0fea13fb40c6c16374052d5adb6d (diff)
parent60cb256835ff7601ee8ad7deefe52c1ef1c3b305 (diff)
Merge pull request #1915 from Bond-009/hex
Rewrite hex encoder/decoder
Diffstat (limited to 'MediaBrowser.Common/Extensions/CopyToExtensions.cs')
-rw-r--r--MediaBrowser.Common/Extensions/CopyToExtensions.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/MediaBrowser.Common/Extensions/CopyToExtensions.cs b/MediaBrowser.Common/Extensions/CopyToExtensions.cs
new file mode 100644
index 000000000..78a73f07e
--- /dev/null
+++ b/MediaBrowser.Common/Extensions/CopyToExtensions.cs
@@ -0,0 +1,26 @@
+using System.Collections.Generic;
+
+namespace MediaBrowser.Common.Extensions
+{
+ /// <summary>
+ /// Provides <c>CopyTo</c> extensions methods for <see cref="IReadOnlyList{T}" />.
+ /// </summary>
+ public static class CollectionExtensions
+ {
+ /// <summary>
+ /// Copies all the elements of the current collection to the specified list
+ /// starting at the specified destination array index. The index is specified as a 32-bit integer.
+ /// </summary>
+ /// <param name="source">The current collection that is the source of the elements.</param>
+ /// <param name="destination">The list that is the destination of the elements copied from the current collection.</param>
+ /// <param name="index">A 32-bit integer that represents the index in <c>destination</c> at which copying begins.</param>
+ /// <typeparam name="T"></typeparam>
+ public static void CopyTo<T>(this IReadOnlyList<T> source, IList<T> destination, int index = 0)
+ {
+ for (int i = 0; i < source.Count; i++)
+ {
+ destination[index + i] = source[i];
+ }
+ }
+ }
+}