-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
204 additions
and
156 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,52 @@ | ||
namespace YANLib.Ultimate; | ||
|
||
public static partial class YANJson | ||
{ | ||
public static IEnumerable<string> Serializes<T>(this IEnumerable<T> mdls) | ||
{ | ||
if (mdls is null || !mdls.Any()) | ||
{ | ||
yield break; | ||
} | ||
foreach (var mdl in mdls) | ||
{ | ||
yield return mdl.Serialize(); | ||
} | ||
} | ||
|
||
public static IEnumerable<string> CamelSerializes<T>(this IEnumerable<T> mdls) | ||
{ | ||
if (mdls is null || !mdls.Any()) | ||
{ | ||
yield break; | ||
} | ||
foreach (var mdl in mdls) | ||
{ | ||
yield return mdl.CamelSerialize(); | ||
} | ||
} | ||
|
||
public static IEnumerable<T?> StandardDeserializes<T>(this IEnumerable<string> strs) | ||
{ | ||
if (strs is null || !strs.Any()) | ||
{ | ||
yield break; | ||
} | ||
foreach (var str in strs) | ||
{ | ||
yield return str.StandardDeserialize<T>(); | ||
} | ||
} | ||
|
||
public static IEnumerable<T?> Deserializes<T>(this IEnumerable<string> strs) | ||
{ | ||
if (strs is null || !strs.Any()) | ||
{ | ||
yield break; | ||
} | ||
foreach (var str in strs) | ||
{ | ||
yield return str.Deserialize<T>(); | ||
} | ||
} | ||
} |
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,76 @@ | ||
namespace YANLib.Ultimate; | ||
|
||
public static partial class YANNum | ||
{ | ||
public static IEnumerable<byte> ToByte<T>(this IEnumerable<T?> nums) where T : struct | ||
{ | ||
if (nums is null || !nums.Any()) | ||
{ | ||
yield break; | ||
} | ||
foreach (var num in nums) | ||
{ | ||
yield return num.ToByte(); | ||
} | ||
} | ||
|
||
public static IEnumerable<byte> ToByte<T>(this IEnumerable<string> strs, T? dfltVal) where T : struct | ||
{ | ||
if (strs is null || !strs.Any()) | ||
{ | ||
yield break; | ||
} | ||
foreach (var str in strs) | ||
{ | ||
yield return str.ToByte(dfltVal); | ||
} | ||
} | ||
|
||
public static IEnumerable<byte> GenerateRandomBytes<T1, T2, T>(T1? min, T2 max, T size) where T1 : struct where T2 : struct where T : struct | ||
{ | ||
for (var i = 0ul; i < size.ToUlong(); i++) | ||
{ | ||
yield return YANLib.YANNum.GenerateRandomByte(min, max); | ||
} | ||
} | ||
|
||
public static IEnumerable<byte> GenerateRandomBytes<T1, T2, T>(T1? min, T2 max, T? size) where T1 : struct where T2 : struct where T : struct | ||
{ | ||
for (var i = 0ul; i < size.ToUlong(); i++) | ||
{ | ||
yield return YANLib.YANNum.GenerateRandomByte(min, max); | ||
} | ||
} | ||
|
||
public static IEnumerable<byte> GenerateRandomBytes<T1, T2, T>(T1 min, T2? max, T size) where T1 : struct where T2 : struct where T : struct | ||
{ | ||
for (var i = 0ul; i < size.ToUlong(); i++) | ||
{ | ||
yield return YANLib.YANNum.GenerateRandomByte(min, max); | ||
} | ||
} | ||
|
||
public static IEnumerable<byte> GenerateRandomBytes<T1, T2, T>(T1 min, T2? max, T? size) where T1 : struct where T2 : struct where T : struct | ||
{ | ||
for (var i = 0ul; i < size.ToUlong(); i++) | ||
{ | ||
yield return YANLib.YANNum.GenerateRandomByte(min, max); | ||
} | ||
} | ||
|
||
public static IEnumerable<byte> GenerateRandomBytes<T1, T2, T>(T1? min, T2? max, T size) where T1 : struct where T2 : struct where T : struct | ||
{ | ||
for (var i = 0ul; i < size.ToUlong(); i++) | ||
{ | ||
yield return YANLib.YANNum.GenerateRandomByte(min, max); | ||
} | ||
} | ||
|
||
public static IEnumerable<byte> GenerateRandomBytes<T1, T2, T>(T1? min, T2? max, T? size) where T1 : struct where T2 : struct where T : struct | ||
{ | ||
for (var i = 0ul; i < size.ToUlong(); i++) | ||
{ | ||
yield return YANLib.YANNum.GenerateRandomByte(min, max); | ||
} | ||
} | ||
} |
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,48 @@ | ||
namespace YANLib.Ultimate; | ||
|
||
public static partial class YANNum | ||
{ | ||
public static IEnumerable<byte> ToByte<T>(this IEnumerable<T> nums) where T : struct | ||
{ | ||
if (nums is null || !nums.Any()) | ||
{ | ||
yield break; | ||
} | ||
foreach (var num in nums) | ||
{ | ||
yield return num.ToByte(); | ||
} | ||
} | ||
|
||
public static IEnumerable<byte> ToByte(this IEnumerable<string> strs) | ||
{ | ||
if (strs is null || !strs.Any()) | ||
{ | ||
yield break; | ||
} | ||
foreach (var str in strs) | ||
{ | ||
yield return YANLib.YANNum.ToByte(str); | ||
} | ||
} | ||
|
||
public static IEnumerable<byte> ToByte<T>(this IEnumerable<string> strs, T dfltVal) where T : struct | ||
{ | ||
if (strs is null || !strs.Any()) | ||
{ | ||
yield break; | ||
} | ||
foreach (var str in strs) | ||
{ | ||
yield return str.ToByte(dfltVal); | ||
} | ||
} | ||
|
||
public static IEnumerable<byte> GenerateRandomBytes<T1, T2, T>(T1 min, T2 max, T size) where T1 : struct where T2 : struct where T : struct | ||
{ | ||
for (var i = 0ul; i < size.ToUlong(); i++) | ||
{ | ||
yield return YANLib.YANNum.GenerateRandomByte(min, max); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.