lith 3 tahun lalu
induk
melakukan
7f50657bc7

+ 26 - 5
dotnet/Library/Vit/Vit.Core/Vit.Core/Extensions/byte/ByteDataExtensions.cs

@@ -7,7 +7,6 @@ namespace Vit.Extensions
     public static partial class ByteDataExtensions
     {
 
-        #region ByteDataToBytes
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public static byte[] ByteDataToBytes(this List<ArraySegment<byte>> byteData)
@@ -26,9 +25,9 @@ namespace Vit.Extensions
             int curIndex = 0;
             foreach (var item in byteData)
             {
-                if (null == item.Array || item.Count == 0) continue; 
+                if (null == item.Array || item.Count == 0) continue;
 
-                item.CopyTo(bytes, curIndex);                
+                item.CopyTo(bytes, curIndex);
 
                 curIndex += item.Count;
             }
@@ -37,12 +36,34 @@ namespace Vit.Extensions
 
 
 
-        #endregion
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public static byte[] ByteDataToBytes(this List<byte[]> byteData)
+        {
+            //(x.1)get length
+            int count = 0;
+            foreach (var item in byteData)
+            {
+                count += item.Length;
+            }
 
 
+            //(x.2) copy data
+            var bytes = new byte[count];
+
+            int curIndex = 0;
+            foreach (var item in byteData)
+            {
+                if (null == item || item.Length == 0) continue;
+
+                item.CopyTo(bytes, curIndex);
+
+                curIndex += item.Length;
+            }
+            return bytes;
+        }
 
 
-        
 
     }
 }