-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove numeral system converter and recode stream/bytes extensions.
- Loading branch information
XiaoFeiDu
committed
Dec 3, 2021
1 parent
a7f8d53
commit ff56101
Showing
30 changed files
with
457 additions
and
600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/GlobalUsings.cs":[326,1637834689005.552,"aa5db1bbc30d493a094b6f0ae7a4c40f8f58848b1952c95b2f4de6a01decc9ed"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Async.cs":[744,1637721450166.2708,"179fa4c6296ae9996345e37cf10a945af2e63def7b913ce54d00fdd7526be27b"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Bool.cs":[1493,1637721116645.7214,"39011fbe3d613611cd8f9168050a1dc111091e2586c4bfeee6a20873c15ed635"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Bytes.Base64.cs":[665,1637830115215.7222,"f975b6c3516bfb915174722686e8edcfa987ac1877cf2bf4ee327e118fcf82fa"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Bytes.Stream.Async.cs":[1133,1638513213059.253,"78e6005b686e69448ac7f68284b3092633bdcdf20bde0e9f6f690b0ae8389d4f"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Bytes.Stream.cs":[739,1638513204137.599,"3ff4a79a41b567ec77f53742c10391f09b22e9c8c5d8c8b446ee63f6f7fa6434"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Bytes.String.cs":[903,1637830097539.0042,"263e7c0fffa6087006a8440223206a1e20a03d7c8f821097e3d0e0c16c5bae14"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.DateTime.cs":[2019,1637566077083.7305,"b2318f4309deed4766e387e0a286dd032987db0cf0efee1591cb1fd4ec35876d"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.DateTimeOffset.cs":[2231,1637566100455.2039,"d65635672dce6dbbf14aecdc514be1509f0a61f858ef9ac12b8d320e5603b88e"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Enum.cs":[1506,1637566206878.1587,"6b45dfa7ccf839515b474378daa89ad12473f12149a195fdaf31dbf183dae231"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Enumerable.cs":[1597,1637739894267.768,"e62d8c2ab630d360c2e25930102d154afde174914e4c9322bf752c973539f262"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Exception.cs":[419,1637566217787.9724,"aaed78c512a97a3ede2d7b1c6e770f4ee12242ca8e93ca458b3706c94cf66251"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Int.cs":[309,1637834656418.689,"b61f09d335136d4a107268bedd4106bb35edd7b3a70518526f883359f4bd3673"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Nullable.cs":[463,1637739545364.3713,"e2f64142ad03b925be27c44d79ccceb3cc7a8f710daddd7be718dcae267abcd7"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Stream.cs":[375,1637828412632.9224,"ebbd2aae8f01e228707d6da480f57c87e2f86c8d6cc1f3144f3d2dda443a22e5"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Stream.Read.Async.cs":[2509,1638514558335.1257,"5c6cdd96ee51e1a60d712246116a80db30d1f75d23130be6ca7a2715c0138971"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Stream.Read.cs":[1011,1638512465095.6604,"43af2758dcd29825ae62a744b0f8a38548e8d4e922dc2d153c5d7c9b19ce7098"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Stream.Timeout.cs":[875,1637828399698.52,"de0788957518e038a8adff05a29eca4cd9b2add7884296e67bf7f0b64661ff67"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Stream.Write.Async.cs":[669,1638512361795.1216,"20f124e033dd65b05d2b521baf29e7e28aa91452b84125c0cf772e82ba5abad3"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Stream.Write.cs":[687,1638512411108.2366,"cb3c8c226266c417b29b54731e70da8dd11cd36a13c4c115e5471561e3d790ee"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.String.Base64.cs":[609,1637832372627.6255,"125becd6f0b8ef8fd496a4365fc3c092ca19107edd5ccd1fc6acd4d620df35c3"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.String.Bytes.cs":[869,1637832116962.8567,"71b4111e0705c34c1ef840bff35d7d9f3a52e316a237dfcfe6eb1c6fbb73fae9"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.String.cs":[1575,1638513422180.366,"c729511cf5c82c0b9c336846597e1eda37c76347cc7c65e33d85ef26e1819d7c"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.String.Parse.cs":[1393,1637832170569.9973,"0d71d3c61e031a1557dd87f510bcfeb91c9e2e5eb634c236f910ce25c3c3cce4"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.String.TryParse.cs":[2406,1637832289122.9846,"fdeb7bbb541983cea0d839198734162d7f33949b44fc39551b9547412296984d"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/src/Zaabee.Extensions/Zaabee.Extensions.Type.cs":[956,1637823326768.0024,"b448fed2bdadbbebf5425e7a403c9b30649faab0922fdda86f451c5479b64558"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/AsyncExtensionTest.cs":[525,1637566721337.2983,"fe3881ea92c69f0622d310890b59fc9927fa77d952205551763f7d4bffb56ecf"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/BoolExtensionTest.cs":[2458,1637566743182.8533,"3a999f00fdb8c2a34bafbc89f20cb8892db506761af363ad8c3435d07a84c701"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/BytesExtensionTest.cs":[4980,1637825262115.057,"e90d227c4c5528d9d1befdaa7025f8c1ad4f2c46b87c61f269df0c2b77fe8867"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/DateTimeExtensionTest.cs":[3109,1637566774523.0366,"342b751c1578ffda81ca665a8555e2afa7b6a007f47b584fc52e09f00329fd47"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/DateTimeOffsetExtensionTest.cs":[3311,1637566781994.0483,"af47a0b6f4a7afc4eff0a4554b80c763601934259e551360962d2ff292bef882"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/EnumerableExtensionTest.cs":[3421,1637740006250.299,"850bfa7d6916ba17d749cb49ec87c83c3dbfb1aaec5bd733ad24ae9de177637d"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/EnumExtensionTest.cs":[667,1637566894736.9595,"d1ebfbfe857eb028cdaaea10c27b52a1e97289ba70cb553d802f2d20b04f6d4d"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/ExceptionExtensionTest.cs":[418,1637566894726.993,"d58c8bc6d0823982edb8e351af449a0502ac153e67352f12487bf8adca24e89d"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/GlobalUsings.cs":[389,1638155342909.7449,"b233455c8c04ee4a5263a9964829499b7e48372913b123b11585b92c6133bc8a"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/IntExtensionTest.cs":[466,1637835024574.0715,"b46849392671db63e97689c6a261b7e61cc2e17ad0a4f4a4c597fb5739f02dd6"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/NullableExtensionTest.cs":[1060,1637723653962.7544,"51f5af17007981305339468987a90386a8fd0040847388df80f857f72bad849e"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/StreamExtensionTest.cs":[8335,1638513769865.6838,"fb04d9bc8daf54823478c2a650ae9d6945ed5f644a0695862c203d572979b01d"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/StringExtensionTest.cs":[15942,1637835055120.8704,"81bf4d33c37d0eb1d24ce7a2ed7ef2e43ab820299ea60cb6725105006e207ac5"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/TypeExtensionTest.cs":[4112,1638154332860.9795,"a3d001caab5a10661dce5fab40f0a6cdb43dd10e1876b622f4209cf63df8d072"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/Commons/FakeNetworkStream.cs":[1447,1637566637740.9414,"e795735b8064c1df71bee469113c9210f880c92720c003267668c66467e1ce90"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/Commons/MyCollection.cs":[1271,1637566653525.7126,"d511acc1039af67a34dbada3d2dd984ff90adf745e042a151f9235c890f3ce35"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/Commons/TestEnum.cs":[226,1637566674803.7898,"db808a848c4845aa828a9c03f9d2bbb2784e36a57263e97b82c830430579fba2"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/Commons/TestHelper.cs":[349,1637566697648.673,"3ccefd1d1e376561a0d64638f12061500671b27e532e437f6b910e2deb818cf5"],"c:/Users/aeond/OneDrive/MyProject/Mutuduxf/Zaabee.Extensions/tests/Zaabee.Extensions.UnitTest/Commons/TestModel.cs":[207,1637566712217.6946,"c6af26ecccb35539f539ed51cf1ba284dc3bb2e4bcf0649f5b4dee5e8ca6eaf0"]} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Zaabee.Extensions; | ||
|
||
public static partial class ZaabeeExtension | ||
{ | ||
public static string ToBase64String(this byte[] bytes) => | ||
Convert.ToBase64String(bytes); | ||
|
||
public static byte[] ToBase64Bytes(this byte[] bytes, Encoding? encoding = null) => | ||
bytes.ToBase64String().ToBytes(encoding); | ||
|
||
public static byte[] DecodeBase64ToBytes(this byte[] bytes, Encoding? encoding = null) => | ||
Convert.FromBase64String(bytes.GetString(encoding)); | ||
|
||
public static string DecodeBase64ToString(this byte[] bytes, Encoding? encoding = null) => | ||
Convert.FromBase64String(bytes.GetString(encoding)).GetString(encoding); | ||
} |
30 changes: 30 additions & 0 deletions
30
src/Zaabee.Extensions/Zaabee.Extensions.Bytes.Stream.Async.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace Zaabee.Extensions; | ||
|
||
public static partial class ZaabeeExtension | ||
{ | ||
public static async Task<MemoryStream> ToStreamAsync(this byte[] buffer, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
var ms = new MemoryStream(); | ||
await buffer.WriteToAsync(ms, cancellationToken); | ||
ms.Seek(0, SeekOrigin.Begin); | ||
return ms; | ||
} | ||
|
||
public static async Task<MemoryStream> TryToStreamAsync(this byte[] buffer, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
var ms = new MemoryStream(); | ||
await buffer.TryWriteToAsync(ms, cancellationToken); | ||
ms.Seek(0, SeekOrigin.Begin); | ||
return ms; | ||
} | ||
|
||
public static async Task WriteToAsync(this byte[] buffer, Stream stream, | ||
CancellationToken cancellationToken = default) => | ||
await stream.WriteAsync(buffer, 0, buffer.Length, cancellationToken); | ||
|
||
public static Task<bool> TryWriteToAsync(this byte[] buffer, Stream stream, | ||
CancellationToken cancellationToken = default) => | ||
stream.TryWriteAsync(buffer, 0, buffer.Length, cancellationToken); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace Zaabee.Extensions; | ||
|
||
public static partial class ZaabeeExtension | ||
{ | ||
public static MemoryStream ToStream(this byte[] buffer) | ||
{ | ||
var ms = new MemoryStream(); | ||
buffer.WriteTo(ms); | ||
ms.Seek(0, SeekOrigin.Begin); | ||
return ms; | ||
} | ||
|
||
public static MemoryStream TryToStream(this byte[] buffer) | ||
{ | ||
var ms = new MemoryStream(); | ||
buffer.TryWriteTo(ms); | ||
ms.Seek(0, SeekOrigin.Begin); | ||
return ms; | ||
} | ||
|
||
public static void WriteTo(this byte[] buffer, Stream stream) => | ||
stream.Write(buffer, 0, buffer.Length); | ||
|
||
public static bool TryWriteTo(this byte[] buffer, Stream stream) => | ||
stream.TryWrite(buffer, 0, buffer.Length); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace Zaabee.Extensions; | ||
|
||
public static partial class ZaabeeExtension | ||
{ | ||
public static string GetStringByUtf8(this byte[] bytes) => | ||
bytes.GetString(Encoding.UTF8); | ||
|
||
public static string GetStringByAscii(this byte[] bytes) => | ||
bytes.GetString(Encoding.ASCII); | ||
|
||
public static string GetStringByBigEndianUnicode(this byte[] bytes) => | ||
bytes.GetString(Encoding.BigEndianUnicode); | ||
|
||
public static string GetStringByDefault(this byte[] bytes) => | ||
bytes.GetString(Encoding.Default); | ||
|
||
public static string GetStringByUtf32(this byte[] bytes) => | ||
bytes.GetString(Encoding.UTF32); | ||
|
||
public static string GetStringByUnicode(this byte[] bytes) => | ||
bytes.GetString(Encoding.Unicode); | ||
|
||
public static string GetString(this byte[] bytes, Encoding? encoding = null) => | ||
(encoding ?? Encoding.UTF8).GetString(bytes); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.