diff --git a/console/YANLib.Benchmarks/Process/Common/ClassTypeBenchmark.cs b/console/YANLib.Benchmarks/Process/Common/ClassTypeBenchmark.cs index a896b680..e907a1a4 100644 --- a/console/YANLib.Benchmarks/Process/Common/ClassTypeBenchmark.cs +++ b/console/YANLib.Benchmarks/Process/Common/ClassTypeBenchmark.cs @@ -1,7 +1,4 @@ -using BenchmarkDotNet.Attributes; -using YANLib.Benchmarks.Models; -using static System.Guid; -using static System.Threading.Tasks.Parallel; +using YANLib.Benchmarks.Models; namespace YANLib.Benchmarks.Process.Common; diff --git a/console/YANLib.Benchmarks/Process/Common/HttpBenchmark.cs b/console/YANLib.Benchmarks/Process/Common/HttpBenchmark.cs index 8adc563d..e86d39a4 100644 --- a/console/YANLib.Benchmarks/Process/Common/HttpBenchmark.cs +++ b/console/YANLib.Benchmarks/Process/Common/HttpBenchmark.cs @@ -1,6 +1,4 @@ -using BenchmarkDotNet.Attributes; - -namespace YANLib.Benchmarks.Process.Common; +namespace YANLib.Benchmarks.Process.Common; public class HttpBenchmark { diff --git a/console/YANLib.Benchmarks/Process/Common/LoopBenchmark.cs b/console/YANLib.Benchmarks/Process/Common/LoopBenchmark.cs index b69e8df2..e29f6f2f 100644 --- a/console/YANLib.Benchmarks/Process/Common/LoopBenchmark.cs +++ b/console/YANLib.Benchmarks/Process/Common/LoopBenchmark.cs @@ -1,7 +1,4 @@ -using BenchmarkDotNet.Attributes; -using static System.Runtime.InteropServices.CollectionsMarshal; - -namespace YANLib.Benchmarks.Process.Common; +namespace YANLib.Benchmarks.Process.Common; public class LoopBenchmark { diff --git a/console/YANLib.Benchmarks/Process/Library/JsonDeserializeBenchmark.cs b/console/YANLib.Benchmarks/Process/Library/JsonDeserializeBenchmark.cs index 0900a34a..9f87af6f 100644 --- a/console/YANLib.Benchmarks/Process/Library/JsonDeserializeBenchmark.cs +++ b/console/YANLib.Benchmarks/Process/Library/JsonDeserializeBenchmark.cs @@ -1,9 +1,4 @@ -using BenchmarkDotNet.Attributes; -using YANLib.Benchmarks.Models; -using YANLib.Core; -using static Newtonsoft.Json.JsonConvert; -using static System.Guid; -using static System.Threading.Tasks.Parallel; +using YANLib.Benchmarks.Models; namespace YANLib.Benchmarks.Process.Library; diff --git a/console/YANLib.Benchmarks/Process/Library/JsonSerializeBenchmark.cs b/console/YANLib.Benchmarks/Process/Library/JsonSerializeBenchmark.cs index 1375e05b..8f18b908 100644 --- a/console/YANLib.Benchmarks/Process/Library/JsonSerializeBenchmark.cs +++ b/console/YANLib.Benchmarks/Process/Library/JsonSerializeBenchmark.cs @@ -1,9 +1,4 @@ -using BenchmarkDotNet.Attributes; -using YANLib.Benchmarks.Models; -using YANLib.Core; -using static Newtonsoft.Json.JsonConvert; -using static System.Guid; -using static System.Threading.Tasks.Parallel; +using YANLib.Benchmarks.Models; namespace YANLib.Benchmarks.Process.Library; diff --git a/console/YANLib.Benchmarks/Program.cs b/console/YANLib.Benchmarks/Program.cs index 027b5b3f..34a9e49a 100644 --- a/console/YANLib.Benchmarks/Program.cs +++ b/console/YANLib.Benchmarks/Program.cs @@ -1,6 +1,4 @@ -using static System.Console; - -#if RELEASE +#if RELEASE using YANLib.Benchmarks.Process.Common; using YANLib.Benchmarks.Process.Library; using static BenchmarkDotNet.Running.BenchmarkRunner; diff --git a/host/YANLib.HttpApi.Host/Controllers/HomeController.cs b/host/YANLib.HttpApi.Host/Controllers/HomeController.cs index 1d3b5691..88006e09 100644 --- a/host/YANLib.HttpApi.Host/Controllers/HomeController.cs +++ b/host/YANLib.HttpApi.Host/Controllers/HomeController.cs @@ -1,7 +1,4 @@ -using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc; - -namespace YANLib.Controllers; +namespace YANLib.Controllers; public class HomeController : AbpController { diff --git a/host/YANLib.HttpApi.Host/EntityFrameworkCore/YANLibHttpApiHostMigrationsDbContext.cs b/host/YANLib.HttpApi.Host/EntityFrameworkCore/YANLibHttpApiHostMigrationsDbContext.cs index 0e785e36..e448b770 100644 --- a/host/YANLib.HttpApi.Host/EntityFrameworkCore/YANLibHttpApiHostMigrationsDbContext.cs +++ b/host/YANLib.HttpApi.Host/EntityFrameworkCore/YANLibHttpApiHostMigrationsDbContext.cs @@ -1,7 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore; - -namespace YANLib.EntityFrameworkCore; +namespace YANLib.EntityFrameworkCore; public class YANLibHttpApiHostMigrationsDbContext(DbContextOptions options) : AbpDbContext(options) { diff --git a/host/YANLib.HttpApi.Host/EntityFrameworkCore/YANLibHttpApiHostMigrationsDbContextFactory.cs b/host/YANLib.HttpApi.Host/EntityFrameworkCore/YANLibHttpApiHostMigrationsDbContextFactory.cs index dc541f12..0a86b201 100644 --- a/host/YANLib.HttpApi.Host/EntityFrameworkCore/YANLibHttpApiHostMigrationsDbContextFactory.cs +++ b/host/YANLib.HttpApi.Host/EntityFrameworkCore/YANLibHttpApiHostMigrationsDbContextFactory.cs @@ -1,9 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; -using static System.IO.Directory; - -namespace YANLib.EntityFrameworkCore; +namespace YANLib.EntityFrameworkCore; public class YANLibHttpApiHostMigrationsDbContextFactory : IDesignTimeDbContextFactory { diff --git a/host/YANLib.HttpApi.Host/Middlewares/UnauthorizedHandlerMiddleware.cs b/host/YANLib.HttpApi.Host/Middlewares/UnauthorizedHandlerMiddleware.cs index 15bb4bd1..59cdde2e 100644 --- a/host/YANLib.HttpApi.Host/Middlewares/UnauthorizedHandlerMiddleware.cs +++ b/host/YANLib.HttpApi.Host/Middlewares/UnauthorizedHandlerMiddleware.cs @@ -1,12 +1,4 @@ -using Microsoft.AspNetCore.Http; -using System; -using System.IO; -using System.Threading.Tasks; -using static Microsoft.AspNetCore.Http.StatusCodes; -using static Serilog.Log; -using static System.Net.HttpStatusCode; - -namespace YANLib.Middlewares; +namespace YANLib.Middlewares; public class UnauthorizedHandlerMiddleware(RequestDelegate next) { diff --git a/host/YANLib.HttpApi.Host/Program.cs b/host/YANLib.HttpApi.Host/Program.cs index b26d3830..a2c3e331 100644 --- a/host/YANLib.HttpApi.Host/Program.cs +++ b/host/YANLib.HttpApi.Host/Program.cs @@ -1,12 +1,4 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Serilog; -using System; -using System.Threading.Tasks; -using static Microsoft.AspNetCore.Builder.WebApplication; - -namespace YANLib; +namespace YANLib; public class Program { diff --git a/host/YANLib.HttpApi.Host/YANLibBrandingProvider.cs b/host/YANLib.HttpApi.Host/YANLibBrandingProvider.cs index cbb15035..dc45a27f 100644 --- a/host/YANLib.HttpApi.Host/YANLibBrandingProvider.cs +++ b/host/YANLib.HttpApi.Host/YANLibBrandingProvider.cs @@ -1,7 +1,4 @@ -using Volo.Abp.DependencyInjection; -using Volo.Abp.Ui.Branding; - -namespace YANLib; +namespace YANLib; [Dependency(ReplaceServices = true)] public class YANLibBrandingProvider : DefaultBrandingProvider diff --git a/host/YANLib.HttpApi.Host/YANLibHttpApiHostModule.cs b/host/YANLib.HttpApi.Host/YANLibHttpApiHostModule.cs index 546d935f..9adaca75 100644 --- a/host/YANLib.HttpApi.Host/YANLibHttpApiHostModule.cs +++ b/host/YANLib.HttpApi.Host/YANLibHttpApiHostModule.cs @@ -1,51 +1,6 @@ -using DotNetCore.CAP; -using Elastic.Apm.DiagnosticSource; -using Elastic.Apm.EntityFrameworkCore; -using Elastic.Apm.NetCoreAll; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Cors; -using Microsoft.AspNetCore.Diagnostics.HealthChecks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.OpenApi.Models; -using MongoDB.Driver; -using System; -using System.Collections.Generic; -using System.Linq; -using Volo.Abp; -using Volo.Abp.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Serilog; -using Volo.Abp.Autofac; -using Volo.Abp.Caching; -using Volo.Abp.Caching.StackExchangeRedis; -using Volo.Abp.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore.SqlServer; -using Volo.Abp.EventBus.Azure; -using Volo.Abp.EventBus.RabbitMq; -using Volo.Abp.Http.Client; -using Volo.Abp.Localization; -using Volo.Abp.Modularity; -using Volo.Abp.MultiTenancy; -using Volo.Abp.Swashbuckle; -using YANLib.EntityFrameworkCore; -using YANLib.Utilities; -using static Elastic.Apm.Agent; -using static HealthChecks.UI.Client.UIResponseWriter; -using static Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults; -using static Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus; -using static System.Convert; -using static System.StringSplitOptions; #if !DEBUG -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Http; using YANLib.Middlewares; -using static Microsoft.OpenApi.Models.ParameterLocation; -using static Microsoft.OpenApi.Models.SecuritySchemeType; -using static System.Net.HttpStatusCode; -using static System.Threading.Tasks.Task; #endif namespace YANLib; diff --git a/lib/YANLib/Core/YANBytes.cs b/lib/YANLib/Core/YANBytes.cs index 29ba676e..52336e13 100644 --- a/lib/YANLib/Core/YANBytes.cs +++ b/lib/YANLib/Core/YANBytes.cs @@ -13,32 +13,11 @@ public static partial class YANBytes /// A byte array representing the UTF-8 encoded serialization of the input object, or if the input object is . public static byte[]? ToByteArray(this object? val) => val.IsNull() ? default : UTF8.GetBytes(val.StandardSerialize() ?? string.Empty); - /// - /// Converts a collection of objects to an enumerable collection of byte arrays. - /// If the collection is or empty, returns . - /// Each object in the collection is converted to a byte array. - /// - /// The collection of objects to be converted to byte arrays. Can be . - /// An enumerable collection of byte arrays, or if the input collection is or empty. public static IEnumerable? ToByteArrays(this IEnumerable? vals) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToByteArray()); - /// - /// Converts a collection (ICollection) of objects to an enumerable collection of byte arrays. - /// If the collection is or empty, returns . - /// Each object in the collection is converted to a byte array. - /// - /// The ICollection of objects to be converted to byte arrays. Can be . - /// An enumerable collection of byte arrays, or if the input ICollection is or empty. public static IEnumerable? ToByteArrays(this ICollection? vals) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToByteArray()); - /// - /// Converts an array of objects to an enumerable collection of byte arrays. - /// If the array is or empty, returns . - /// Each object in the array is converted to a byte array. - /// - /// The array of objects to be converted to byte arrays. Can be . - /// An enumerable collection of byte arrays, or if the input array is or empty. - public static IEnumerable? ToByteArrays(this object?[]? vals) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToByteArray()); + public static IEnumerable? ToByteArrays(params object?[]? vals) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToByteArray()); /// /// Converts a byte array to its equivalent object of type . @@ -49,30 +28,9 @@ public static partial class YANBytes /// The object of type represented by the deserialized byte array, or the default value of type if the byte array is . public static T? FromByteArray(this byte[]? arr) => arr.IsNull() ? default : UTF8.GetString(arr).Deserialize(); - /// - /// Converts a collection of byte arrays to an enumerable collection of objects of type . - /// If the collection is or empty, returns . - /// Each byte array in the collection is converted to an object of type . - /// - /// The collection of byte arrays to be converted. Can be . - /// An enumerable collection of objects of type , or if the input collection is or empty. public static IEnumerable? FromByteArrays(this IEnumerable? arrs) => arrs.IsEmptyOrNull() ? default : arrs.Select(x => x.FromByteArray()); - /// - /// Converts a collection (ICollection) of byte arrays to an enumerable collection of objects of type . - /// If the collection is or empty, returns . - /// Each byte array in the collection is converted to an object of type . - /// - /// The ICollection of byte arrays to be converted. Can be . - /// An enumerable collection of objects of type , or if the input ICollection is or empty. public static IEnumerable? FromByteArrays(this ICollection? arrs) => arrs.IsEmptyOrNull() ? default : arrs.Select(x => x.FromByteArray()); - /// - /// Converts an array of byte arrays to an enumerable collection of objects of type . - /// If the array is or empty, returns . - /// Each byte array in the array is converted to an object of type . - /// - /// The array of byte arrays to be converted. Can be . - /// An enumerable collection of objects of type , or if the input array is or empty. - public static IEnumerable? FromByteArrays(this byte[]?[]? arrs) => arrs.IsEmptyOrNull() ? default : arrs.Select(x => x.FromByteArray()); + public static IEnumerable? FromByteArrays(params byte[]?[]? arrs) => arrs.IsEmptyOrNull() ? default : arrs.Select(x => x.FromByteArray()); } diff --git a/lib/YANLib/Core/YANDateTime.cs b/lib/YANLib/Core/YANDateTime.cs index 60ee5fa8..d8dd0482 100644 --- a/lib/YANLib/Core/YANDateTime.cs +++ b/lib/YANLib/Core/YANDateTime.cs @@ -68,86 +68,33 @@ public static DateTime ToDateTime(this string? str, string? fmt = null, DateTime /// The week of the year for the specified , or the default integer value if is . public static int GetWeekOfYear(this DateTime? dt) => dt.HasValue ? CurrentInfo.Calendar.GetWeekOfYear(dt.Value, CurrentInfo.CalendarWeekRule, CurrentInfo.FirstDayOfWeek) : default; - /// - /// Converts a collection of nullable values to their respective week numbers of the year. - /// If the collection is or empty, returns . - /// - /// The collection of nullable values. Can be . - /// An enumerable collection of integers representing the week numbers of the year, or if the input collection is or empty. - public static IEnumerable? GetWeekOfYears(this IEnumerable? dts) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.GetWeekOfYear()); - - /// - /// Converts a collection of values to their respective week numbers of the year. - /// If the collection is or empty, returns . - /// - /// The collection of values. Can be . - /// An enumerable collection of integers representing the week numbers of the year, or if the input collection is or empty. public static IEnumerable? GetWeekOfYears(this IEnumerable? dts) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.GetWeekOfYear()); - /// - /// Converts a collection (ICollection) of nullable values to their respective week numbers of the year. - /// If the collection is or empty, returns . - /// - /// The ICollection of nullable values. Can be . - /// An enumerable collection of integers representing the week numbers of the year, or if the input ICollection is or empty. - public static IEnumerable? GetWeekOfYears(this ICollection? dts) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.GetWeekOfYear()); - - /// - /// Converts a collection (ICollection) of values to their respective week numbers of the year. - /// If the collection is or empty, returns . - /// - /// The ICollection of values. Can be . - /// An enumerable collection of integers representing the week numbers of the year, or if the input ICollection is or empty. public static IEnumerable? GetWeekOfYears(this ICollection? dts) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.GetWeekOfYear()); - /// - /// Converts an array of nullable values to their respective week numbers of the year. - /// If the array is or empty, returns . - /// - /// The array of nullable values. Can be . - /// An enumerable collection of integers representing the week numbers of the year, or if the input array is or empty. - public static IEnumerable? GetWeekOfYears(this DateTime?[]? dts) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.GetWeekOfYear()); + public static IEnumerable? GetWeekOfYears(params DateTime[]? dts) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.GetWeekOfYear()); - /// - /// Converts an array of values to their respective week numbers of the year. - /// If the array is or empty, returns . - /// - /// The array of values. Can be . - /// An enumerable collection of integers representing the week numbers of the year, or if the input array is or empty. - public static IEnumerable? GetWeekOfYears(this DateTime[]? dts) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.GetWeekOfYear()); + public static IEnumerable? GetWeekOfYears(this IEnumerable? dts) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.GetWeekOfYear()); + + public static IEnumerable? GetWeekOfYears(this ICollection? dts) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.GetWeekOfYear()); + + public static IEnumerable? GetWeekOfYears(params DateTime?[]? dts) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.GetWeekOfYear()); public static int TotalMonth(DateTime dt1, DateTime dt2) => Abs((dt1.Year - dt2.Year) * 12 + dt1.Month - dt2.Month); - /// - /// Changes the time zone of the given . - /// Adjusts the by the difference in hours between the source and destination time zones. - /// If the adjustment results in a date outside the valid range of , returns the default . - /// - /// The to change the time zone for. - /// The source time zone. Can be . - /// The destination time zone. Can be . - /// The adjusted to the new time zone, or the default if the adjustment results in an invalid date. public static DateTime ChangeTimeZone(this DateTime dt, object? tzSrc = null, object? tzDst = null) { var diff = tzDst.ToInt() - tzSrc.ToInt(); return diff switch { - < 0 when (dt - MinValue).TotalHours < Abs(diff) => default, - > 0 when (MaxValue - dt).TotalHours < diff => default, + 0 => dt, + < 0 when (dt - MinValue).TotalHours < Abs(diff) => dt, + > 0 when (MaxValue - dt).TotalHours < diff => dt, _ => dt.AddHours(diff) }; } - /// - /// Changes the time zone of a nullable . - /// If the has a value, adjusts it by the difference in hours between the source and destination time zones. - /// If the adjustment results in a date outside the valid range of , or if the is , returns the default . - /// - /// The nullable to change the time zone for. Can be . - /// The source time zone. Can be . - /// The destination time zone. Can be . - /// The adjusted to the new time zone, or the default if the adjustment results in an invalid date or if is . public static DateTime ChangeTimeZone(this DateTime? dt, object? tzSrc = null, object? tzDst = null) { if (!dt.HasValue) @@ -159,87 +106,54 @@ public static DateTime ChangeTimeZone(this DateTime? dt, object? tzSrc = null, o return diff switch { - < 0 when (dt.Value - MinValue).TotalHours < Abs(diff) => default, - > 0 when (MaxValue - dt.Value).TotalHours < diff => default, + 0 => dt.Value, + < 0 when (dt.Value - MinValue).TotalHours < Abs(diff) => dt.Value, + > 0 when (MaxValue - dt.Value).TotalHours < diff => dt.Value, _ => dt.Value.AddHours(diff) }; } - /// - /// Changes the time zones of a collection of nullable values. - /// Adjusts each in the collection by the difference in hours between the source and destination time zones. - /// If the collection is or empty, returns . - /// - /// The collection of nullable values to change the time zones for. Can be . - /// The source time zone. Can be . - /// The destination time zone. Can be . - /// An enumerable collection of nullable values adjusted to the new time zones, or if the input collection is or empty. - public static IEnumerable? ChangeTimeZones(this IEnumerable? dts, object? tzSrc = null, object? tzDst = null) => dts.IsEmptyOrNull() - ? default - : dts.Select(x => x.ChangeTimeZone(tzSrc, tzDst)); + public static void ChangeTimeZone(this List? dts, object? tzSrc = null, object? tzDst = null) + { + if (dts.IsEmptyOrNull()) + { + return; + } + + dts.ForEach(x => x = x.ChangeTimeZone(tzSrc, tzDst)); + } - /// - /// Changes the time zones of a collection of values. - /// Adjusts each in the collection by the difference in hours between the source and destination time zones. - /// If the collection is or empty, returns . - /// - /// The collection of values to change the time zones for. Can be . - /// The source time zone. Can be . - /// The destination time zone. Can be . - /// An enumerable collection of values adjusted to the new time zones, or if the input collection is or empty. public static IEnumerable? ChangeTimeZones(this IEnumerable? dts, object? tzSrc = null, object? tzDst = null) => dts.IsEmptyOrNull() - ? default + ? dts : dts.Select(x => x.ChangeTimeZone(tzSrc, tzDst)); - /// - /// Changes the time zones of a collection (ICollection) of nullable values. - /// Adjusts each in the collection by the difference in hours between the source and destination time zones. - /// If the collection is or empty, returns . - /// - /// The ICollection of nullable values to change the time zones for. Can be . - /// The source time zone. Can be . - /// The destination time zone. Can be . - /// An enumerable collection of nullable values adjusted to the new time zones, or if the input ICollection is or empty. - public static IEnumerable? ChangeTimeZones(this ICollection? dts, object? tzSrc = null, object? tzDst = null) => dts.IsEmptyOrNull() - ? default + public static IEnumerable? ChangeTimeZones(this ICollection? dts, object? tzSrc = null, object? tzDst = null) => dts.IsEmptyOrNull() + ? dts : dts.Select(x => x.ChangeTimeZone(tzSrc, tzDst)); - /// - /// Changes the time zones of a collection (ICollection) of values. - /// Adjusts each in the collection by the difference in hours between the source and destination time zones. - /// If the collection is or empty, returns . - /// - /// The ICollection of values to change the time zones for. Can be . - /// The source time zone. Can be . - /// The destination time zone. Can be . - /// An enumerable collection of values adjusted to the new time zones, or if the input ICollection is or empty. - public static IEnumerable? ChangeTimeZones(this ICollection? dts, object? tzSrc = null, object? tzDst = null) => dts.IsEmptyOrNull() + public static IEnumerable? ChangeTimeZones(this DateTime[]? dts, object? tzSrc = null, object? tzDst = null) => dts.IsEmptyOrNull() + ? dts + : dts.Select(x => x.ChangeTimeZone(tzSrc, tzDst)); + + public static void ChangeTimeZone(this List? dts, object? tzSrc = null, object? tzDst = null) + { + if (dts.IsEmptyOrNull()) + { + return; + } + + dts.ForEach(x => x = x.ChangeTimeZone(tzSrc, tzDst)); + } + + public static IEnumerable? ChangeTimeZones(this IEnumerable? dts, object? tzSrc = null, object? tzDst = null) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.ChangeTimeZone(tzSrc, tzDst)); - /// - /// Changes the time zones of an array of nullable values. - /// Adjusts each in the array by the difference in hours between the source and destination time zones. - /// If the array is or empty, returns . - /// - /// The array of nullable values to change the time zones for. Can be . - /// The source time zone. Can be . - /// The destination time zone. Can be . - /// An enumerable collection of nullable values adjusted to the new time zones, or if the input array is or empty. - public static IEnumerable? ChangeTimeZones(this DateTime?[]? dts, object? tzSrc = null, object? tzDst = null) => dts.IsEmptyOrNull() + public static IEnumerable? ChangeTimeZones(this ICollection? dts, object? tzSrc = null, object? tzDst = null) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.ChangeTimeZone(tzSrc, tzDst)); - /// - /// Changes the time zones of an array of values. - /// Adjusts each in the array by the difference in hours between the source and destination time zones. - /// If the array is or empty, returns . - /// - /// The array of values to change the time zones for. Can be . - /// The source time zone. Can be . - /// The destination time zone. Can be . - /// An enumerable collection of values adjusted to the new time zones, or if the input array is or empty. - public static IEnumerable? ChangeTimeZones(this DateTime[]? dts, object? tzSrc = null, object? tzDst = null) => dts.IsEmptyOrNull() + public static IEnumerable? ChangeTimeZones(this DateTime?[]? dts, object? tzSrc = null, object? tzDst = null) => dts.IsEmptyOrNull() ? default : dts.Select(x => x.ChangeTimeZone(tzSrc, tzDst)); } diff --git a/lib/YANLib/Core/YANEnum.cs b/lib/YANLib/Core/YANEnum.cs index 17b53c02..b259d55f 100644 --- a/lib/YANLib/Core/YANEnum.cs +++ b/lib/YANLib/Core/YANEnum.cs @@ -28,5 +28,5 @@ public static partial class YANEnum /// /// The array of strings to be converted to enumeration values of type . Can be . /// An enumerable collection of enumeration values of type , or for any string that does not correspond to a valid enumeration value. - public static IEnumerable? ToEnums(this string?[]? vals) where T : struct => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToEnum()); + public static IEnumerable? ToEnums(params string?[]? vals) where T : struct => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToEnum()); } diff --git a/lib/YANLib/Core/YANEnumerable.cs b/lib/YANLib/Core/YANEnumerable.cs index b0ccdb70..839dc696 100644 --- a/lib/YANLib/Core/YANEnumerable.cs +++ b/lib/YANLib/Core/YANEnumerable.cs @@ -1,5 +1,4 @@ -using System.Diagnostics.CodeAnalysis; -using static System.Math; +using static System.Math; using static System.Nullable; namespace YANLib.Core; @@ -103,18 +102,11 @@ public static partial class YANEnumerable } } - /// - /// Cleans a collection of nullable elements by removing values. - /// For classes and nullable value types, elements are removed. For non-nullable value types, no elements are removed. - /// If the source collection is or empty, returns . - /// - /// The source collection of nullable elements. Can be . - /// An enumerable collection with elements removed, or if the input collection is or empty. public static IEnumerable? Clean(this IEnumerable? srcs) { if (srcs.IsEmptyOrNull()) { - return default; + return srcs; } var t = typeof(T); @@ -122,18 +114,11 @@ public static partial class YANEnumerable return t.IsClass || GetUnderlyingType(t).IsNotNull() ? srcs.Where(x => x.IsNotNull()) : srcs; } - /// - /// Cleans a collection (ICollection) of nullable elements by removing values. - /// For classes and nullable value types, elements are removed. For non-nullable value types, no elements are removed. - /// If the source collection is or empty, returns . - /// - /// The source ICollection of nullable elements. Can be . - /// An enumerable collection with elements removed, or if the input ICollection is or empty. public static IEnumerable? Clean(this ICollection? srcs) { if (srcs.IsEmptyOrNull()) { - return default; + return srcs; } var t = typeof(T); @@ -141,18 +126,11 @@ public static partial class YANEnumerable return t.IsClass || GetUnderlyingType(t).IsNotNull() ? srcs.Where(x => x.IsNotNull()) : srcs; } - /// - /// Cleans an array of nullable elements by removing values. - /// For classes and nullable value types, elements are removed. For non-nullable value types, no elements are removed. - /// If the source array is or empty, returns . - /// - /// The source array of nullable elements. Can be . - /// An enumerable collection with elements removed, or if the input array is or empty. - public static IEnumerable? Clean(this T?[]? srcs) + public static IEnumerable? Clean(params T?[]? srcs) { if (srcs.IsEmptyOrNull()) { - return default; + return srcs; } var t = typeof(T); @@ -160,27 +138,9 @@ public static partial class YANEnumerable return t.IsClass || GetUnderlyingType(t).IsNotNull() ? srcs.Where(x => x.IsNotNull()) : srcs; } - /// - /// Cleans a collection of strings by removing or white-space strings. - /// If the source collection is or empty, returns . - /// - /// The source collection of strings. Can be . - /// An enumerable collection with or white-space strings removed, or if the input collection is or empty. - public static IEnumerable? Clean(this IEnumerable? srcs) => srcs.IsEmptyOrNull() ? default : srcs.Where(x => x.IsNotWhiteSpaceAndNull()); + public static IEnumerable? Clean(this IEnumerable? srcs) => srcs.IsEmptyOrNull() ? srcs : srcs.Where(x => x.IsNotWhiteSpaceAndNull()); - /// - /// Cleans a collection (ICollection) of strings by removing or white-space strings. - /// If the source collection is or empty, returns . - /// - /// The source ICollection of strings. Can be . - /// An enumerable collection with or white-space strings removed, or if the input ICollection is or empty. - public static IEnumerable? Clean(this ICollection? srcs) => srcs.IsEmptyOrNull() ? default : srcs.Where(x => x.IsNotWhiteSpaceAndNull()); + public static IEnumerable? Clean(this ICollection? srcs) => srcs.IsEmptyOrNull() ? srcs : srcs.Where(x => x.IsNotWhiteSpaceAndNull()); - /// - /// Cleans an array of strings by removing or white-space strings. - /// If the source array is or empty, returns . - /// - /// The source array of strings. Can be . - /// An enumerable collection with or white-space strings removed, or if the input array is or empty. - public static IEnumerable? Clean(this string?[]? srcs) => srcs.IsEmptyOrNull() ? default : srcs.Where(x => x.IsNotWhiteSpaceAndNull()); + public static IEnumerable? Clean(params string?[]? srcs) => srcs.IsEmptyOrNull() ? srcs : srcs.Where(x => x.IsNotWhiteSpaceAndNull()); } diff --git a/lib/YANLib/Core/YANObject.Property.cs b/lib/YANLib/Core/YANObject.Property.cs index d07538ff..7d52a7c9 100644 --- a/lib/YANLib/Core/YANObject.Property.cs +++ b/lib/YANLib/Core/YANObject.Property.cs @@ -29,7 +29,7 @@ public static bool AllPropertiesNotDefault(this T? obj) where T : class public static bool AllPropertiesNotDefaults(this ICollection? objs) where T : class => objs.IsNotEmptyAndNull() && !objs.Any(x => x.AnyPropertiesDefault()); - public static bool AllPropertiesNotDefaults(this T?[]? objs) where T : class => objs.IsNotEmptyAndNull() && !objs.Any(x => x.AnyPropertiesDefault()); + public static bool AllPropertiesNotDefaults(params T?[]? objs) where T : class => objs.IsNotEmptyAndNull() && !objs.Any(x => x.AnyPropertiesDefault()); public static bool AllPropertiesDefault(this T? obj) where T : class { @@ -55,7 +55,7 @@ public static bool AllPropertiesDefault(this T? obj) where T : class public static bool AllPropertiesDefaults(this ICollection? objs) where T : class => objs.IsNotEmptyAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault()); - public static bool AllPropertiesDefaults(this T?[]? objs) where T : class => objs.IsNotEmptyAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault()); + public static bool AllPropertiesDefaults(params T?[]? objs) where T : class => objs.IsNotEmptyAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault()); public static bool AnyPropertiesNotDefault(this T? obj) where T : class { @@ -81,7 +81,7 @@ public static bool AnyPropertiesNotDefault(this T? obj) where T : class public static bool AnyPropertiesNotDefaults(this ICollection? objs) where T : class => objs.IsNotEmptyAndNull() && objs.Any(x => x.AnyPropertiesNotDefault()); - public static bool AnyPropertiesNotDefaults(this T?[]? objs) where T : class => objs.IsNotEmptyAndNull() && objs.Any(x => x.AnyPropertiesNotDefault()); + public static bool AnyPropertiesNotDefaults(params T?[]? objs) where T : class => objs.IsNotEmptyAndNull() && objs.Any(x => x.AnyPropertiesNotDefault()); public static bool AnyPropertiesDefault(this T? obj) where T : class { @@ -107,11 +107,11 @@ public static bool AnyPropertiesDefault(this T? obj) where T : class public static bool AnyPropertiesDefaults(this ICollection? objs) where T : class => objs.IsNotEmptyAndNull() && objs.Any(x => x.AnyPropertiesDefault()); - public static bool AnyPropertiesDefaults(this T?[]? objs) where T : class => objs.IsNotEmptyAndNull() && objs.Any(x => x.AnyPropertiesDefault()); + public static bool AnyPropertiesDefaults(params T?[]? objs) where T : class => objs.IsNotEmptyAndNull() && objs.Any(x => x.AnyPropertiesDefault()); public static bool AllPropertiesNotDefault(this T? obj, params string?[]? names) where T : class { - if (obj.IsNull() || names.AllWhiteSpaceOrNull()) + if (obj.IsNull() || names.IsEmptyOrNull() || names.AllWhiteSpaceOrNull()) { return default; } @@ -130,17 +130,17 @@ public static bool AllPropertiesNotDefault(this T? obj, params string?[]? nam } public static bool AllPropertiesNotDefaults(this IEnumerable? objs, params string?[]? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AllPropertiesNotDefaults(this ICollection? objs, params string?[]? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AllPropertiesNotDefaults(this T?[]? objs, params string?[]? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AllPropertiesDefault(this T? obj, params string?[]? names) where T : class { - if (obj.IsNull() || names.AllWhiteSpaceOrNull()) + if (obj.IsNull() || names.IsEmptyOrNull() || names.AllWhiteSpaceOrNull()) { return default; } @@ -159,17 +159,17 @@ public static bool AllPropertiesDefault(this T? obj, params string?[]? names) } public static bool AllPropertiesDefaults(this IEnumerable? objs, params string?[]? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AllPropertiesDefaults(this ICollection? objs, params string?[]? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AllPropertiesDefaults(this T?[]? objs, params string?[]? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AnyPropertiesNotDefault(this T? obj, params string?[]? names) where T : class { - if (obj.IsNull() || names.AllWhiteSpaceOrNull()) + if (obj.IsNull() || names.IsEmptyOrNull() || names.AllWhiteSpaceOrNull()) { return false; } @@ -188,17 +188,17 @@ public static bool AnyPropertiesNotDefault(this T? obj, params string?[]? nam } public static bool AnyPropertiesNotDefaults(this IEnumerable? objs, params string?[]? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AnyPropertiesNotDefaults(this ICollection? objs, params string?[]? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AnyPropertiesNotDefaults(this T?[]? objs, params string?[]? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AnyPropertiesDefault(this T? obj, params string?[]? names) where T : class { - if (obj.IsNull() || names.AllWhiteSpaceOrNull()) + if (obj.IsNull() || names.IsEmptyOrNull() || names.AllWhiteSpaceOrNull()) { return false; } @@ -217,17 +217,17 @@ public static bool AnyPropertiesDefault(this T? obj, params string?[]? names) } public static bool AnyPropertiesDefaults(this IEnumerable? objs, params string?[]? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AnyPropertiesDefaults(this ICollection? objs, params string?[]? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AnyPropertiesDefaults(this T?[]? objs, params string?[]? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AllPropertiesNotDefault(this T? obj, IEnumerable? names) where T : class { - if (obj.IsNull() || names.AllWhiteSpaceOrNull()) + if (obj.IsNull() || names.IsEmptyOrNull() || names.AllWhiteSpaceOrNull()) { return false; } @@ -246,17 +246,17 @@ public static bool AllPropertiesNotDefault(this T? obj, IEnumerable? } public static bool AllPropertiesNotDefaults(this IEnumerable? objs, IEnumerable? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AllPropertiesNotDefaults(this ICollection? objs, IEnumerable? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AllPropertiesNotDefaults(this T?[]? objs, IEnumerable? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AllPropertiesDefault(this T? obj, IEnumerable? names) where T : class { - if (obj.IsNull() || names.AllWhiteSpaceOrNull()) + if (obj.IsNull() || names.IsEmptyOrNull() || names.AllWhiteSpaceOrNull()) { return false; } @@ -275,17 +275,17 @@ public static bool AllPropertiesDefault(this T? obj, IEnumerable? na } public static bool AllPropertiesDefaults(this IEnumerable? objs, IEnumerable? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AllPropertiesDefaults(this ICollection? objs, IEnumerable? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AllPropertiesDefaults(this T?[]? objs, IEnumerable? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AnyPropertiesNotDefault(this T? obj, IEnumerable? names) where T : class { - if (obj.IsNull() || names.AllWhiteSpaceOrNull()) + if (obj.IsNull() || names.IsEmptyOrNull() || names.AllWhiteSpaceOrNull()) { return false; } @@ -304,17 +304,17 @@ public static bool AnyPropertiesNotDefault(this T? obj, IEnumerable? } public static bool AnyPropertiesNotDefaults(this IEnumerable? objs, IEnumerable? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AnyPropertiesNotDefaults(this ICollection? objs, IEnumerable? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AnyPropertiesNotDefaults(this T?[]? objs, IEnumerable? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AnyPropertiesDefault(this T? obj, IEnumerable? names) where T : class { - if (obj.IsNull() || names.AllWhiteSpaceOrNull()) + if (obj.IsNull() || names.IsEmptyOrNull() || names.AllWhiteSpaceOrNull()) { return false; } @@ -333,18 +333,17 @@ public static bool AnyPropertiesDefault(this T? obj, IEnumerable? na } public static bool AnyPropertiesDefaults(this IEnumerable? objs, IEnumerable? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AnyPropertiesDefaults(this ICollection? objs, IEnumerable? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AnyPropertiesDefaults(this T?[]? objs, IEnumerable? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); - // public static bool AllPropertiesNotDefault(this T? obj, ICollection? names) where T : class { - if (obj.IsNull() || names.AllWhiteSpaceOrNull()) + if (obj.IsNull() || names.IsEmptyOrNull() || names.AllWhiteSpaceOrNull()) { return false; } @@ -363,17 +362,17 @@ public static bool AllPropertiesNotDefault(this T? obj, ICollection? } public static bool AllPropertiesNotDefaults(this IEnumerable? objs, ICollection? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AllPropertiesNotDefaults(this ICollection? objs, ICollection? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AllPropertiesNotDefaults(this T?[]? objs, ICollection? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AllPropertiesDefault(this T? obj, ICollection? names) where T : class { - if (obj.IsNull() || names.AllWhiteSpaceOrNull()) + if (obj.IsNull() || names.IsEmptyOrNull() || names.AllWhiteSpaceOrNull()) { return false; } @@ -392,17 +391,17 @@ public static bool AllPropertiesDefault(this T? obj, ICollection? na } public static bool AllPropertiesDefaults(this IEnumerable? objs, ICollection? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AllPropertiesDefaults(this ICollection? objs, ICollection? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AllPropertiesDefaults(this T?[]? objs, ICollection? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && !objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AnyPropertiesNotDefault(this T? obj, ICollection? names) where T : class { - if (obj.IsNull() || names.AllWhiteSpaceOrNull()) + if (obj.IsNull() || names.IsEmptyOrNull() || names.AllWhiteSpaceOrNull()) { return false; } @@ -421,17 +420,17 @@ public static bool AnyPropertiesNotDefault(this T? obj, ICollection? } public static bool AnyPropertiesNotDefaults(this IEnumerable? objs, ICollection? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AnyPropertiesNotDefaults(this ICollection? objs, ICollection? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AnyPropertiesNotDefaults(this T?[]? objs, ICollection? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesNotDefault(names)); public static bool AnyPropertiesDefault(this T? obj, ICollection? names) where T : class { - if (obj.IsNull() || names.AllWhiteSpaceOrNull()) + if (obj.IsNull() || names.IsEmptyOrNull() || names.AllWhiteSpaceOrNull()) { return false; } @@ -450,11 +449,11 @@ public static bool AnyPropertiesDefault(this T? obj, ICollection? na } public static bool AnyPropertiesDefaults(this IEnumerable? objs, ICollection? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AnyPropertiesDefaults(this ICollection? objs, ICollection? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); public static bool AnyPropertiesDefaults(this T?[]? objs, ICollection? names) where T : class - => objs.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); + => objs.IsNotEmptyAndNull() && names.IsNotEmptyAndNull() && names.AllNotWhiteSpaceAndNull() && objs.Any(x => x.AnyPropertiesDefault(names)); } diff --git a/lib/YANLib/Core/YANObject.cs b/lib/YANLib/Core/YANObject.cs index 2fd3fd2d..fd56b40c 100644 --- a/lib/YANLib/Core/YANObject.cs +++ b/lib/YANLib/Core/YANObject.cs @@ -29,7 +29,7 @@ public static partial class YANObject /// /// The array to check. Can be . /// if the array is or empty; otherwise, . - public static bool IsEmptyOrNull([NotNullWhen(false)] this T?[]? srcs) => srcs.IsNull() || srcs.Length is 0; + public static bool IsEmptyOrNull([NotNullWhen(false)] params T?[]? srcs) => srcs.IsNull() || srcs.Length is 0; /// /// Determines whether the specified IEnumerable collection is not and contains at least one element. @@ -50,13 +50,13 @@ public static partial class YANObject /// /// The array to check. Can be . /// if the array is not and not empty; otherwise, . - public static bool IsNotEmptyAndNull([NotNullWhen(true)] this T?[]? srcs) => srcs.IsNotNull() && srcs.Length is not 0; + public static bool IsNotEmptyAndNull([NotNullWhen(true)] params T?[]? srcs) => srcs.IsNotNull() && srcs.Length is not 0; public static bool AllNull(this IEnumerable? srcs) where T : class => srcs.IsNotEmptyAndNull() && !srcs.Any(x => x.IsNotNull()); public static bool AllNull(this ICollection? srcs) where T : class => srcs.IsNotEmptyAndNull() && !srcs.Any(x => x.IsNotNull()); - public static bool AllNull(this T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && !srcs.Any(x => x.IsNotNull()); + public static bool AllNull(params T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && !srcs.Any(x => x.IsNotNull()); /// /// Determines whether all elements in the specified IEnumerable collection of class type are either or have all properties set to default values. @@ -80,13 +80,13 @@ public static partial class YANObject /// /// The array of class type elements to check. Can be . /// if all elements are or have default property values; otherwise, . - public static bool AllEmptyOrNull(this T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && !srcs.Any(x => x.IsNotNull() || x.AnyPropertiesNotDefault()); + public static bool AllEmptyOrNull(params T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && !srcs.Any(x => x.IsNotNull() || x.AnyPropertiesNotDefault()); public static bool AnyNull(this IEnumerable? srcs) where T : class => srcs.IsNotEmptyAndNull() && srcs.Any(x => x.IsNull()); public static bool AnyNull(this ICollection? srcs) where T : class => srcs.IsNotEmptyAndNull() && srcs.Any(x => x.IsNull()); - public static bool AnyNull(this T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && srcs.Any(x => x.IsNull()); + public static bool AnyNull(params T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && srcs.Any(x => x.IsNull()); /// /// Determines whether any element in the specified IEnumerable collection of class type is either or has all properties set to default values. @@ -110,13 +110,13 @@ public static partial class YANObject /// /// The array of class type elements to check. Can be . /// if any element is or has all properties set to default values; otherwise, . - public static bool AnyEmptyOrNull(this T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && srcs.Any(x => x.IsNull() || x.AllPropertiesDefault()); + public static bool AnyEmptyOrNull(params T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && srcs.Any(x => x.IsNull() || x.AllPropertiesDefault()); public static bool AllNotNull(this IEnumerable? srcs) where T : class => srcs.IsNotEmptyAndNull() && !srcs.Any(x => x.IsNull()); public static bool AllNotNull(this ICollection? srcs) where T : class => srcs.IsNotEmptyAndNull() && !srcs.Any(x => x.IsNull()); - public static bool AllNotNull(this T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && !srcs.Any(x => x.IsNull()); + public static bool AllNotNull(params T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && !srcs.Any(x => x.IsNull()); /// /// Determines whether all elements in the specified IEnumerable collection of class type are not and do not have all properties set to default values. @@ -140,7 +140,7 @@ public static partial class YANObject /// /// The array of class type elements to check. Can be . /// if no element is or has all properties set to default values; otherwise, . - public static bool AllNotEmptyAndNull(this T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && !srcs.Any(x => x.IsNull() || x.AllPropertiesDefault()); + public static bool AllNotEmptyAndNull(params T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && !srcs.Any(x => x.IsNull() || x.AllPropertiesDefault()); public static bool AnyNotNull(this IEnumerable? srcs) where T : class => srcs.IsNotEmptyAndNull() && srcs.Any(x => x.IsNotNull()); @@ -166,7 +166,7 @@ public static partial class YANObject /// /// The array of class type elements to check. Can be . /// if any element is not or does not have all properties set to default values; otherwise, . - public static bool AnyNotEmptyAndNull(this T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && srcs.Any(x => x.IsNotNull() || x.AnyPropertiesNotDefault()); + public static bool AnyNotEmptyAndNull(params T?[]? srcs) where T : class => srcs.IsNotEmptyAndNull() && srcs.Any(x => x.IsNotNull() || x.AnyPropertiesNotDefault()); public static List AsList(this T? obj) => new() { obj }; @@ -174,18 +174,11 @@ public static partial class YANObject public static T?[] AsArray(this T? obj) => new T?[1] { obj }; - /// - /// Creates a shallow copy of the provided object if it is not . - /// The copy is made by copying the public instance properties from the source object to a new object of the same type. - /// - /// The type of object to be copied. Must have a parameterless constructor. - /// The source object to be copied. Can be . - /// A shallow copy of the source object, or if the source object is . public static T? Copy(this T? src) where T : new() { if (src.IsNull()) { - return default; + return src; } var rslt = new T(); @@ -208,7 +201,7 @@ public static partial class YANObject { if (obj.IsNull()) { - return default; + return obj; } var props = typeof(T).GetProperties(Public | Instance).Where(x => x.CanRead && x.CanWrite); @@ -271,14 +264,14 @@ public static partial class YANObject } public static IEnumerable? ChangeTimeZoneAllProperties(this IEnumerable? objs, object? tzSrc = null, object? tzDst = null) where T : class => objs.IsEmptyOrNull() - ? default + ? objs : objs.Select(x => x.ChangeTimeZoneAllProperty(tzSrc, tzDst)); public static IEnumerable? ChangeTimeZoneAllProperties(this ICollection? objs, object? tzSrc = null, object? tzDst = null) where T : class => objs.IsEmptyOrNull() - ? default + ? objs : objs.Select(x => x.ChangeTimeZoneAllProperty(tzSrc, tzDst)); public static IEnumerable? ChangeTimeZoneAllProperties(this T?[]? objs, object? tzSrc = null, object? tzDst = null) where T : class => objs.IsEmptyOrNull() - ? default + ? objs : objs.Select(x => x.ChangeTimeZoneAllProperty(tzSrc, tzDst)); } diff --git a/lib/YANLib/Core/YANText.Char.Nullable.cs b/lib/YANLib/Core/YANText.Char.Nullable.cs deleted file mode 100644 index a4c28e27..00000000 --- a/lib/YANLib/Core/YANText.Char.Nullable.cs +++ /dev/null @@ -1,323 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace YANLib.Core; - -public static partial class YANText -{ - public static bool IsEmptyOrNull([NotNullWhen(false)] this char? c) => c.IsNull() || c.Value.IsEmpty(); - - public static bool AllEmptyOrNull(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotEmptyAndNull()); - - public static bool AllEmptyOrNull(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotEmptyAndNull()); - - public static bool AllEmptyOrNull(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotEmptyAndNull()); - - public static bool AnyEmptyOrNull(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsEmptyOrNull()); - - public static bool AnyEmptyOrNull(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsEmptyOrNull()); - - public static bool AnyEmptyOrNull(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsEmptyOrNull()); - - public static bool IsWhiteSpaceOrNull([NotNullWhen(false)] this char? c) => c.IsNull() || c.Value.IsEmpty() || c.Value.IsWhiteSpace(); - - public static bool AllWhiteSpaceOrNull(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotWhiteSpaceAndNull()); - - public static bool AllWhiteSpaceOrNull(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotWhiteSpaceAndNull()); - - public static bool AllWhiteSpaceOrNull(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotWhiteSpaceAndNull()); - - public static bool AnyWhiteSpaceOrNull(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsWhiteSpaceOrNull()); - - public static bool AnyWhiteSpaceOrNull(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsWhiteSpaceOrNull()); - - public static bool AnyWhiteSpaceOrNull(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsWhiteSpaceOrNull()); - - public static bool IsAlphabetic([NotNullWhen(true)] this char? c) => c.HasValue && c.Value.IsAlphabetic(); - - public static bool AllAlphabetic(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotAlphabetic()); - - public static bool AllAlphabetic(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotAlphabetic()); - - public static bool AllAlphabetic(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotAlphabetic()); - - public static bool AnyAlphabetic(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsAlphabetic()); - - public static bool AnyAlphabetic(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsAlphabetic()); - - public static bool AnyAlphabetic(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsAlphabetic()); - - public static bool IsPunctuation([NotNullWhen(true)] this char? c) => c.HasValue && c.Value.IsPunctuation(); - - public static bool AllPunctuation(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotPunctuation()); - - public static bool AllPunctuation(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotPunctuation()); - - public static bool AllPunctuation(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotPunctuation()); - - public static bool AnyPunctuation(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsPunctuation()); - - public static bool AnyPunctuation(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsPunctuation()); - - public static bool AnyPunctuation(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsPunctuation()); - - public static bool IsNumber([NotNullWhen(true)] this char? c) => c.HasValue && c.Value.IsNumber(); - - public static bool AllNumber(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotNumber()); - - public static bool AllNumber(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotNumber()); - - public static bool AllNumber(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotNumber()); - - public static bool AnyNumber(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNumber()); - - public static bool AnyNumber(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNumber()); - - public static bool AnyNumber(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNumber()); - - public static bool EqualsIgnoreCase(this char? c1, char? c2) => c1.LowerInvariant() == c2.LowerInvariant(); - - public static bool AllEqualsIgnoreCase(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.NotEqualsIgnoreCase(cs.First())); - - public static bool AllEqualsIgnoreCase(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.NotEqualsIgnoreCase(cs.First())); - - public static bool AllEqualsIgnoreCase(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.NotEqualsIgnoreCase(cs.First())); - - public static bool AnyEqualsIgnoreCase(this IEnumerable? cs) => !cs.AllNotEqualsIgnoreCase(); - - public static bool AnyEqualsIgnoreCase(this ICollection? cs) => !cs.AllNotEqualsIgnoreCase(); - - public static bool AnyEqualsIgnoreCase(this char?[]? cs) => !cs.AllNotEqualsIgnoreCase(); - - public static bool IsNotEmptyAndNull([NotNullWhen(true)] this char? c) => c.HasValue && c.Value.IsNotEmpty(); - - public static bool AllNotEmptyAndNull(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsEmptyOrNull()); - - public static bool AllNotEmptyAndNull(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsEmptyOrNull()); - - public static bool AllNotEmptyAndNull(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsEmptyOrNull()); - - public static bool AnyNotEmptyAndNull(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotEmptyAndNull()); - - public static bool AnyNotEmptyAndNull(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotEmptyAndNull()); - - public static bool AnyNotEmptyAndNull(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotEmptyAndNull()); - - public static bool IsNotWhiteSpaceAndNull([NotNullWhen(true)] this char? c) => c.HasValue && c.Value.IsNotEmpty() && c.Value.IsNotWhiteSpace(); - - public static bool AllNotWhiteSpaceAndNull(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsWhiteSpaceOrNull()); - - public static bool AllNotWhiteSpaceAndNull(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsWhiteSpaceOrNull()); - - public static bool AllNotWhiteSpaceAndNull(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsWhiteSpaceOrNull()); - - public static bool AnyNotWhiteSpaceAndNull(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotWhiteSpaceAndNull()); - - public static bool AnyNotWhiteSpaceAndNull(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotWhiteSpaceAndNull()); - - public static bool AnyNotWhiteSpaceAndNull(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotWhiteSpaceAndNull()); - - public static bool IsNotAlphabetic(this char? c) => c.HasValue && c.Value.IsNotAlphabetic(); - - public static bool AllNotAlphabetic(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsAlphabetic()); - - public static bool AllNotAlphabetic(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsAlphabetic()); - - public static bool AllNotAlphabetic(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsAlphabetic()); - - public static bool AnyNotAlphabetic(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotAlphabetic()); - - public static bool AnyNotAlphabetic(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotAlphabetic()); - - public static bool AnyNotAlphabetic(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotAlphabetic()); - - public static bool IsNotPunctuation(this char? c) => c.HasValue && c.Value.IsNotPunctuation(); - - public static bool AllNotPunctuation(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsPunctuation()); - - public static bool AllNotPunctuation(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsPunctuation()); - - public static bool AllNotPunctuation(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsPunctuation()); - - public static bool AnyNotPunctuation(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotPunctuation()); - - public static bool AnyNotPunctuation(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotPunctuation()); - - public static bool AnyNotPunctuation(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotPunctuation()); - - public static bool IsNotNumber(this char? c) => c.HasValue && c.Value.IsNotNumber(); - - public static bool AllNotNumber(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNumber()); - - public static bool AllNotNumber(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNumber()); - - public static bool AllNotNumber(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNumber()); - - public static bool AnyNotNumber(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotNumber()); - - public static bool AnyNotNumber(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotNumber()); - - public static bool AnyNotNumber(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotNumber()); - - public static bool NotEqualsIgnoreCase(this char? c1, char? c2) => c1.LowerInvariant() != c2.LowerInvariant(); - - public static bool AllNotEqualsIgnoreCase(this IEnumerable? cs) - { - if (cs.IsEmptyOrNull() || cs.Count() < 2) - { - return default; - } - - var hashSet = new HashSet(cs.Count()); - - foreach (var c in cs) - { - if (!hashSet.Add(c.LowerInvariant())) - { - return false; - } - } - - return true; - } - - public static bool AllNotEqualsIgnoreCase(this ICollection? cs) - { - if (cs.IsEmptyOrNull() || cs.Count < 2) - { - return default; - } - - var hashSet = new HashSet(cs.Count); - - foreach (var c in cs) - { - if (!hashSet.Add(c.LowerInvariant())) - { - return false; - } - } - - return true; - } - - public static bool AllNotEqualsIgnoreCase(this char?[]? cs) - { - if (cs.IsEmptyOrNull() || cs.Length < 2) - { - return default; - } - - var hashSet = new HashSet(cs.Length); - - foreach (var c in cs) - { - if (!hashSet.Add(c.LowerInvariant())) - { - return false; - } - } - - return true; - } - - public static bool AnyNotEqualsIgnoreCase(this IEnumerable? cs) => !cs.AllEqualsIgnoreCase(); - - public static bool AnyNotEqualsIgnoreCase(this ICollection? cs) => !cs.AllEqualsIgnoreCase(); - - public static bool AnyNotEqualsIgnoreCase(this char?[]? cs) => !cs.AllEqualsIgnoreCase(); - - public static char? GetValue(this char? c, char dfltVal = default) => c.IsEmptyOrNull() ? dfltVal : c.Value; - - public static char? Lower(this char? c) => c.IsWhiteSpaceOrNull() ? default : char.ToLower(c.Value); - - public static IEnumerable? Lowers(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Lower()); - - public static IEnumerable? Lowers(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Lower()); - - public static IEnumerable? Lowers(this char?[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Lower()); - - public static char? LowerInvariant(this char? c) => c.IsWhiteSpaceOrNull() ? default : char.ToLowerInvariant(c.Value); - - public static IEnumerable? LowerInvariants(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.LowerInvariant()); - - public static IEnumerable? LowerInvariants(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.LowerInvariant()); - - public static IEnumerable? LowerInvariants(this char?[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.LowerInvariant()); - - public static char? Upper(this char? c) => c.IsWhiteSpaceOrNull() ? default : char.ToUpper(c.Value); - - public static IEnumerable? Upper(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Upper()); - - public static IEnumerable? Upper(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Upper()); - - public static IEnumerable? Upper(this char?[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Upper()); - - public static char? UpperInvariant(this char? c) => c.IsWhiteSpaceOrNull() ? default : char.ToUpperInvariant(c.Value); - - public static IEnumerable? UpperInvariants(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.UpperInvariant()); - - public static IEnumerable? UpperInvariants(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.UpperInvariant()); - - public static IEnumerable? UpperInvariants(this char?[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.UpperInvariant()); - - public static bool IsLower(this char? c) => c.IsNotWhiteSpaceAndEmpty() && char.IsLower(c); - - public static bool AllLowers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotLower()); - - public static bool AllLowers(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotLower()); - - public static bool AllLowers(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotLower()); - - public static bool AnyLowers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsLower()); - - public static bool AnyLowers(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsLower()); - - public static bool AnyLowers(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsLower()); - - public static bool IsNotLower(this char? c) => c.IsNotWhiteSpaceAndEmpty() && !char.IsLower(c); - - public static bool AllNotLowers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsLower()); - - public static bool AllNotLowers(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsLower()); - - public static bool AllNotLowers(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsLower()); - - public static bool AnyNotLowers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotLower()); - - public static bool AnyNotLowers(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotLower()); - - public static bool AnyNotLowers(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotLower()); - - public static bool IsUpper(this char? c) => c.IsNotWhiteSpaceAndEmpty() && char.IsUpper(c); - - public static bool AllUppers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotUpper()); - - public static bool AllUppers(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotUpper()); - - public static bool AllUppers(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotUpper()); - - public static bool AnyUppers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsUpper()); - - public static bool AnyUppers(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsUpper()); - - public static bool AnyUppers(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsUpper()); - - public static bool IsNotUpper(this char? c) => c.IsNotWhiteSpaceAndEmpty() && !char.IsUpper(c); - - public static bool AllNotUppers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsUpper()); - - public static bool AllNotUppers(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsUpper()); - - public static bool AllNotUppers(this char?[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsUpper()); - - public static bool AnyNotUppers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotUpper()); - - public static bool AnyNotUppers(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotUpper()); - - public static bool AnyNotUppers(this char?[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotUpper()); -} diff --git a/lib/YANLib/Core/YANText.Char.cs b/lib/YANLib/Core/YANText.Char.cs index 30946ec8..842d0a35 100644 --- a/lib/YANLib/Core/YANText.Char.cs +++ b/lib/YANLib/Core/YANText.Char.cs @@ -7,195 +7,190 @@ public static partial class YANText { public static bool IsEmpty(this char c) => c is char.MinValue; - public static bool AllEmpty(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotEmpty()); + public static bool AllEmpty(this IEnumerable cs) => !cs.Any(x => x.IsNotEmpty()); - public static bool AllEmpty(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotEmpty()); + public static bool AllEmpty(this ICollection cs) => !cs.Any(x => x.IsNotEmpty()); - public static bool AllEmpty(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotEmpty()); + public static bool AllEmpty(params char[] cs) => !cs.Any(x => x.IsNotEmpty()); - public static bool AnyEmpty(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsEmpty()); + public static bool AnyEmpty(this IEnumerable cs) => cs.Any(x => x.IsEmpty()); - public static bool AnyEmpty(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsEmpty()); + public static bool AnyEmpty(this ICollection cs) => cs.Any(x => x.IsEmpty()); - public static bool AnyEmpty(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsEmpty()); + public static bool AnyEmpty(params char[] cs) => cs.Any(x => x.IsEmpty()); public static bool IsWhiteSpace(this char c) => char.IsWhiteSpace(c); - public static bool AllWhiteSpace(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotWhiteSpace()); + public static bool AllWhiteSpace(this IEnumerable cs) => !cs.Any(x => x.IsNotWhiteSpace()); - public static bool AllWhiteSpace(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotWhiteSpace()); + public static bool AllWhiteSpace(this ICollection cs) => !cs.Any(x => x.IsNotWhiteSpace()); - public static bool AllWhiteSpace(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotWhiteSpace()); + public static bool AllWhiteSpace(params char[] cs) => !cs.Any(x => x.IsNotWhiteSpace()); - public static bool AnyWhiteSpace(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsWhiteSpace()); + public static bool AnyWhiteSpace(this IEnumerable cs) => cs.Any(x => x.IsWhiteSpace()); - public static bool AnyWhiteSpace(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsWhiteSpace()); + public static bool AnyWhiteSpace(this ICollection cs) => cs.Any(x => x.IsWhiteSpace()); - public static bool AnyWhiteSpace(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsWhiteSpace()); + public static bool AnyWhiteSpace(params char[] cs) => cs.Any(x => x.IsWhiteSpace()); public static bool IsWhiteSpaceOrEmpty(this char c) => c.IsEmpty() || c.IsWhiteSpace(); - public static bool AllWhiteSpaceOrEmpty(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotWhiteSpaceAndEmpty()); + public static bool AllWhiteSpaceOrEmpty(this IEnumerable cs) => !cs.Any(x => x.IsNotWhiteSpaceAndEmpty()); - public static bool AllWhiteSpaceOrEmpty(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotWhiteSpaceAndEmpty()); + public static bool AllWhiteSpaceOrEmpty(this ICollection cs) => !cs.Any(x => x.IsNotWhiteSpaceAndEmpty()); - public static bool AllWhiteSpaceOrEmpty(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotWhiteSpaceAndEmpty()); + public static bool AllWhiteSpaceOrEmpty(params char[] cs) => !cs.Any(x => x.IsNotWhiteSpaceAndEmpty()); - public static bool AnyWhiteSpaceOrEmpty(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsWhiteSpaceOrEmpty()); + public static bool AnyWhiteSpaceOrEmpty(this IEnumerable cs) => cs.Any(x => x.IsWhiteSpaceOrEmpty()); - public static bool AnyWhiteSpaceOrEmpty(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsWhiteSpaceOrEmpty()); + public static bool AnyWhiteSpaceOrEmpty(this ICollection cs) => cs.Any(x => x.IsWhiteSpaceOrEmpty()); - public static bool AnyWhiteSpaceOrEmpty(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsWhiteSpaceOrEmpty()); + public static bool AnyWhiteSpaceOrEmpty(params char[] cs) => cs.Any(x => x.IsWhiteSpaceOrEmpty()); public static bool IsAlphabetic(this char c) => char.IsLetter(c); - public static bool AllAlphabetic(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotAlphabetic()); + public static bool AllAlphabetic(this IEnumerable cs) => !cs.Any(x => x.IsNotAlphabetic()); - public static bool AllAlphabetic(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotAlphabetic()); + public static bool AllAlphabetic(this ICollection cs) => !cs.Any(x => x.IsNotAlphabetic()); - public static bool AllAlphabetic(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotAlphabetic()); + public static bool AllAlphabetic(params char[] cs) => !cs.Any(x => x.IsNotAlphabetic()); - public static bool AnyAlphabetic(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsAlphabetic()); + public static bool AnyAlphabetic(this IEnumerable cs) => cs.Any(x => x.IsAlphabetic()); - public static bool AnyAlphabetic(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsAlphabetic()); + public static bool AnyAlphabetic(this ICollection cs) => cs.Any(x => x.IsAlphabetic()); - public static bool AnyAlphabetic(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsAlphabetic()); + public static bool AnyAlphabetic(params char[] cs) => cs.Any(x => x.IsAlphabetic()); public static bool IsPunctuation(this char c) => char.IsPunctuation(c); - public static bool AllPunctuation(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotPunctuation()); + public static bool AllPunctuation(this IEnumerable cs) => !cs.Any(x => x.IsNotPunctuation()); - public static bool AllPunctuation(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotPunctuation()); + public static bool AllPunctuation(this ICollection cs) => !cs.Any(x => x.IsNotPunctuation()); - public static bool AllPunctuation(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotPunctuation()); + public static bool AllPunctuation(params char[] cs) => !cs.Any(x => x.IsNotPunctuation()); - public static bool AnyPunctuation(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsPunctuation()); + public static bool AnyPunctuation(this IEnumerable cs) => cs.Any(x => x.IsPunctuation()); - public static bool AnyPunctuation(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsPunctuation()); + public static bool AnyPunctuation(this ICollection cs) => cs.Any(x => x.IsPunctuation()); - public static bool AnyPunctuation(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsPunctuation()); + public static bool AnyPunctuation(params char[] cs) => cs.Any(x => x.IsPunctuation()); public static bool IsNumber(this char c) => char.IsDigit(c); - public static bool AllNumber(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotNumber()); + public static bool AllNumber(this IEnumerable cs) => !cs.Any(x => x.IsNotNumber()); - public static bool AllNumber(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotNumber()); + public static bool AllNumber(this ICollection cs) => !cs.Any(x => x.IsNotNumber()); - public static bool AllNumber(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotNumber()); + public static bool AllNumber(params char[] cs) => !cs.Any(x => x.IsNotNumber()); - public static bool AnyNumber(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNumber()); + public static bool AnyNumber(this IEnumerable cs) => cs.Any(x => x.IsNumber()); - public static bool AnyNumber(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNumber()); + public static bool AnyNumber(this ICollection cs) => cs.Any(x => x.IsNumber()); - public static bool AnyNumber(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNumber()); + public static bool AnyNumber(params char[] cs) => cs.Any(x => x.IsNumber()); public static bool EqualsIgnoreCase(this char c1, char c2) => c1.LowerInvariant() == c2.LowerInvariant(); - public static bool AllEqualsIgnoreCase(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.NotEqualsIgnoreCase(cs.First())); + public static bool AllEqualsIgnoreCase(this IEnumerable cs) => !cs.Any(x => x.NotEqualsIgnoreCase(cs.First())); - public static bool AllEqualsIgnoreCase(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.NotEqualsIgnoreCase(cs.First())); + public static bool AllEqualsIgnoreCase(this ICollection cs) => !cs.Any(x => x.NotEqualsIgnoreCase(cs.First())); - public static bool AllEqualsIgnoreCase(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.NotEqualsIgnoreCase(cs.First())); + public static bool AllEqualsIgnoreCase(params char[] cs) => !cs.Any(x => x.NotEqualsIgnoreCase(cs.First())); - public static bool AnyEqualsIgnoreCase(this IEnumerable? cs) => !cs.AllNotEqualsIgnoreCase(); + public static bool AnyEqualsIgnoreCase(this IEnumerable cs) => !cs.AllNotEqualsIgnoreCase(); - public static bool AnyEqualsIgnoreCase(this ICollection? cs) => !cs.AllNotEqualsIgnoreCase(); + public static bool AnyEqualsIgnoreCase(this ICollection cs) => !cs.AllNotEqualsIgnoreCase(); - public static bool AnyEqualsIgnoreCase(this char[]? cs) => !cs.AllNotEqualsIgnoreCase(); + public static bool AnyEqualsIgnoreCase(params char[] cs) => !cs.AllNotEqualsIgnoreCase(); public static bool IsNotEmpty(this char c) => c is not char.MinValue; - public static bool AllNotEmpty(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsEmpty()); + public static bool AllNotEmpty(this IEnumerable cs) => !cs.Any(x => x.IsEmpty()); - public static bool AllNotEmpty(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsEmpty()); + public static bool AllNotEmpty(this ICollection cs) => !cs.Any(x => x.IsEmpty()); - public static bool AllNotEmpty(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsEmpty()); + public static bool AllNotEmpty(params char[] cs) => !cs.Any(x => x.IsEmpty()); - public static bool AnyNotEmpty(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotEmpty()); + public static bool AnyNotEmpty(this IEnumerable cs) => cs.Any(x => x.IsNotEmpty()); - public static bool AnyNotEmpty(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotEmpty()); + public static bool AnyNotEmpty(this ICollection cs) => cs.Any(x => x.IsNotEmpty()); - public static bool AnyNotEmpty(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotEmpty()); + public static bool AnyNotEmpty(params char[] cs) => cs.Any(x => x.IsNotEmpty()); public static bool IsNotWhiteSpace(this char c) => !char.IsWhiteSpace(c); - public static bool AllNotWhiteSpace(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsWhiteSpace()); + public static bool AllNotWhiteSpace(this IEnumerable cs) => !cs.Any(x => x.IsWhiteSpace()); - public static bool AllNotWhiteSpace(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsWhiteSpace()); + public static bool AllNotWhiteSpace(this ICollection cs) => !cs.Any(x => x.IsWhiteSpace()); - public static bool AllNotWhiteSpace(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsWhiteSpace()); + public static bool AllNotWhiteSpace(params char[] cs) => !cs.Any(x => x.IsWhiteSpace()); - public static bool AnyNotWhiteSpace(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotWhiteSpace()); + public static bool AnyNotWhiteSpace(this IEnumerable cs) => cs.Any(x => x.IsNotWhiteSpace()); - public static bool AnyNotWhiteSpace(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotWhiteSpace()); + public static bool AnyNotWhiteSpace(this ICollection cs) => cs.Any(x => x.IsNotWhiteSpace()); - public static bool AnyNotWhiteSpace(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotWhiteSpace()); + public static bool AnyNotWhiteSpace(params char[] cs) => cs.Any(x => x.IsNotWhiteSpace()); public static bool IsNotWhiteSpaceAndEmpty(this char c) => c.IsNotEmpty() && c.IsNotWhiteSpace(); - public static bool AllNotWhiteSpaceAndEmpty(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsWhiteSpaceOrEmpty()); + public static bool AllNotWhiteSpaceAndEmpty(this IEnumerable cs) => !cs.Any(x => x.IsWhiteSpaceOrEmpty()); - public static bool AllNotWhiteSpaceAndEmpty(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsWhiteSpaceOrEmpty()); + public static bool AllNotWhiteSpaceAndEmpty(this ICollection cs) => !cs.Any(x => x.IsWhiteSpaceOrEmpty()); - public static bool AllNotWhiteSpaceAndEmpty(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsWhiteSpaceOrEmpty()); + public static bool AllNotWhiteSpaceAndEmpty(params char[] cs) => !cs.Any(x => x.IsWhiteSpaceOrEmpty()); - public static bool AnyNotWhiteSpaceAndEmpty(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotWhiteSpaceAndEmpty()); + public static bool AnyNotWhiteSpaceAndEmpty(this IEnumerable cs) => cs.Any(x => x.IsNotWhiteSpaceAndEmpty()); - public static bool AnyNotWhiteSpaceAndEmpty(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotWhiteSpaceAndEmpty()); + public static bool AnyNotWhiteSpaceAndEmpty(this ICollection cs) => cs.Any(x => x.IsNotWhiteSpaceAndEmpty()); - public static bool AnyNotWhiteSpaceAndEmpty(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotWhiteSpaceAndEmpty()); + public static bool AnyNotWhiteSpaceAndEmpty(params char[] cs) => cs.Any(x => x.IsNotWhiteSpaceAndEmpty()); public static bool IsNotAlphabetic(this char c) => !char.IsLetter(c); - public static bool AllNotAlphabetic(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsAlphabetic()); + public static bool AllNotAlphabetic(this IEnumerable cs) => !cs.Any(x => x.IsAlphabetic()); - public static bool AllNotAlphabetic(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsAlphabetic()); + public static bool AllNotAlphabetic(this ICollection cs) => !cs.Any(x => x.IsAlphabetic()); - public static bool AllNotAlphabetic(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsAlphabetic()); + public static bool AllNotAlphabetic(params char[] cs) => !cs.Any(x => x.IsAlphabetic()); - public static bool AnyNotAlphabetic(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotAlphabetic()); + public static bool AnyNotAlphabetic(this IEnumerable cs) => cs.Any(x => x.IsNotAlphabetic()); - public static bool AnyNotAlphabetic(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotAlphabetic()); + public static bool AnyNotAlphabetic(this ICollection cs) => cs.Any(x => x.IsNotAlphabetic()); - public static bool AnyNotAlphabetic(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotAlphabetic()); + public static bool AnyNotAlphabetic(params char[] cs) => cs.Any(x => x.IsNotAlphabetic()); public static bool IsNotPunctuation(this char c) => !char.IsPunctuation(c); - public static bool AllNotPunctuation(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsPunctuation()); + public static bool AllNotPunctuation(this IEnumerable cs) => !cs.Any(x => x.IsPunctuation()); - public static bool AllNotPunctuation(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsPunctuation()); + public static bool AllNotPunctuation(this ICollection cs) => !cs.Any(x => x.IsPunctuation()); - public static bool AllNotPunctuation(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsPunctuation()); + public static bool AllNotPunctuation(params char[] cs) => !cs.Any(x => x.IsPunctuation()); - public static bool AnyNotPunctuation(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotPunctuation()); + public static bool AnyNotPunctuation(this IEnumerable cs) => cs.Any(x => x.IsNotPunctuation()); - public static bool AnyNotPunctuation(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotPunctuation()); + public static bool AnyNotPunctuation(this ICollection cs) => cs.Any(x => x.IsNotPunctuation()); - public static bool AnyNotPunctuation(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotPunctuation()); + public static bool AnyNotPunctuation(params char[] cs) => cs.Any(x => x.IsNotPunctuation()); public static bool IsNotNumber(this char c) => !char.IsDigit(c); - public static bool AllNotNumber(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNumber()); + public static bool AllNotNumber(this IEnumerable cs) => !cs.Any(x => x.IsNumber()); - public static bool AllNotNumber(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNumber()); + public static bool AllNotNumber(this ICollection cs) => !cs.Any(x => x.IsNumber()); - public static bool AllNotNumber(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNumber()); + public static bool AllNotNumber(params char[] cs) => !cs.Any(x => x.IsNumber()); - public static bool AnyNotNumber(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotNumber()); + public static bool AnyNotNumber(this IEnumerable cs) => cs.Any(x => x.IsNotNumber()); - public static bool AnyNotNumber(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotNumber()); + public static bool AnyNotNumber(this ICollection cs) => cs.Any(x => x.IsNotNumber()); - public static bool AnyNotNumber(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotNumber()); + public static bool AnyNotNumber(params char[] cs) => cs.Any(x => x.IsNotNumber()); public static bool NotEqualsIgnoreCase(this char c1, char c2) => c1.LowerInvariant() != c2.LowerInvariant(); - public static bool AllNotEqualsIgnoreCase(this IEnumerable? cs) + public static bool AllNotEqualsIgnoreCase(this IEnumerable cs) { - if (cs.IsEmptyOrNull() || cs.Count() < 2) - { - return default; - } - var hashSet = new HashSet(cs.Count()); foreach (var c in cs) @@ -209,13 +204,8 @@ public static bool AllNotEqualsIgnoreCase(this IEnumerable? cs) return true; } - public static bool AllNotEqualsIgnoreCase(this ICollection? cs) + public static bool AllNotEqualsIgnoreCase(this ICollection cs) { - if (cs.IsEmptyOrNull() || cs.Count < 2) - { - return default; - } - var hashSet = new HashSet(cs.Count); foreach (var c in cs) @@ -229,13 +219,8 @@ public static bool AllNotEqualsIgnoreCase(this ICollection? cs) return true; } - public static bool AllNotEqualsIgnoreCase(this char[]? cs) + public static bool AllNotEqualsIgnoreCase(params char[] cs) { - if (cs.IsEmptyOrNull() || cs.Length < 2) - { - return default; - } - var hashSet = new HashSet(cs.Length); foreach (var c in cs) @@ -249,13 +234,11 @@ public static bool AllNotEqualsIgnoreCase(this char[]? cs) return true; } - public static bool AnyNotEqualsIgnoreCase(this IEnumerable? cs) => !cs.AllEqualsIgnoreCase(); - - public static bool AnyNotEqualsIgnoreCase(this ICollection? cs) => !cs.AllEqualsIgnoreCase(); + public static bool AnyNotEqualsIgnoreCase(this IEnumerable cs) => !cs.AllEqualsIgnoreCase(); - public static bool AnyNotEqualsIgnoreCase(this char[]? cs) => !cs.AllEqualsIgnoreCase(); + public static bool AnyNotEqualsIgnoreCase(this ICollection cs) => !cs.AllEqualsIgnoreCase(); - public static char GetValue(this char c, char dfltVal = default) => c.IsEmpty() ? dfltVal : c; + public static bool AnyNotEqualsIgnoreCase(params char[] cs) => !cs.AllEqualsIgnoreCase(); public static char GenerateRandomCharacter() { @@ -268,89 +251,129 @@ public static char GenerateRandomCharacter() public static char Lower(this char c) => c.IsWhiteSpaceOrEmpty() ? c : char.ToLower(c); + public static void Lower(this List? cs) + { + if (cs.IsEmptyOrNull()) + { + return; + } + + cs.ForEach(x => x = x.Lower()); + } + public static IEnumerable? Lowers(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Lower()); public static IEnumerable? Lowers(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Lower()); - public static IEnumerable? Lowers(this char[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Lower()); + public static IEnumerable? Lowers(params char[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Lower()); public static char LowerInvariant(this char c) => c.IsWhiteSpaceOrEmpty() ? c : char.ToLowerInvariant(c); + public static void LowerInvariant(this List? cs) + { + if (cs.IsEmptyOrNull()) + { + return; + } + + cs.ForEach(x => x = x.LowerInvariant()); + } + public static IEnumerable? LowerInvariants(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.LowerInvariant()); public static IEnumerable? LowerInvariants(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.LowerInvariant()); - public static IEnumerable? LowerInvariants(this char[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.LowerInvariant()); + public static IEnumerable? LowerInvariants(params char[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.LowerInvariant()); public static char Upper(this char c) => c.IsWhiteSpaceOrEmpty() ? c : char.ToUpper(c); - public static IEnumerable? Upper(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Upper()); + public static void Upper(this List? cs) + { + if (cs.IsEmptyOrNull()) + { + return; + } + + cs.ForEach(x => x = x.Upper()); + } + + public static IEnumerable? Uppers(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Upper()); - public static IEnumerable? Upper(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Upper()); + public static IEnumerable? Uppers(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Upper()); - public static IEnumerable? Upper(this char[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Upper()); + public static IEnumerable? Uppers(params char[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Upper()); public static char UpperInvariant(this char c) => c.IsWhiteSpaceOrEmpty() ? c : char.ToUpperInvariant(c); + public static void UpperInvariant(this List? cs) + { + if (cs.IsEmptyOrNull()) + { + return; + } + + cs.ForEach(x => x = x.UpperInvariant()); + } + public static IEnumerable? UpperInvariants(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.UpperInvariant()); public static IEnumerable? UpperInvariants(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.UpperInvariant()); - public static IEnumerable? UpperInvariants(this char[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.UpperInvariant()); + public static IEnumerable? UpperInvariants(params char[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.UpperInvariant()); public static bool IsLower(this char c) => c.IsNotWhiteSpaceAndEmpty() && char.IsLower(c); - public static bool AllLowers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotLower()); - - public static bool AllLowers(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotLower()); - - public static bool AllLowers(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotLower()); - - public static bool AnyLowers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsLower()); - - public static bool AnyLowers(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsLower()); - - public static bool AnyLowers(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsLower()); + public static bool AllLowers(this IEnumerable cs) => !cs.Any(x => x.IsNotLower()); + + public static bool AllLowers(this ICollection cs) => !cs.Any(x => x.IsNotLower()); + + public static bool AllLowers(params char[] cs) => !cs.Any(x => x.IsNotLower()); + + public static bool AnyLowers(this IEnumerable cs) => cs.Any(x => x.IsLower()); + + public static bool AnyLowers(this ICollection cs) => cs.Any(x => x.IsLower()); + + public static bool AnyLowers(params char[] cs) => cs.Any(x => x.IsLower()); public static bool IsNotLower(this char c) => c.IsNotWhiteSpaceAndEmpty() && !char.IsLower(c); - public static bool AllNotLowers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsLower()); + public static bool AllNotLowers(this IEnumerable cs) => !cs.Any(x => x.IsLower()); - public static bool AllNotLowers(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsLower()); + public static bool AllNotLowers(this ICollection cs) => !cs.Any(x => x.IsLower()); - public static bool AllNotLowers(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsLower()); + public static bool AllNotLowers(params char[] cs) => !cs.Any(x => x.IsLower()); - public static bool AnyNotLowers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotLower()); + public static bool AnyNotLowers(this IEnumerable cs) => cs.Any(x => x.IsNotLower()); - public static bool AnyNotLowers(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotLower()); + public static bool AnyNotLowers(this ICollection cs) => cs.Any(x => x.IsNotLower()); - public static bool AnyNotLowers(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotLower()); + public static bool AnyNotLowers(params char[] cs) => cs.Any(x => x.IsNotLower()); public static bool IsUpper(this char c) => c.IsNotWhiteSpaceAndEmpty() && char.IsUpper(c); - public static bool AllUppers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotUpper()); + public static bool AllUppers(this IEnumerable cs) => !cs.Any(x => x.IsNotUpper()); - public static bool AllUppers(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotUpper()); + public static bool AllUppers(this ICollection cs) => !cs.Any(x => x.IsNotUpper()); - public static bool AllUppers(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsNotUpper()); + public static bool AllUppers(params char[] cs) => !cs.Any(x => x.IsNotUpper()); - public static bool AnyUppers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsUpper()); + public static bool AnyUppers(this IEnumerable cs) => cs.Any(x => x.IsUpper()); - public static bool AnyUppers(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsUpper()); + public static bool AnyUppers(this ICollection cs) => cs.Any(x => x.IsUpper()); - public static bool AnyUppers(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsUpper()); + public static bool AnyUppers(params char[] cs) => cs.Any(x => x.IsUpper()); public static bool IsNotUpper(this char c) => c.IsNotWhiteSpaceAndEmpty() && !char.IsUpper(c); - public static bool AllNotUppers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsUpper()); + public static bool AllNotUppers(this IEnumerable cs) => !cs.Any(x => x.IsUpper()); - public static bool AllNotUppers(this ICollection? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsUpper()); + public static bool AllNotUppers(this ICollection cs) => !cs.Any(x => x.IsUpper()); - public static bool AllNotUppers(this char[]? cs) => cs.IsNotEmptyAndNull() && !cs.Any(x => x.IsUpper()); + public static bool AllNotUppers(params char[] cs) => !cs.Any(x => x.IsUpper()); - public static bool AnyNotUppers(this IEnumerable? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotUpper()); + public static bool AnyNotUppers(this IEnumerable cs) => cs.Any(x => x.IsNotUpper()); - public static bool AnyNotUppers(this ICollection? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotUpper()); + public static bool AnyNotUppers(this ICollection cs) => cs.Any(x => x.IsNotUpper()); - public static bool AnyNotUppers(this char[]? cs) => cs.IsNotEmptyAndNull() && cs.Any(x => x.IsNotUpper()); + public static bool AnyNotUppers(params char[] cs) => cs.Any(x => x.IsNotUpper()); } diff --git a/lib/YANLib/Core/YANText.String.cs b/lib/YANLib/Core/YANText.String.cs index 48875161..ed0208a3 100644 --- a/lib/YANLib/Core/YANText.String.cs +++ b/lib/YANLib/Core/YANText.String.cs @@ -6,91 +6,109 @@ namespace YANLib.Core; public static partial class YANText { + public static bool AllNull(this IEnumerable strs) => !strs.Any(x => x.IsNotNull()); - public static bool IsNull([NotNullWhen(false)] this string? str) => str is null; + public static bool AllNull(this ICollection strs) => !strs.Any(x => x.IsNotNull()); - public static bool AllNull(params string?[] strs) => strs.IsNotNull() && !strs.Any(x => x.IsNotNull()); + public static bool AllNull(params string?[] strs) => !strs.Any(x => x.IsNotNull()); - public static bool AnyNull(params string?[] strs) => strs.IsNotNull() && strs.Any(x => x.IsNull()); + public static bool AnyNull(this IEnumerable strs) => strs.Any(x => x.IsNull()); - public static bool AllNull(this IEnumerable strs) => strs.IsNotNull() && !strs.Any(x => x.IsNotNull()); + public static bool AnyNull(this ICollection strs) => strs.Any(x => x.IsNull()); - public static bool AnyNull(this IEnumerable strs) => strs.IsNotNull() && strs.Any(x => x.IsNull()); + public static bool AnyNull(params string?[] strs) => strs.Any(x => x.IsNull()); public static bool IsEmptyOrNull([NotNullWhen(false)] this string? str) => string.IsNullOrEmpty(str); - public static bool AllEmptyOrNull(params string?[] strs) => strs.IsNotNull() && !strs.Any(x => x.IsNotEmptyAndNull()); + public static bool AllEmptyOrNull(this IEnumerable strs) => !strs.Any(x => x.IsNotEmptyAndNull()); - public static bool AnyEmptyOrNull(params string?[] strs) => strs.IsNotNull() && strs.Any(x => x.IsEmptyOrNull()); + public static bool AllEmptyOrNull(this ICollection strs) => !strs.Any(x => x.IsNotEmptyAndNull()); - public static bool AllEmptyOrNull(this IEnumerable strs) => strs.IsNotNull() && !strs.Any(x => x.IsNotEmptyAndNull()); + public static bool AllEmptyOrNull(params string?[] strs) => !strs.Any(x => x.IsNotEmptyAndNull()); - public static bool AnyEmptyOrNull(this IEnumerable strs) => strs.IsNotNull() && strs.Any(x => x.IsEmptyOrNull()); + public static bool AnyEmptyOrNull(this IEnumerable strs) => strs.Any(x => x.IsEmptyOrNull()); + + public static bool AnyEmptyOrNull(this ICollection strs) => strs.Any(x => x.IsEmptyOrNull()); + + public static bool AnyEmptyOrNull(params string?[] strs) => strs.Any(x => x.IsEmptyOrNull()); public static bool IsWhiteSpaceOrNull([NotNullWhen(false)] this string? str) => string.IsNullOrWhiteSpace(str); - public static bool AllWhiteSpaceOrNull(params string?[] strs) => strs.IsNotNull() && !strs.Any(x => x.IsNotWhiteSpaceAndNull()); + public static bool AllWhiteSpaceOrNull(this IEnumerable strs) => !strs.Any(x => x.IsNotWhiteSpaceAndNull()); - public static bool AnyWhiteSpaceOrNull(params string?[] strs) => strs.IsNotNull() && strs.Any(x => x.IsWhiteSpaceOrNull()); + public static bool AllWhiteSpaceOrNull(this ICollection strs) => !strs.Any(x => x.IsNotWhiteSpaceAndNull()); - public static bool AllWhiteSpaceOrNull(this IEnumerable? strs) => strs.IsNotEmptyAndNull() && !strs.Any(x => x.IsNotWhiteSpaceAndNull()); + public static bool AllWhiteSpaceOrNull(params string?[] strs) => !strs.Any(x => x.IsNotWhiteSpaceAndNull()); - public static bool AnyWhiteSpaceOrNull(this IEnumerable strs) => strs.IsNotNull() && strs.Any(x => x.IsWhiteSpaceOrNull()); + public static bool AnyWhiteSpaceOrNull(this IEnumerable strs) => strs.Any(x => x.IsWhiteSpaceOrNull()); - public static bool EqualsIgnoreCase(this string? str1, string? str2) => AllNull(str1, str2) || str1.IsNotNull() && str1.IsNotNull() && string.Equals(str1, str2, OrdinalIgnoreCase); + public static bool AnyWhiteSpaceOrNull(this ICollection strs) => strs.Any(x => x.IsWhiteSpaceOrNull()); - public static bool AllEqualsIgnoreCase(params string?[] strs) => strs.IsNotNull() && !strs.Any(x => x.NotEqualsIgnoreCase(strs[0])); + public static bool AnyWhiteSpaceOrNull(params string?[] strs) => strs.Any(x => x.IsWhiteSpaceOrNull()); - public static bool AnyEqualsIgnoreCase(params string?[] strs) => !strs.AllNotEqualsIgnoreCase(); + public static bool EqualsIgnoreCase(this string str1, string? str2) => AllNull(str1, str2) || str1.IsNotNull() && str1.IsNotNull() && string.Equals(str1, str2, OrdinalIgnoreCase); + + public static bool AllEqualsIgnoreCase(this IEnumerable strs) => !strs.Any(x => x.NotEqualsIgnoreCase(strs.First())); + + public static bool AllEqualsIgnoreCase(this ICollection strs) => !strs.Any(x => x.NotEqualsIgnoreCase(strs.First())); - public static bool AllEqualsIgnoreCase(this IEnumerable strs) => strs.IsNotNull() && !strs.Any(x => x.NotEqualsIgnoreCase(strs.First())); + public static bool AllEqualsIgnoreCase(params string?[] strs) => !strs.Any(x => x.NotEqualsIgnoreCase(strs[0])); public static bool AnyEqualsIgnoreCase(this IEnumerable strs) => !strs.AllNotEqualsIgnoreCase(); - public static bool IsNotNull([NotNullWhen(true)] this string? str) => str is not null; + public static bool AnyEqualsIgnoreCase(this ICollection strs) => !strs.AllNotEqualsIgnoreCase(); + + public static bool AnyEqualsIgnoreCase(params string?[] strs) => !strs.AllNotEqualsIgnoreCase(); + + public static bool AllNotNull(this IEnumerable strs) => !strs.Any(x => x.IsNull()); + + public static bool AllNotNull(this ICollection strs) => !strs.Any(x => x.IsNull()); - public static bool AllNotNull(params string?[] strs) => strs.IsNotNull() && !strs.Any(x => x.IsNull()); + public static bool AllNotNull(params string?[] strs) => !strs.Any(x => x.IsNull()); - public static bool AnyNotNull(params string?[] strs) => strs.IsNotNull() && strs.Any(x => x.IsNotNull()); + public static bool AnyNotNull(this IEnumerable strs) => strs.Any(x => x.IsNotNull()); - public static bool AllNotNull(this IEnumerable strs) => strs.IsNotNull() && !strs.Any(x => x.IsNull()); + public static bool AnyNotNull(this ICollection strs) => strs.Any(x => x.IsNotNull()); - public static bool AnyNotNull(this IEnumerable strs) => strs.IsNotNull() && strs.Any(x => x.IsNotNull()); + public static bool AnyNotNull(params string?[] strs) => strs.Any(x => x.IsNotNull()); public static bool IsNotEmptyAndNull([NotNullWhen(true)] this string? str) => !string.IsNullOrEmpty(str); - public static bool AllNotEmptyAndNull(params string?[] strs) => strs.IsNotNull() && !strs.Any(x => x.IsEmptyOrNull()); + public static bool AllNotEmptyAndNull(this IEnumerable strs) => !strs.Any(x => x.IsEmptyOrNull()); - public static bool AnyNotEmptyAndNull(params string?[] strs) => strs.IsNotNull() && strs.Any(x => x.IsNotEmptyAndNull()); + public static bool AllNotEmptyAndNull(this ICollection strs) => !strs.Any(x => x.IsEmptyOrNull()); - public static bool AllNotEmptyAndNull(this IEnumerable strs) => strs.IsNotNull() && !strs.Any(x => x.IsEmptyOrNull()); + public static bool AllNotEmptyAndNull(params string?[] strs) => !strs.Any(x => x.IsEmptyOrNull()); - public static bool AnyNotEmptyAndNull(this IEnumerable strs) => strs.IsNotNull() && strs.Any(x => x.IsNotEmptyAndNull()); + public static bool AnyNotEmptyAndNull(this IEnumerable strs) => strs.Any(x => x.IsNotEmptyAndNull()); + + public static bool AnyNotEmptyAndNull(this ICollection strs) => strs.Any(x => x.IsNotEmptyAndNull()); + + public static bool AnyNotEmptyAndNull(params string?[] strs) => strs.Any(x => x.IsNotEmptyAndNull()); public static bool IsNotWhiteSpaceAndNull([NotNullWhen(true)] this string? str) => !string.IsNullOrWhiteSpace(str); - public static bool AllNotWhiteSpaceAndNull(params string?[] strs) => strs.IsNotNull() && !strs.Any(x => x.IsWhiteSpaceOrNull()); + public static bool AllNotWhiteSpaceAndNull(this IEnumerable strs) => !strs.Any(x => x.IsWhiteSpaceOrNull()); + + public static bool AllNotWhiteSpaceAndNull(this ICollection strs) => !strs.Any(x => x.IsWhiteSpaceOrNull()); - public static bool AnyNotWhiteSpaceAndNull(params string?[] strs) => strs.IsNotNull() && strs.Any(x => x.IsNotWhiteSpaceAndNull()); + public static bool AllNotWhiteSpaceAndNull(params string?[] strs) => !strs.Any(x => x.IsWhiteSpaceOrNull()); - public static bool AllNotWhiteSpaceAndNull(this IEnumerable strs) => strs.IsNotNull() && !strs.Any(x => x.IsWhiteSpaceOrNull()); + public static bool AnyNotWhiteSpaceAndNull(this IEnumerable strs) => strs.Any(x => x.IsNotWhiteSpaceAndNull()); - public static bool AnyNotWhiteSpaceAndNull(this IEnumerable strs) => strs.IsNotNull() && strs.Any(x => x.IsNotWhiteSpaceAndNull()); + public static bool AnyNotWhiteSpaceAndNull(this ICollection strs) => strs.Any(x => x.IsNotWhiteSpaceAndNull()); + + public static bool AnyNotWhiteSpaceAndNull(params string?[] strs) => strs.Any(x => x.IsNotWhiteSpaceAndNull()); public static bool NotEqualsIgnoreCase(this string? str1, string? str2) => AllNotNull(str1, str2) && !string.Equals(str1, str2, OrdinalIgnoreCase); - public static bool AllNotEqualsIgnoreCase(params string?[] strs) + public static bool AllNotEqualsIgnoreCase(this IEnumerable strs) { - if (strs.IsNull() || strs.Length < 2) - { - return false; - } - - var hashSet = new HashSet(strs.Length, StringComparer.OrdinalIgnoreCase); + var hashSet = new HashSet(strs.Count(), StringComparer.OrdinalIgnoreCase); - for (var i = 0; i < strs.Length; i++) + foreach (var str in strs) { - if (!hashSet.Add(strs[i])) + if (!hashSet.Add(str)) { return false; } @@ -99,20 +117,28 @@ public static bool AllNotEqualsIgnoreCase(params string?[] strs) return true; } - public static bool AnyNotEqualsIgnoreCase(params string?[] strs) => !strs.AllEqualsIgnoreCase(); - - public static bool AllNotEqualsIgnoreCase(this IEnumerable strs) + public static bool AllNotEqualsIgnoreCase(this ICollection strs) { - if (strs.IsNull() || strs.Count() < 2) + var hashSet = new HashSet(strs.Count, StringComparer.OrdinalIgnoreCase); + + foreach (var str in strs) { - return false; + if (!hashSet.Add(str)) + { + return false; + } } - var hashSet = new HashSet(strs.Count(), StringComparer.OrdinalIgnoreCase); + return true; + } - foreach (var str in strs) + public static bool AllNotEqualsIgnoreCase(params string?[] strs) + { + var hashSet = new HashSet(strs.Length, StringComparer.OrdinalIgnoreCase); + + for (var i = 0; i < strs.Length; i++) { - if (!hashSet.Add(str)) + if (!hashSet.Add(strs[i])) { return false; } @@ -123,69 +149,79 @@ public static bool AllNotEqualsIgnoreCase(this IEnumerable strs) public static bool AnyNotEqualsIgnoreCase(this IEnumerable strs) => !strs.AllEqualsIgnoreCase(); - public static string GetValue(this string? str) => str ?? string.Empty; + public static bool AnyNotEqualsIgnoreCase(this ICollection strs) => !strs.AllEqualsIgnoreCase(); - public static string GetValue(this string? str, string dfltVal) => str ?? dfltVal; - - public static string GetValue(this string? str, char dfltVal) => str ?? (dfltVal.IsNotEmpty() ? dfltVal.ToString() : string.Empty); + public static bool AnyNotEqualsIgnoreCase(params string?[] strs) => !strs.AllEqualsIgnoreCase(); - public static string? ToLower(this string? str) => str.IsNotWhiteSpaceAndNull() ? str.ToLower() : str; + public static string? Lower(this string? str) => str.IsWhiteSpaceOrNull() ? str : str.ToLower(); - public static IEnumerable ToLower(this IEnumerable strs) + public static void Lower(this List? strs) { if (strs.IsEmptyOrNull()) { - yield break; + return; } - foreach (var str in strs) - { - yield return ToLower(str); - } + strs.ForEach(x => x = x.Lower()); } - public static string? ToLowerInvariant(this string? str) => str.IsNotWhiteSpaceAndNull() ? str.ToLower(CultureInfo.InvariantCulture) : str; + public static IEnumerable? Lowers(this IEnumerable? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.Lower()); - public static IEnumerable ToLowerInvariant(this IEnumerable strs) + public static IEnumerable? Lowers(this ICollection? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.Lower()); + + public static IEnumerable? Lowers(params string?[]? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.Lower()); + + public static string? LowerInvariant(this string? str) => str.IsWhiteSpaceOrNull() ? str : str.ToLower(CultureInfo.InvariantCulture); + + public static void LowerInvariant(this List? strs) { if (strs.IsEmptyOrNull()) { - yield break; + return; } - foreach (var str in strs) - { - yield return ToLowerInvariant(str); - } + strs.ForEach(x => x = x.LowerInvariant()); } - public static string? ToUpper(this string? str) => str.IsNotWhiteSpaceAndNull() ? str.ToUpper() : str; + public static IEnumerable? LowerInvariants(this IEnumerable? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.LowerInvariant()); + + public static IEnumerable? LowerInvariants(this ICollection? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.LowerInvariant()); + + public static IEnumerable? LowerInvariants(params string?[]? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.LowerInvariant()); + + public static string? Upper(this string? str) => str.IsWhiteSpaceOrNull() ? str : str.ToUpper(); - public static IEnumerable ToUpper(this IEnumerable strs) + public static void Upper(this List? strs) { if (strs.IsEmptyOrNull()) { - yield break; + return; } - foreach (var str in strs) - { - yield return ToUpper(str); - } + strs.ForEach(x => x = x.Upper()); } - public static string? ToUpperInvariant(this string? str) => str.IsNotWhiteSpaceAndNull() ? str.ToUpper(CultureInfo.InvariantCulture) : str; + public static IEnumerable? Uppers(this IEnumerable? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.Upper()); + + public static IEnumerable? Uppers(this ICollection? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.Upper()); - public static IEnumerable ToUpperInvariant(this IEnumerable strs) + public static IEnumerable? Uppers(params string?[]? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.Upper()); + + public static string? UpperInvariant(this string? str) => str.IsWhiteSpaceOrNull() ? str : str.ToUpper(CultureInfo.InvariantCulture); + + public static void UpperInvariant(this List? strs) { if (strs.IsEmptyOrNull()) { - yield break; + return; } - foreach (var str in strs) - { - yield return ToUpperInvariant(str); - } + strs.ForEach(x => x = x.UpperInvariant()); } + + public static IEnumerable? UpperInvariants(this IEnumerable? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.UpperInvariant()); + + public static IEnumerable? UpperInvariants(this ICollection? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.UpperInvariant()); + + public static IEnumerable? UpperInvariants(params string?[]? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.UpperInvariant()); } diff --git a/lib/YANLib/Core/YANText.cs b/lib/YANLib/Core/YANText.cs index 19a18c17..710505fe 100644 --- a/lib/YANLib/Core/YANText.cs +++ b/lib/YANLib/Core/YANText.cs @@ -5,23 +5,25 @@ namespace YANLib.Core; public static partial class YANText { + public static string? Title(this string? str) => str.IsWhiteSpaceOrNull() ? str : CurrentCulture.TextInfo.ToTitleCase(str); - public static string ToTitle(this string str) => str.IsWhiteSpaceOrNull() ? str : CurrentCulture.TextInfo.ToTitleCase(str); - - public static IEnumerable ToTitle(this IEnumerable strs) + public static void Titles(this List? strs) { if (strs.IsEmptyOrNull()) { - yield break; + return; } - foreach (var str in strs) - { - yield return str.ToTitle(); - } + strs.ForEach(x => x = x.Title()); } - public static string ToCapitalize(this string str) + public static IEnumerable? Titles(this IEnumerable? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.Title()); + + public static IEnumerable? Titles(this ICollection? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.Title()); + + public static IEnumerable? Titles(params string?[]? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.Title()); + + public static string? Capitalize(this string? str) { if (str.IsWhiteSpaceOrNull()) { @@ -47,20 +49,23 @@ public static string ToCapitalize(this string str) return sb.ToString(); } - public static IEnumerable ToCapitalize(this IEnumerable strs) + public static void Capitalizes(this List? strs) { if (strs.IsEmptyOrNull()) { - yield break; + return; } - foreach (var str in strs) - { - yield return str.ToCapitalize(); - } + strs.ForEach(x => x = x.Capitalize()); } - public static string CleanSpace(this string str) + public static IEnumerable? Capitalizes(this IEnumerable? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.Capitalize()); + + public static IEnumerable? Capitalizes(this ICollection? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.Capitalize()); + + public static IEnumerable? Capitalizes(params string?[]? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.Capitalize()); + + public static string? CleanSpace(this string? str) { if (str.IsEmptyOrNull()) { @@ -92,20 +97,23 @@ public static string CleanSpace(this string str) return sb.ToString(); } - public static IEnumerable CleanSpace(this IEnumerable strs) + public static void CleanSpace(this List? strs) { if (strs.IsEmptyOrNull()) { - yield break; + return; } - foreach (var str in strs) - { - yield return str.CleanSpace(); - } + strs.ForEach(x => x = x.CleanSpace()); } - public static string FormatName(this string str) + public static IEnumerable? CleanSpaces(this IEnumerable? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.CleanSpace()); + + public static IEnumerable? CleanSpaces(this ICollection? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.CleanSpace()); + + public static IEnumerable? CleanSpaces(params string?[]? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.CleanSpace()); + + public static string? FormatName(this string? str) { if (str.IsEmptyOrNull()) { @@ -131,20 +139,23 @@ public static string FormatName(this string str) return sb.ToString(); } - public static IEnumerable FormatName(this IEnumerable strs) + public static void FormatName(this List? strs) { if (strs.IsEmptyOrNull()) { - yield break; + return; } - foreach (var str in strs) - { - yield return str.FormatName(); - } + strs.ForEach(x => x = x.FormatName()); } - public static string FilterAlphabetic(this string str) + public static IEnumerable? FormatNames(this IEnumerable? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.FormatName()); + + public static IEnumerable? FormatNames(this ICollection? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.FormatName()); + + public static IEnumerable? FormatNames(params string?[]? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.FormatName()); + + public static string? FilterAlphabetic(this string? str) { if (str.IsEmptyOrNull()) { @@ -166,20 +177,23 @@ public static string FilterAlphabetic(this string str) return sb.ToString(); } - public static IEnumerable FilterAlphabetic(this IEnumerable strs) + public static void FilterAlphabetic(this List? strs) { if (strs.IsEmptyOrNull()) { - yield break; + return; } - foreach (var str in strs) - { - yield return str.FilterAlphabetic(); - } + strs.ForEach(x => x = x.FilterAlphabetic()); } - public static string FilterNumber(this string str) + public static IEnumerable? FilterAlphabetics(this IEnumerable? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.FilterAlphabetic()); + + public static IEnumerable? FilterAlphabetics(this ICollection? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.FilterAlphabetic()); + + public static IEnumerable? FilterAlphabetics(params string?[]? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.FilterAlphabetic()); + + public static string? FilterNumber(this string? str) { if (str.IsEmptyOrNull()) { @@ -201,20 +215,23 @@ public static string FilterNumber(this string str) return sb.ToString(); } - public static IEnumerable FilterNumber(this IEnumerable strs) + public static void FilterNumber(this List? strs) { if (strs.IsEmptyOrNull()) { - yield break; + return; } - foreach (var str in strs) - { - yield return str.FilterNumber(); - } + strs.ForEach(x => x = x.FilterNumber()); } - public static string FilterAlphanumeric(this string str) + public static IEnumerable? FilterNumbers(this IEnumerable? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.FilterNumber()); + + public static IEnumerable? FilterNumbers(this ICollection? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.FilterNumber()); + + public static IEnumerable? FilterNumbers(params string?[]? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.FilterNumber()); + + public static string? FilterAlphanumeric(this string? str) { if (str.IsEmptyOrNull()) { @@ -236,16 +253,19 @@ public static string FilterAlphanumeric(this string str) return sb.ToString(); } - public static IEnumerable FilterAlphanumeric(this IEnumerable strs) + public static void FilterAlphanumeric(this List? strs) { if (strs.IsEmptyOrNull()) { - yield break; + return; } - foreach (var str in strs) - { - yield return str.FilterAlphanumeric(); - } + strs.ForEach(x => x = x.FilterAlphanumeric()); } + + public static IEnumerable? FilterAlphanumerics(this IEnumerable? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.FilterAlphanumeric()); + + public static IEnumerable? FilterAlphanumerics(this ICollection? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.FilterAlphanumeric()); + + public static IEnumerable? FilterAlphanumerics(params string?[]? strs) => strs.IsEmptyOrNull() ? strs : strs.Select(x => x.FilterAlphanumeric()); } \ No newline at end of file diff --git a/lib/YANLib/Nullable/YANDateTime.cs b/lib/YANLib/Nullable/YANDateTime.cs index 967f3f3e..a402285e 100644 --- a/lib/YANLib/Nullable/YANDateTime.cs +++ b/lib/YANLib/Nullable/YANDateTime.cs @@ -90,7 +90,7 @@ public static partial class YANDateTime /// The minimum value for each generated value. Can be . /// The maximum value for each generated value. Can be . /// An enumerable collection of randomly generated values. - public static IEnumerable GenerateRandomDateTimes(object? size, DateTime? min = null, DateTime? max = null) => Range(0, (int)size.ToUint()).Select(i => GenerateRandomDateTime(min, max)); + public static IEnumerable GenerateRandomDateTimes(object? size, DateTime? min = null, DateTime? max = null) => Range(0, (int)Core.YANNum.ToUint(size)).Select(i => GenerateRandomDateTime(min, max)); /// /// Gets the week of the year for a specified . @@ -142,7 +142,7 @@ public static partial class YANDateTime return default; } - var diff = tzDst.ToInt() - tzSrc.ToInt(); + var diff = Core.YANNum.ToInt(tzDst) - Core.YANNum.ToInt(tzSrc); return diff switch { diff --git a/lib/YANLib/Nullable/YANNum.Byte.cs b/lib/YANLib/Nullable/YANNum.Byte.cs index 67e8952c..4a2e071a 100644 --- a/lib/YANLib/Nullable/YANNum.Byte.cs +++ b/lib/YANLib/Nullable/YANNum.Byte.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToBytes(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToByte(dfltVal)); + public static IEnumerable? ToBytes(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToByte(dfltVal)); - public static IEnumerable? ToBytes(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToByte(dfltVal)); + public static IEnumerable? ToBytes(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToByte(dfltVal)); - public static IEnumerable? ToBytes(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToByte(dfltVal)); + public static IEnumerable? ToBytes(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToByte(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANNum.Decimal.cs b/lib/YANLib/Nullable/YANNum.Decimal.cs index 53cf92ae..ab4e3dd9 100644 --- a/lib/YANLib/Nullable/YANNum.Decimal.cs +++ b/lib/YANLib/Nullable/YANNum.Decimal.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToDecimals(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToDecimal(dfltVal)); + public static IEnumerable? ToDecimals(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToDecimal(dfltVal)); - public static IEnumerable? ToDecimals(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToDecimal(dfltVal)); + public static IEnumerable? ToDecimals(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToDecimal(dfltVal)); - public static IEnumerable? ToDecimals(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToDecimal(dfltVal)); + public static IEnumerable? ToDecimals(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToDecimal(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANNum.Double.cs b/lib/YANLib/Nullable/YANNum.Double.cs index cde6b080..f334e398 100644 --- a/lib/YANLib/Nullable/YANNum.Double.cs +++ b/lib/YANLib/Nullable/YANNum.Double.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToDouble(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToDouble(dfltVal)); + public static IEnumerable? ToDoubles(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToDouble(dfltVal)); - public static IEnumerable? ToDouble(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToDouble(dfltVal)); + public static IEnumerable? ToDoubles(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToDouble(dfltVal)); - public static IEnumerable? ToDouble(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToDouble(dfltVal)); + public static IEnumerable? ToDoubles(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToDouble(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANNum.Float.cs b/lib/YANLib/Nullable/YANNum.Float.cs index 95f6f1c2..2558c596 100644 --- a/lib/YANLib/Nullable/YANNum.Float.cs +++ b/lib/YANLib/Nullable/YANNum.Float.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToFloat(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToFloat(dfltVal)); + public static IEnumerable? ToFloats(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToFloat(dfltVal)); - public static IEnumerable? ToFloat(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToFloat(dfltVal)); + public static IEnumerable? ToFloats(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToFloat(dfltVal)); - public static IEnumerable? ToFloat(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToFloat(dfltVal)); + public static IEnumerable? ToFloats(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToFloat(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANNum.Int.cs b/lib/YANLib/Nullable/YANNum.Int.cs index 06f5f2dc..9f13ca57 100644 --- a/lib/YANLib/Nullable/YANNum.Int.cs +++ b/lib/YANLib/Nullable/YANNum.Int.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToInt(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToInt(dfltVal)); + public static IEnumerable? ToInts(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToInt(dfltVal)); - public static IEnumerable? ToInt(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToInt(dfltVal)); + public static IEnumerable? ToInts(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToInt(dfltVal)); - public static IEnumerable? ToInt(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToInt(dfltVal)); + public static IEnumerable? ToInts(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToInt(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANNum.Long.cs b/lib/YANLib/Nullable/YANNum.Long.cs index 14ec8c36..b231973a 100644 --- a/lib/YANLib/Nullable/YANNum.Long.cs +++ b/lib/YANLib/Nullable/YANNum.Long.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToLong(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToLong(dfltVal)); + public static IEnumerable? ToLongs(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToLong(dfltVal)); - public static IEnumerable? ToLong(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToLong(dfltVal)); + public static IEnumerable? ToLongs(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToLong(dfltVal)); - public static IEnumerable? ToLong(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToLong(dfltVal)); + public static IEnumerable? ToLongs(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToLong(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANNum.Nint.cs b/lib/YANLib/Nullable/YANNum.Nint.cs index a0dd7360..2e363b1e 100644 --- a/lib/YANLib/Nullable/YANNum.Nint.cs +++ b/lib/YANLib/Nullable/YANNum.Nint.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToNint(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToNint(dfltVal)); + public static IEnumerable? ToNints(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToNint(dfltVal)); - public static IEnumerable? ToNint(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToNint(dfltVal)); + public static IEnumerable? ToNints(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToNint(dfltVal)); - public static IEnumerable? ToNint(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToNint(dfltVal)); + public static IEnumerable? ToNints(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToNint(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANNum.Nuint.cs b/lib/YANLib/Nullable/YANNum.Nuint.cs index e0e3cab3..73b4b379 100644 --- a/lib/YANLib/Nullable/YANNum.Nuint.cs +++ b/lib/YANLib/Nullable/YANNum.Nuint.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToNuint(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToNuint(dfltVal)); + public static IEnumerable? ToNuints(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToNuint(dfltVal)); - public static IEnumerable? ToNuint(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToNuint(dfltVal)); + public static IEnumerable? ToNuints(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToNuint(dfltVal)); - public static IEnumerable? ToNuint(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToNuint(dfltVal)); + public static IEnumerable? ToNuints(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToNuint(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANNum.Sbyte.cs b/lib/YANLib/Nullable/YANNum.Sbyte.cs index 52192b4a..410ad8fa 100644 --- a/lib/YANLib/Nullable/YANNum.Sbyte.cs +++ b/lib/YANLib/Nullable/YANNum.Sbyte.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToSbyte(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToSbyte(dfltVal)); + public static IEnumerable? ToSbytes(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToSbyte(dfltVal)); - public static IEnumerable? ToSbyte(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToSbyte(dfltVal)); + public static IEnumerable? ToSbytes(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToSbyte(dfltVal)); - public static IEnumerable? ToSbyte(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToSbyte(dfltVal)); + public static IEnumerable? ToSbytes(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToSbyte(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANNum.Short.cs b/lib/YANLib/Nullable/YANNum.Short.cs index e858a4c6..ad221b98 100644 --- a/lib/YANLib/Nullable/YANNum.Short.cs +++ b/lib/YANLib/Nullable/YANNum.Short.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToShort(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToShort(dfltVal)); + public static IEnumerable? ToShorts(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToShort(dfltVal)); - public static IEnumerable? ToShort(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToShort(dfltVal)); + public static IEnumerable? ToShorts(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToShort(dfltVal)); - public static IEnumerable? ToShort(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToShort(dfltVal)); + public static IEnumerable? ToShorts(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToShort(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANNum.Uint.cs b/lib/YANLib/Nullable/YANNum.Uint.cs index 05f7cc72..0fde1ac6 100644 --- a/lib/YANLib/Nullable/YANNum.Uint.cs +++ b/lib/YANLib/Nullable/YANNum.Uint.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToUint(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToUint(dfltVal)); + public static IEnumerable? ToUints(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToUint(dfltVal)); - public static IEnumerable? ToUint(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToUint(dfltVal)); + public static IEnumerable? ToUints(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToUint(dfltVal)); - public static IEnumerable? ToUint(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToUint(dfltVal)); + public static IEnumerable? ToUints(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToUint(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANNum.Ulong.cs b/lib/YANLib/Nullable/YANNum.Ulong.cs index bd6dc01f..61d64728 100644 --- a/lib/YANLib/Nullable/YANNum.Ulong.cs +++ b/lib/YANLib/Nullable/YANNum.Ulong.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToUlong(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToUlong(dfltVal)); + public static IEnumerable? ToUlongs(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToUlong(dfltVal)); - public static IEnumerable? ToUlong(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToUlong(dfltVal)); + public static IEnumerable? ToUlongs(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToUlong(dfltVal)); - public static IEnumerable? ToUlong(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToUlong(dfltVal)); + public static IEnumerable? ToUlongs(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToUlong(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANNum.Ushort.cs b/lib/YANLib/Nullable/YANNum.Ushort.cs index 6e2ab4e1..9e028098 100644 --- a/lib/YANLib/Nullable/YANNum.Ushort.cs +++ b/lib/YANLib/Nullable/YANNum.Ushort.cs @@ -16,9 +16,9 @@ public static partial class YANNum } } - public static IEnumerable? ToUshort(this IEnumerable? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToUshort(dfltVal)); + public static IEnumerable? ToUshorts(this IEnumerable? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToUshort(dfltVal)); - public static IEnumerable? ToUshort(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToUshort(dfltVal)); + public static IEnumerable? ToUshorts(this ICollection? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToUshort(dfltVal)); - public static IEnumerable? ToUshort(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToUshort(dfltVal)); + public static IEnumerable? ToUshorts(this object?[]? vals, object? dfltVal = null) => vals.IsEmptyOrNull() ? default : vals.Select(x => x.ToUshort(dfltVal)); } diff --git a/lib/YANLib/Nullable/YANText.Char.cs b/lib/YANLib/Nullable/YANText.Char.cs new file mode 100644 index 00000000..3df3f853 --- /dev/null +++ b/lib/YANLib/Nullable/YANText.Char.cs @@ -0,0 +1,342 @@ +using System.Diagnostics.CodeAnalysis; +using YANLib.Core; + +namespace YANLib.Nullable; + +public static partial class YANText +{ + public static bool IsEmptyOrNull([NotNullWhen(false)] this char? c) => !c.HasValue || c.Value.IsEmpty(); + + public static bool AllEmptyOrNull(this IEnumerable cs) => !cs.Any(x => x.IsNotEmptyAndNull()); + + public static bool AllEmptyOrNull(this ICollection cs) => !cs.Any(x => x.IsNotEmptyAndNull()); + + public static bool AllEmptyOrNull(params char?[] cs) => !cs.Any(x => x.IsNotEmptyAndNull()); + + public static bool AnyEmptyOrNull(this IEnumerable cs) => cs.Any(x => x.IsEmptyOrNull()); + + public static bool AnyEmptyOrNull(this ICollection cs) => cs.Any(x => x.IsEmptyOrNull()); + + public static bool AnyEmptyOrNull(params char?[] cs) => cs.Any(x => x.IsEmptyOrNull()); + + public static bool IsWhiteSpaceOrNull([NotNullWhen(false)] this char? c) => !c.HasValue || c.Value.IsEmpty() || c.Value.IsWhiteSpace(); + + public static bool AllWhiteSpaceOrNull(this IEnumerable cs) => !cs.Any(x => x.IsNotWhiteSpaceAndNull()); + + public static bool AllWhiteSpaceOrNull(this ICollection cs) => !cs.Any(x => x.IsNotWhiteSpaceAndNull()); + + public static bool AllWhiteSpaceOrNull(params char?[] cs) => !cs.Any(x => x.IsNotWhiteSpaceAndNull()); + + public static bool AnyWhiteSpaceOrNull(this IEnumerable cs) => cs.Any(x => x.IsWhiteSpaceOrNull()); + + public static bool AnyWhiteSpaceOrNull(this ICollection cs) => cs.Any(x => x.IsWhiteSpaceOrNull()); + + public static bool AnyWhiteSpaceOrNull(params char?[] cs) => cs.Any(x => x.IsWhiteSpaceOrNull()); + + public static bool IsAlphabetic([NotNullWhen(true)] this char? c) => c.HasValue && c.Value.IsAlphabetic(); + + public static bool AllAlphabetic(this IEnumerable cs) => !cs.Any(x => x.IsNotAlphabetic()); + + public static bool AllAlphabetic(this ICollection cs) => !cs.Any(x => x.IsNotAlphabetic()); + + public static bool AllAlphabetic(params char?[] cs) => !cs.Any(x => x.IsNotAlphabetic()); + + public static bool AnyAlphabetic(this IEnumerable cs) => cs.Any(x => x.IsAlphabetic()); + + public static bool AnyAlphabetic(this ICollection cs) => cs.Any(x => x.IsAlphabetic()); + + public static bool AnyAlphabetic(params char?[] cs) => cs.Any(x => x.IsAlphabetic()); + + public static bool IsPunctuation([NotNullWhen(true)] this char? c) => c.HasValue && c.Value.IsPunctuation(); + + public static bool AllPunctuation(this IEnumerable cs) => !cs.Any(x => x.IsNotPunctuation()); + + public static bool AllPunctuation(this ICollection cs) => !cs.Any(x => x.IsNotPunctuation()); + + public static bool AllPunctuation(params char?[] cs) => !cs.Any(x => x.IsNotPunctuation()); + + public static bool AnyPunctuation(this IEnumerable cs) => cs.Any(x => x.IsPunctuation()); + + public static bool AnyPunctuation(this ICollection cs) => cs.Any(x => x.IsPunctuation()); + + public static bool AnyPunctuation(params char?[] cs) => cs.Any(x => x.IsPunctuation()); + + public static bool IsNumber([NotNullWhen(true)] this char? c) => c.HasValue && c.Value.IsNumber(); + + public static bool AllNumber(this IEnumerable cs) => !cs.Any(x => x.IsNotNumber()); + + public static bool AllNumber(this ICollection cs) => !cs.Any(x => x.IsNotNumber()); + + public static bool AllNumber(params char?[] cs) => !cs.Any(x => x.IsNotNumber()); + + public static bool AnyNumber(this IEnumerable cs) => cs.Any(x => x.IsNumber()); + + public static bool AnyNumber(this ICollection cs) => cs.Any(x => x.IsNumber()); + + public static bool AnyNumber(params char?[] cs) => cs.Any(x => x.IsNumber()); + + public static bool EqualsIgnoreCase(this char c1, char? c2) => c1.LowerInvariant() == c2.LowerInvariant(); + + public static bool AllEqualsIgnoreCase(this IEnumerable cs) => !cs.Any(x => x.NotEqualsIgnoreCase(cs.First())); + + public static bool AllEqualsIgnoreCase(this ICollection cs) => !cs.Any(x => x.NotEqualsIgnoreCase(cs.First())); + + public static bool AllEqualsIgnoreCase(params char?[] cs) => !cs.Any(x => x.NotEqualsIgnoreCase(cs.First())); + + public static bool AnyEqualsIgnoreCase(this IEnumerable cs) => !cs.AllNotEqualsIgnoreCase(); + + public static bool AnyEqualsIgnoreCase(this ICollection cs) => !cs.AllNotEqualsIgnoreCase(); + + public static bool AnyEqualsIgnoreCase(params char?[] cs) => !cs.AllNotEqualsIgnoreCase(); + + public static bool IsNotEmptyAndNull([NotNullWhen(true)] this char? c) => c.HasValue && c.Value.IsNotEmpty(); + + public static bool AllNotEmptyAndNull(this IEnumerable cs) => !cs.Any(x => x.IsEmptyOrNull()); + + public static bool AllNotEmptyAndNull(this ICollection cs) => !cs.Any(x => x.IsEmptyOrNull()); + + public static bool AllNotEmptyAndNull(params char?[] cs) => !cs.Any(x => x.IsEmptyOrNull()); + + public static bool AnyNotEmptyAndNull(this IEnumerable cs) => cs.Any(x => x.IsNotEmptyAndNull()); + + public static bool AnyNotEmptyAndNull(this ICollection cs) => cs.Any(x => x.IsNotEmptyAndNull()); + + public static bool AnyNotEmptyAndNull(params char?[] cs) => cs.Any(x => x.IsNotEmptyAndNull()); + + public static bool IsNotWhiteSpaceAndNull([NotNullWhen(true)] this char? c) => c.HasValue && c.Value.IsNotEmpty() && c.Value.IsNotWhiteSpace(); + + public static bool AllNotWhiteSpaceAndNull(this IEnumerable cs) => !cs.Any(x => x.IsWhiteSpaceOrNull()); + + public static bool AllNotWhiteSpaceAndNull(this ICollection cs) => !cs.Any(x => x.IsWhiteSpaceOrNull()); + + public static bool AllNotWhiteSpaceAndNull(params char?[] cs) => !cs.Any(x => x.IsWhiteSpaceOrNull()); + + public static bool AnyNotWhiteSpaceAndNull(this IEnumerable cs) => cs.Any(x => x.IsNotWhiteSpaceAndNull()); + + public static bool AnyNotWhiteSpaceAndNull(this ICollection cs) => cs.Any(x => x.IsNotWhiteSpaceAndNull()); + + public static bool AnyNotWhiteSpaceAndNull(params char?[] cs) => cs.Any(x => x.IsNotWhiteSpaceAndNull()); + + public static bool IsNotAlphabetic(this char? c) => c.HasValue && c.Value.IsNotAlphabetic(); + + public static bool AllNotAlphabetic(this IEnumerable cs) => !cs.Any(x => x.IsAlphabetic()); + + public static bool AllNotAlphabetic(this ICollection cs) => !cs.Any(x => x.IsAlphabetic()); + + public static bool AllNotAlphabetic(params char?[] cs) => !cs.Any(x => x.IsAlphabetic()); + + public static bool AnyNotAlphabetic(this IEnumerable cs) => cs.Any(x => x.IsNotAlphabetic()); + + public static bool AnyNotAlphabetic(this ICollection cs) => cs.Any(x => x.IsNotAlphabetic()); + + public static bool AnyNotAlphabetic(params char?[] cs) => cs.Any(x => x.IsNotAlphabetic()); + + public static bool IsNotPunctuation(this char? c) => c.HasValue && c.Value.IsNotPunctuation(); + + public static bool AllNotPunctuation(this IEnumerable cs) => !cs.Any(x => x.IsPunctuation()); + + public static bool AllNotPunctuation(this ICollection cs) => !cs.Any(x => x.IsPunctuation()); + + public static bool AllNotPunctuation(params char?[] cs) => !cs.Any(x => x.IsPunctuation()); + + public static bool AnyNotPunctuation(this IEnumerable cs) => cs.Any(x => x.IsNotPunctuation()); + + public static bool AnyNotPunctuation(this ICollection cs) => cs.Any(x => x.IsNotPunctuation()); + + public static bool AnyNotPunctuation(params char?[] cs) => cs.Any(x => x.IsNotPunctuation()); + + public static bool IsNotNumber(this char? c) => c.HasValue && c.Value.IsNotNumber(); + + public static bool AllNotNumber(this IEnumerable cs) => !cs.Any(x => x.IsNumber()); + + public static bool AllNotNumber(this ICollection cs) => !cs.Any(x => x.IsNumber()); + + public static bool AllNotNumber(params char?[] cs) => !cs.Any(x => x.IsNumber()); + + public static bool AnyNotNumber(this IEnumerable cs) => cs.Any(x => x.IsNotNumber()); + + public static bool AnyNotNumber(this ICollection cs) => cs.Any(x => x.IsNotNumber()); + + public static bool AnyNotNumber(params char?[] cs) => cs.Any(x => x.IsNotNumber()); + + public static bool NotEqualsIgnoreCase(this char? c1, char? c2) => c1.LowerInvariant() != c2.LowerInvariant(); + + public static bool AllNotEqualsIgnoreCase(this IEnumerable cs) + { + var hashSet = new HashSet(cs.Count()); + + foreach (var c in cs) + { + if (!hashSet.Add(c.LowerInvariant())) + { + return false; + } + } + + return true; + } + + public static bool AllNotEqualsIgnoreCase(this ICollection cs) + { + var hashSet = new HashSet(cs.Count); + + foreach (var c in cs) + { + if (!hashSet.Add(c.LowerInvariant())) + { + return false; + } + } + + return true; + } + + public static bool AllNotEqualsIgnoreCase(params char?[] cs) + { + var hashSet = new HashSet(cs.Length); + + foreach (var c in cs) + { + if (!hashSet.Add(c.LowerInvariant())) + { + return false; + } + } + + return true; + } + + public static bool AnyNotEqualsIgnoreCase(this IEnumerable cs) => !cs.AllEqualsIgnoreCase(); + + public static bool AnyNotEqualsIgnoreCase(this ICollection cs) => !cs.AllEqualsIgnoreCase(); + + public static bool AnyNotEqualsIgnoreCase(params char?[] cs) => !cs.AllEqualsIgnoreCase(); + + public static char? Lower(this char? c) => c.IsWhiteSpaceOrNull() ? default : char.ToLower(c.Value); + + public static void Lower(this List? cs) + { + if (cs.IsEmptyOrNull()) + { + return; + } + + cs.ForEach(x => x = x.Lower()); + } + + public static IEnumerable? Lowers(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Lower()); + + public static IEnumerable? Lowers(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Lower()); + + public static IEnumerable? Lowers(params char?[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Lower()); + + public static char? LowerInvariant(this char? c) => c.IsWhiteSpaceOrNull() ? default : char.ToLowerInvariant(c.Value); + + public static void LowerInvariant(this List? cs) + { + if (cs.IsEmptyOrNull()) + { + return; + } + + cs.ForEach(x => x = x.LowerInvariant()); + } + + public static IEnumerable? LowerInvariants(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.LowerInvariant()); + + public static IEnumerable? LowerInvariants(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.LowerInvariant()); + + public static IEnumerable? LowerInvariants(params char?[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.LowerInvariant()); + + public static char? Upper(this char? c) => c.IsWhiteSpaceOrNull() ? default : char.ToUpper(c.Value); + + public static void Upper(this List? cs) + { + if (cs.IsEmptyOrNull()) + { + return; + } + + cs.ForEach(x => x = x.Upper()); + } + + public static IEnumerable? Uppers(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Upper()); + + public static IEnumerable? Uppers(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Upper()); + + public static IEnumerable? Uppers(params char?[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.Upper()); + + public static char? UpperInvariant(this char? c) => c.IsWhiteSpaceOrNull() ? default : char.ToUpperInvariant(c.Value); + + public static void UpperInvariant(this List? cs) + { + if (cs.IsEmptyOrNull()) + { + return; + } + + cs.ForEach(x => x = x.UpperInvariant()); + } + + public static IEnumerable? UpperInvariants(this IEnumerable? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.UpperInvariant()); + + public static IEnumerable? UpperInvariants(this ICollection? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.UpperInvariant()); + + public static IEnumerable? UpperInvariants(params char?[]? cs) => cs.IsEmptyOrNull() ? default : cs.Select(x => x.UpperInvariant()); + + public static bool IsLower(this char? c) => c.HasValue && char.IsLower(c.Value); + + public static bool AllLowers(this IEnumerable cs) => !cs.Any(x => x.IsNotLower()); + + public static bool AllLowers(this ICollection cs) => !cs.Any(x => x.IsNotLower()); + + public static bool AllLowers(params char?[] cs) => !cs.Any(x => x.IsNotLower()); + + public static bool AnyLowers(this IEnumerable cs) => cs.Any(x => x.IsLower()); + + public static bool AnyLowers(this ICollection cs) => cs.Any(x => x.IsLower()); + + public static bool AnyLowers(params char?[] cs) => cs.Any(x => x.IsLower()); + + public static bool IsNotLower(this char? c) => c.HasValue && !char.IsLower(c.Value); + + public static bool AllNotLowers(this IEnumerable cs) => !cs.Any(x => x.IsLower()); + + public static bool AllNotLowers(this ICollection cs) => !cs.Any(x => x.IsLower()); + + public static bool AllNotLowers(params char?[] cs) => !cs.Any(x => x.IsLower()); + + public static bool AnyNotLowers(this IEnumerable cs) => cs.Any(x => x.IsNotLower()); + + public static bool AnyNotLowers(this ICollection cs) => cs.Any(x => x.IsNotLower()); + + public static bool AnyNotLowers(params char?[] cs) => cs.Any(x => x.IsNotLower()); + + public static bool IsUpper(this char? c) => c.HasValue && char.IsUpper(c.Value); + + public static bool AllUppers(this IEnumerable cs) => !cs.Any(x => x.IsNotUpper()); + + public static bool AllUppers(this ICollection cs) => !cs.Any(x => x.IsNotUpper()); + + public static bool AllUppers(params char?[] cs) => !cs.Any(x => x.IsNotUpper()); + + public static bool AnyUppers(this IEnumerable cs) => cs.Any(x => x.IsUpper()); + + public static bool AnyUppers(this ICollection cs) => cs.Any(x => x.IsUpper()); + + public static bool AnyUppers(params char?[] cs) => cs.Any(x => x.IsUpper()); + + public static bool IsNotUpper(this char? c) => c.HasValue && !char.IsUpper(c.Value); + + public static bool AllNotUppers(this IEnumerable cs) => !cs.Any(x => x.IsUpper()); + + public static bool AllNotUppers(this ICollection cs) => !cs.Any(x => x.IsUpper()); + + public static bool AllNotUppers(params char?[] cs) => !cs.Any(x => x.IsUpper()); + + public static bool AnyNotUppers(this IEnumerable cs) => cs.Any(x => x.IsNotUpper()); + + public static bool AnyNotUppers(this ICollection cs) => cs.Any(x => x.IsNotUpper()); + + public static bool AnyNotUppers(params char?[] cs) => cs.Any(x => x.IsNotUpper()); +} diff --git a/lib/YANLib/Ultimate/Core/YANDateTime.cs b/lib/YANLib/Ultimate/Core/YANDateTime.cs index 8609a958..0eae0a7c 100644 --- a/lib/YANLib/Ultimate/Core/YANDateTime.cs +++ b/lib/YANLib/Ultimate/Core/YANDateTime.cs @@ -88,13 +88,13 @@ public static IEnumerable GenerateRandomDateTimes(object? size, DateTi } /// - /// Converts a collection of nullable values to their respective week numbers of the year. + /// Converts a collection of non-nullable values to their respective week numbers of the year. /// If the collection is or empty, yields no results. /// Each value is converted to its corresponding week number based on the current culture's calendar and rules. /// - /// The collection of nullable values. Can be . + /// The collection of non-nullable values. Can be . /// An enumerable collection of integers representing the week numbers of the year for each value. - public static IEnumerable GetWeekOfYears(this IEnumerable? dts) + public static IEnumerable GetWeekOfYears(this IEnumerable? dts) { if (dts.IsEmptyOrNull()) { @@ -108,13 +108,13 @@ public static IEnumerable GetWeekOfYears(this IEnumerable? dts) } /// - /// Converts a collection of non-nullable values to their respective week numbers of the year. + /// Converts a collection (ICollection) of non-nullable values to their respective week numbers of the year. /// If the collection is or empty, yields no results. /// Each value is converted to its corresponding week number based on the current culture's calendar and rules. /// - /// The collection of non-nullable values. Can be . + /// The ICollection of non-nullable values. Can be . /// An enumerable collection of integers representing the week numbers of the year for each value. - public static IEnumerable GetWeekOfYears(this IEnumerable? dts) + public static IEnumerable GetWeekOfYears(this ICollection? dts) { if (dts.IsEmptyOrNull()) { @@ -128,13 +128,13 @@ public static IEnumerable GetWeekOfYears(this IEnumerable? dts) } /// - /// Converts a collection (ICollection) of nullable values to their respective week numbers of the year. - /// If the collection is or empty, yields no results. + /// Converts an array of non-nullable values to their respective week numbers of the year. + /// If the array is or empty, yields no results. /// Each value is converted to its corresponding week number based on the current culture's calendar and rules. /// - /// The ICollection of nullable values. Can be . + /// The array of non-nullable values. Can be . /// An enumerable collection of integers representing the week numbers of the year for each value. - public static IEnumerable GetWeekOfYears(this ICollection? dts) + public static IEnumerable GetWeekOfYears(this DateTime[]? dts) { if (dts.IsEmptyOrNull()) { @@ -148,13 +148,13 @@ public static IEnumerable GetWeekOfYears(this ICollection? dts) } /// - /// Converts a collection (ICollection) of non-nullable values to their respective week numbers of the year. + /// Converts a collection of nullable values to their respective week numbers of the year. /// If the collection is or empty, yields no results. /// Each value is converted to its corresponding week number based on the current culture's calendar and rules. /// - /// The ICollection of non-nullable values. Can be . + /// The collection of nullable values. Can be . /// An enumerable collection of integers representing the week numbers of the year for each value. - public static IEnumerable GetWeekOfYears(this ICollection? dts) + public static IEnumerable GetWeekOfYears(this IEnumerable? dts) { if (dts.IsEmptyOrNull()) { @@ -168,13 +168,13 @@ public static IEnumerable GetWeekOfYears(this ICollection? dts) } /// - /// Converts an array of nullable values to their respective week numbers of the year. - /// If the array is or empty, yields no results. + /// Converts a collection (ICollection) of nullable values to their respective week numbers of the year. + /// If the collection is or empty, yields no results. /// Each value is converted to its corresponding week number based on the current culture's calendar and rules. /// - /// The array of nullable values. Can be . + /// The ICollection of nullable values. Can be . /// An enumerable collection of integers representing the week numbers of the year for each value. - public static IEnumerable GetWeekOfYears(this DateTime?[]? dts) + public static IEnumerable GetWeekOfYears(this ICollection? dts) { if (dts.IsEmptyOrNull()) { @@ -188,13 +188,13 @@ public static IEnumerable GetWeekOfYears(this DateTime?[]? dts) } /// - /// Converts an array of non-nullable values to their respective week numbers of the year. + /// Converts an array of nullable values to their respective week numbers of the year. /// If the array is or empty, yields no results. /// Each value is converted to its corresponding week number based on the current culture's calendar and rules. /// - /// The array of non-nullable values. Can be . + /// The array of nullable values. Can be . /// An enumerable collection of integers representing the week numbers of the year for each value. - public static IEnumerable GetWeekOfYears(this DateTime[]? dts) + public static IEnumerable GetWeekOfYears(this DateTime?[]? dts) { if (dts.IsEmptyOrNull()) { diff --git a/lib/YANLib/Ultimate/Core/YANNum.Byte.cs b/lib/YANLib/Ultimate/Core/YANNum.Byte.cs index 9257e8d1..5bba5863 100644 --- a/lib/YANLib/Ultimate/Core/YANNum.Byte.cs +++ b/lib/YANLib/Ultimate/Core/YANNum.Byte.cs @@ -4,7 +4,7 @@ namespace YANLib.Ultimate.Core; public static partial class YANNum { - public static IEnumerable ToBytes(this IEnumerable? vals, object? dfltVal = null) + public static IEnumerable ToBytes(this IEnumerable vals, object? dfltVal = null) { if (vals.IsEmptyOrNull()) { @@ -17,9 +17,37 @@ public static IEnumerable ToBytes(this IEnumerable? vals, object? } } - public static IEnumerable ToBytes(this ICollection? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToByte(dfltVal)); + public static IEnumerable ToBytes(this ICollection vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToByte(dfltVal); + } + } + + public static IEnumerable ToBytes(this object?[] vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } - public static IEnumerable ToBytes(this object?[]? nums, object? dfltVal = null) => nums.IsEmptyOrNull() ? default : nums.Select(x => x.ToByte(dfltVal)); + foreach (var val in vals) + { + yield return val.ToByte(dfltVal); + } + } - public static IEnumerable GenerateRandomBytes(object? min = null, object? max = null, object? size = null) => Range(0, (int)size.ToUint()).Select(i => GenerateRandomByte(min, max)); + public static IEnumerable GenerateRandomBytes(object? min = null, object? max = null, object? size = null) + { + for (var i = 0ul; i < size.ToUlong(); i++) + { + yield return YANLib.Core.YANNum.GenerateRandomByte(min, max); + } + } } diff --git a/lib/YANLib/Ultimate/Core/YANNum.Decimal.cs b/lib/YANLib/Ultimate/Core/YANNum.Decimal.cs index 69370f4a..f2257d1e 100644 --- a/lib/YANLib/Ultimate/Core/YANNum.Decimal.cs +++ b/lib/YANLib/Ultimate/Core/YANNum.Decimal.cs @@ -4,46 +4,46 @@ namespace YANLib.Ultimate.Core; public static partial class YANNum { - public static IEnumerable ToDecimal(this IEnumerable nums) where T : struct + public static IEnumerable ToDecimals(this IEnumerable? vals, object? dfltVal = null) { - if (nums.IsNull() || !nums.Any()) + if (vals.IsEmptyOrNull()) { yield break; } - foreach (var num in nums) + foreach (var val in vals) { - yield return num.ToDecimal(); + yield return val.ToDecimal(dfltVal); } } - public static IEnumerable ToDecimal(this IEnumerable strs) + public static IEnumerable ToDecimals(this ICollection? vals, object? dfltVal = null) { - if (strs.IsNull() || !strs.Any()) + if (vals.IsEmptyOrNull()) { yield break; } - foreach (var num in strs) + foreach (var val in vals) { - yield return YANLib.Core.YANNum.ToDecimal(num); + yield return val.ToDecimal(dfltVal); } } - public static IEnumerable ToDecimal(this IEnumerable strs, T dfltVal) where T : struct + public static IEnumerable ToDecimals(this object?[]? vals, object? dfltVal = null) { - if (strs.IsNull() || !strs.Any()) + if (vals.IsEmptyOrNull()) { yield break; } - foreach (var num in strs) + foreach (var val in vals) { - yield return num.ToDecimal(dfltVal); + yield return val.ToDecimal(dfltVal); } } - public static IEnumerable GenerateRandomDecimals(T1 min, T2 max, T size) where T1 : struct where T2 : struct where T : struct + public static IEnumerable GenerateRandomDecimals(object? min = null, object? max = null, object? size = null) { for (var i = 0ul; i < size.ToUlong(); i++) { diff --git a/lib/YANLib/Ultimate/Core/YANNum.Double.cs b/lib/YANLib/Ultimate/Core/YANNum.Double.cs index dc688bb1..f7716697 100644 --- a/lib/YANLib/Ultimate/Core/YANNum.Double.cs +++ b/lib/YANLib/Ultimate/Core/YANNum.Double.cs @@ -4,46 +4,46 @@ namespace YANLib.Ultimate.Core; public static partial class YANNum { - public static IEnumerable ToDouble(this IEnumerable nums) where T : struct + public static IEnumerable ToDoubles(this IEnumerable? vals, object? dfltVal = null) { - if (nums.IsEmptyOrNull()) + if (vals.IsEmptyOrNull()) { yield break; } - foreach (var num in nums) + foreach (var val in vals) { - yield return num.ToDouble(); + yield return val.ToDouble(dfltVal); } } - public static IEnumerable ToDouble(this IEnumerable strs) + public static IEnumerable ToDoubles(this ICollection? vals, object? dfltVal = null) { - if (strs.IsEmptyOrNull()) + if (vals.IsEmptyOrNull()) { yield break; } - foreach (var num in strs) + foreach (var val in vals) { - yield return YANLib.Core.YANNum.ToDouble(num); + yield return val.ToDouble(dfltVal); } } - public static IEnumerable ToDouble(this IEnumerable strs, T dfltVal) where T : struct + public static IEnumerable ToDoubles(this object?[]? vals, object? dfltVal = null) { - if (strs.IsEmptyOrNull()) + if (vals.IsEmptyOrNull()) { yield break; } - foreach (var num in strs) + foreach (var val in vals) { - yield return num.ToDouble(dfltVal); + yield return val.ToDouble(dfltVal); } } - public static IEnumerable GenerateRandomDoubles(T1 min, T2 max, T size) where T1 : struct where T2 : struct where T : struct + public static IEnumerable GenerateRandomDoubles(object? min = null, object? max = null, object? size = null) { for (var i = 0ul; i < size.ToUlong(); i++) { diff --git a/lib/YANLib/Ultimate/Core/YANNum.Float.cs b/lib/YANLib/Ultimate/Core/YANNum.Float.cs index 10694581..55c25fb8 100644 --- a/lib/YANLib/Ultimate/Core/YANNum.Float.cs +++ b/lib/YANLib/Ultimate/Core/YANNum.Float.cs @@ -4,46 +4,46 @@ namespace YANLib.Ultimate.Core; public static partial class YANNum { - public static IEnumerable ToFloat(this IEnumerable nums) where T : struct + public static IEnumerable ToFloats(this IEnumerable? vals, object? dfltVal = null) { - if (nums.IsEmptyOrNull()) + if (vals.IsEmptyOrNull()) { yield break; } - foreach (var num in nums) + foreach (var val in vals) { - yield return num.ToFloat(); + yield return val.ToFloat(dfltVal); } } - public static IEnumerable ToFloat(this IEnumerable strs) + public static IEnumerable ToFloats(this ICollection? vals, object? dfltVal = null) { - if (strs.IsEmptyOrNull()) + if (vals.IsEmptyOrNull()) { yield break; } - foreach (var num in strs) + foreach (var val in vals) { - yield return YANLib.Core.YANNum.ToFloat(num); + yield return val.ToFloat(dfltVal); } } - public static IEnumerable ToFloat(this IEnumerable strs, T dfltVal) where T : struct + public static IEnumerable ToFloats(this object?[]? vals, object? dfltVal = null) { - if (strs.IsEmptyOrNull()) + if (vals.IsEmptyOrNull()) { yield break; } - foreach (var num in strs) + foreach (var val in vals) { - yield return num.ToFloat(dfltVal); + yield return val.ToFloat(dfltVal); } } - public static IEnumerable GenerateRandomFloats(T1 min, T2 max, T size) where T1 : struct where T2 : struct where T : struct + public static IEnumerable GenerateRandomFloats(object? min = null, object? max = null, object? size = null) { for (var i = 0ul; i < size.ToUlong(); i++) { diff --git a/lib/YANLib/Ultimate/Core/YANNum.Int.cs b/lib/YANLib/Ultimate/Core/YANNum.Int.cs new file mode 100644 index 00000000..ec4c2655 --- /dev/null +++ b/lib/YANLib/Ultimate/Core/YANNum.Int.cs @@ -0,0 +1,53 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Core; + +public static partial class YANNum +{ + public static IEnumerable ToInts(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToInt(dfltVal); + } + } + + public static IEnumerable ToInts(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToInt(dfltVal); + } + } + + public static IEnumerable ToInts(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToInt(dfltVal); + } + } + + public static IEnumerable GenerateRandomInts(object? min = null, object? max = null, object? size = null) + { + for (var i = 0ul; i < size.ToUlong(); i++) + { + yield return YANLib.Core.YANNum.GenerateRandomInt(min, max); + } + } +} diff --git a/lib/YANLib/Ultimate/Core/YANNum.Long.cs b/lib/YANLib/Ultimate/Core/YANNum.Long.cs new file mode 100644 index 00000000..a5a235ad --- /dev/null +++ b/lib/YANLib/Ultimate/Core/YANNum.Long.cs @@ -0,0 +1,53 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Core; + +public static partial class YANNum +{ + public static IEnumerable ToLongs(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToLong(dfltVal); + } + } + + public static IEnumerable ToLongs(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToLong(dfltVal); + } + } + + public static IEnumerable ToLongs(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToLong(dfltVal); + } + } + + public static IEnumerable GenerateRandomLongs(object? min = null, object? max = null, object? size = null) + { + for (var i = 0ul; i < size.ToUlong(); i++) + { + yield return YANLib.Core.YANNum.GenerateRandomLong(min, max); + } + } +} diff --git a/lib/YANLib/Ultimate/Core/YANNum.Nint.cs b/lib/YANLib/Ultimate/Core/YANNum.Nint.cs new file mode 100644 index 00000000..627b60dc --- /dev/null +++ b/lib/YANLib/Ultimate/Core/YANNum.Nint.cs @@ -0,0 +1,53 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Core; + +public static partial class YANNum +{ + public static IEnumerable ToNints(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToNint(dfltVal); + } + } + + public static IEnumerable ToNints(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToNint(dfltVal); + } + } + + public static IEnumerable ToNints(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToNint(dfltVal); + } + } + + public static IEnumerable GenerateRandomNints(object? min = null, object? max = null, object? size = null) + { + for (var i = 0ul; i < size.ToUlong(); i++) + { + yield return YANLib.Core.YANNum.GenerateRandomNint(min, max); + } + } +} diff --git a/lib/YANLib/Ultimate/Core/YANNum.Nuint.cs b/lib/YANLib/Ultimate/Core/YANNum.Nuint.cs new file mode 100644 index 00000000..3b6ff313 --- /dev/null +++ b/lib/YANLib/Ultimate/Core/YANNum.Nuint.cs @@ -0,0 +1,53 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Core; + +public static partial class YANNum +{ + public static IEnumerable ToNuints(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToNuint(dfltVal); + } + } + + public static IEnumerable ToNuints(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToNuint(dfltVal); + } + } + + public static IEnumerable ToNuints(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToNuint(dfltVal); + } + } + + public static IEnumerable GenerateRandomNuints(object? min = null, object? max = null, object? size = null) + { + for (var i = 0ul; i < size.ToUlong(); i++) + { + yield return YANLib.Core.YANNum.GenerateRandomNuint(min, max); + } + } +} diff --git a/lib/YANLib/Ultimate/Core/YANNum.Sbyte.cs b/lib/YANLib/Ultimate/Core/YANNum.Sbyte.cs new file mode 100644 index 00000000..66847a9c --- /dev/null +++ b/lib/YANLib/Ultimate/Core/YANNum.Sbyte.cs @@ -0,0 +1,53 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Core; + +public static partial class YANNum +{ + public static IEnumerable ToSbytes(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToSbyte(dfltVal); + } + } + + public static IEnumerable ToSbytes(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToSbyte(dfltVal); + } + } + + public static IEnumerable ToSbytes(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToSbyte(dfltVal); + } + } + + public static IEnumerable GenerateRandomSbytes(object? min = null, object? max = null, object? size = null) + { + for (var i = 0ul; i < size.ToUlong(); i++) + { + yield return YANLib.Core.YANNum.GenerateRandomSbyte(min, max); + } + } +} diff --git a/lib/YANLib/Ultimate/Core/YANNum.Short.cs b/lib/YANLib/Ultimate/Core/YANNum.Short.cs new file mode 100644 index 00000000..1427b6fc --- /dev/null +++ b/lib/YANLib/Ultimate/Core/YANNum.Short.cs @@ -0,0 +1,53 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Core; + +public static partial class YANNum +{ + public static IEnumerable ToShorts(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToShort(dfltVal); + } + } + + public static IEnumerable ToShorts(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToShort(dfltVal); + } + } + + public static IEnumerable ToShorts(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToShort(dfltVal); + } + } + + public static IEnumerable GenerateRandomShorts(object? min = null, object? max = null, object? size = null) + { + for (var i = 0ul; i < size.ToUlong(); i++) + { + yield return YANLib.Core.YANNum.GenerateRandomShort(min, max); + } + } +} diff --git a/lib/YANLib/Ultimate/Core/YANNum.Uint.cs b/lib/YANLib/Ultimate/Core/YANNum.Uint.cs new file mode 100644 index 00000000..86fe093f --- /dev/null +++ b/lib/YANLib/Ultimate/Core/YANNum.Uint.cs @@ -0,0 +1,53 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Core; + +public static partial class YANNum +{ + public static IEnumerable ToUints(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToUint(dfltVal); + } + } + + public static IEnumerable ToUints(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToUint(dfltVal); + } + } + + public static IEnumerable ToUints(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToUint(dfltVal); + } + } + + public static IEnumerable GenerateRandomUints(object? min = null, object? max = null, object? size = null) + { + for (var i = 0ul; i < size.ToUlong(); i++) + { + yield return YANLib.Core.YANNum.GenerateRandomUint(min, max); + } + } +} diff --git a/lib/YANLib/Ultimate/Core/YANNum.Ulong.cs b/lib/YANLib/Ultimate/Core/YANNum.Ulong.cs new file mode 100644 index 00000000..aee753cc --- /dev/null +++ b/lib/YANLib/Ultimate/Core/YANNum.Ulong.cs @@ -0,0 +1,53 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Core; + +public static partial class YANNum +{ + public static IEnumerable ToUlongs(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToUlong(dfltVal); + } + } + + public static IEnumerable ToUlongs(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToUlong(dfltVal); + } + } + + public static IEnumerable ToUlongs(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToUlong(dfltVal); + } + } + + public static IEnumerable GenerateRandomUlongs(object? min = null, object? max = null, object? size = null) + { + for (var i = 0ul; i < size.ToUlong(); i++) + { + yield return YANLib.Core.YANNum.GenerateRandomUlong(min, max); + } + } +} diff --git a/lib/YANLib/Ultimate/Core/YANNum.Ushort.cs b/lib/YANLib/Ultimate/Core/YANNum.Ushort.cs new file mode 100644 index 00000000..5aa3edd2 --- /dev/null +++ b/lib/YANLib/Ultimate/Core/YANNum.Ushort.cs @@ -0,0 +1,53 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Core; + +public static partial class YANNum +{ + public static IEnumerable ToUshorts(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToUshort(dfltVal); + } + } + + public static IEnumerable ToUshorts(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToUshort(dfltVal); + } + } + + public static IEnumerable ToUshorts(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return val.ToUshort(dfltVal); + } + } + + public static IEnumerable GenerateRandomUshorts(object? min = null, object? max = null, object? size = null) + { + for (var i = 0ul; i < size.ToUlong(); i++) + { + yield return YANLib.Core.YANNum.GenerateRandomUshort(min, max); + } + } +} diff --git a/lib/YANLib/Ultimate/Core/YANText.Char.cs b/lib/YANLib/Ultimate/Core/YANText.Char.cs new file mode 100644 index 00000000..687c8bd7 --- /dev/null +++ b/lib/YANLib/Ultimate/Core/YANText.Char.cs @@ -0,0 +1,170 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Core; + +public static partial class YANText +{ + public static IEnumerable GenerateRandomCharacters(object? size) + { + for (var i = 0ul; i < size.ToUlong(); i++) + { + yield return YANLib.Core.YANText.GenerateRandomCharacter(); + } + } + + public static IEnumerable Lowers(this IEnumerable? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return c.Lower(); + } + } + + public static IEnumerable Lowers(this ICollection? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return c.Lower(); + } + } + + public static IEnumerable Lowers(params char[]? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return c.Lower(); + } + } + + public static IEnumerable LowerInvariants(this IEnumerable? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return c.LowerInvariant(); + } + } + + public static IEnumerable LowerInvariants(this ICollection? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return c.LowerInvariant(); + } + } + + public static IEnumerable LowerInvariants(params char[]? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return c.LowerInvariant(); + } + } + + public static IEnumerable Uppers(this IEnumerable? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return c.Upper(); + } + } + + public static IEnumerable Uppers(this ICollection? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return c.Upper(); + } + } + + public static IEnumerable Uppers(params char[]? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return c.Upper(); + } + } + + public static IEnumerable UpperInvariants(this IEnumerable? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return c.UpperInvariant(); + } + } + + public static IEnumerable UpperInvariants(this ICollection? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return c.UpperInvariant(); + } + } + + public static IEnumerable UpperInvariants(params char[]? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return c.UpperInvariant(); + } + } +} diff --git a/lib/YANLib/Ultimate/Core/YANText.String.cs b/lib/YANLib/Ultimate/Core/YANText.String.cs new file mode 100644 index 00000000..90e1530d --- /dev/null +++ b/lib/YANLib/Ultimate/Core/YANText.String.cs @@ -0,0 +1,162 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Core; + +public static partial class YANText +{ + public static IEnumerable Lowers(this IEnumerable? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.Lower(); + } + } + + public static IEnumerable Lowers(this ICollection? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.Lower(); + } + } + + public static IEnumerable Lowers(params string?[]? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.Lower(); + } + } + + public static IEnumerable LowerInvariants(this IEnumerable? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.LowerInvariant(); + } + } + + public static IEnumerable LowerInvariants(this ICollection? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.LowerInvariant(); + } + } + + public static IEnumerable LowerInvariants(params string?[]? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.LowerInvariant(); + } + } + + public static IEnumerable Uppers(this IEnumerable? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.Upper(); + } + } + + public static IEnumerable Uppers(this ICollection? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.Upper(); + } + } + + public static IEnumerable Uppers(params string?[]? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.Upper(); + } + } + + public static IEnumerable UpperInvariants(this IEnumerable? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.UpperInvariant(); + } + } + + public static IEnumerable UpperInvariants(this ICollection? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.UpperInvariant(); + } + } + + public static IEnumerable UpperInvariants(params string?[]? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.UpperInvariant(); + } + } +} diff --git a/lib/YANLib/Ultimate/Core/YANText.cs b/lib/YANLib/Ultimate/Core/YANText.cs new file mode 100644 index 00000000..de67cbec --- /dev/null +++ b/lib/YANLib/Ultimate/Core/YANText.cs @@ -0,0 +1,279 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Core; + +public static partial class YANText +{ + public static IEnumerable Titles(this IEnumerable? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.Title(); + } + } + + public static IEnumerable Titles(this ICollection? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.Title(); + } + } + + public static IEnumerable Titles(params string?[]? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.Title(); + } + } + + public static IEnumerable Capitalizes(this IEnumerable? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.Capitalize(); + } + } + + public static IEnumerable Capitalizes(this ICollection? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.Capitalize(); + } + } + + public static IEnumerable Capitalizes(params string?[]? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.Capitalize(); + } + } + + public static IEnumerable CleanSpaces(this IEnumerable? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.CleanSpace(); + } + } + + public static IEnumerable CleanSpaces(this ICollection? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.CleanSpace(); + } + } + + public static IEnumerable CleanSpaces(params string?[]? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.CleanSpace(); + } + } + + public static IEnumerable FormatNames(this IEnumerable? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.FormatName(); + } + } + + public static IEnumerable FormatNames(this ICollection? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.FormatName(); + } + } + + public static IEnumerable FormatNames(params string?[]? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.FormatName(); + } + } + + public static IEnumerable FilterAlphabetics(this IEnumerable? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.FilterAlphabetic(); + } + } + + public static IEnumerable FilterAlphabetics(this ICollection? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.FilterAlphabetic(); + } + } + + public static IEnumerable FilterAlphabetics(params string?[]? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.FilterAlphabetic(); + } + } + + public static IEnumerable FilterNumbers(this IEnumerable? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.FilterNumber(); + } + } + + public static IEnumerable FilterNumbers(this ICollection? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.FilterNumber(); + } + } + + public static IEnumerable FilterNumbers(params string?[]? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.FilterNumber(); + } + } + + public static IEnumerable FilterAlphanumerics(this IEnumerable? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.FilterAlphanumeric(); + } + } + + public static IEnumerable FilterAlphanumerics(this ICollection? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.FilterAlphanumeric(); + } + } + + public static IEnumerable FilterAlphanumerics(params string?[]? strs) + { + if (strs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var str in strs) + { + yield return str.FilterAlphanumeric(); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Byte.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Byte.cs new file mode 100644 index 00000000..b0e6d008 --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Byte.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable ToBytes(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToByte(val, dfltVal); + } + } + + public static IEnumerable ToBytes(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToByte(val, dfltVal); + } + } + + public static IEnumerable ToBytes(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToByte(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Decimal.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Decimal.cs new file mode 100644 index 00000000..71271f3d --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Decimal.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable ToDecimals(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToDecimal(val, dfltVal); + } + } + + public static IEnumerable ToDecimals(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToDecimal(val, dfltVal); + } + } + + public static IEnumerable ToDecimals(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToDecimal(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Double.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Double.cs new file mode 100644 index 00000000..6f520aa4 --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Double.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable ToDouble(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToDouble(val, dfltVal); + } + } + + public static IEnumerable ToDouble(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToDouble(val, dfltVal); + } + } + + public static IEnumerable ToDouble(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToDouble(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Float.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Float.cs new file mode 100644 index 00000000..3366bf49 --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Float.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable ToFloats(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToFloat(val, dfltVal); + } + } + + public static IEnumerable ToFloats(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToFloat(val, dfltVal); + } + } + + public static IEnumerable ToFloats(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToFloat(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Int.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Int.cs new file mode 100644 index 00000000..a6919921 --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Int.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable ToInts(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToInt(val, dfltVal); + } + } + + public static IEnumerable ToInts(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToInt(val, dfltVal); + } + } + + public static IEnumerable ToInts(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToInt(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Long.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Long.cs new file mode 100644 index 00000000..ece1f59c --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Long.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable ToLongs(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToLong(val, dfltVal); + } + } + + public static IEnumerable ToLongs(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToLong(val, dfltVal); + } + } + + public static IEnumerable ToLongs(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToLong(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Nint.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Nint.cs new file mode 100644 index 00000000..1c7d676b --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Nint.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable ToNints(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToNint(val, dfltVal); + } + } + + public static IEnumerable ToNints(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToNint(val, dfltVal); + } + } + + public static IEnumerable ToNints(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToNint(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Nuint.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Nuint.cs new file mode 100644 index 00000000..16f3125b --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Nuint.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable ToNuints(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToNuint(val, dfltVal); + } + } + + public static IEnumerable ToNuints(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToNuint(val, dfltVal); + } + } + + public static IEnumerable ToNuints(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToNuint(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Sbyte.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Sbyte.cs new file mode 100644 index 00000000..65a12fdb --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Sbyte.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable ToSbytes(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToSbyte(val, dfltVal); + } + } + + public static IEnumerable ToSbytes(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToSbyte(val, dfltVal); + } + } + + public static IEnumerable ToSbytes(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToSbyte(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Short.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Short.cs new file mode 100644 index 00000000..618a58ad --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Short.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable ToShorts(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToShort(val, dfltVal); + } + } + + public static IEnumerable ToShorts(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToShort(val, dfltVal); + } + } + + public static IEnumerable ToShorts(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToShort(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Uint.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Uint.cs new file mode 100644 index 00000000..49bfd5f8 --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Uint.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable ToUints(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToUint(val, dfltVal); + } + } + + public static IEnumerable ToUints(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToUint(val, dfltVal); + } + } + + public static IEnumerable ToUints(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToUint(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Ulong.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Ulong.cs new file mode 100644 index 00000000..188749ca --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Ulong.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable? ToUlongs(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToUlong(val, dfltVal); + } + } + + public static IEnumerable? ToUlongs(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToUlong(val, dfltVal); + } + } + + public static IEnumerable? ToUlongs(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToUlong(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANNum.Ushort.cs b/lib/YANLib/Ultimate/Nullable/YANNum.Ushort.cs new file mode 100644 index 00000000..f7dd6d5e --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANNum.Ushort.cs @@ -0,0 +1,45 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANNum +{ + public static IEnumerable ToUshorts(this IEnumerable? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToUshort(val, dfltVal); + } + } + + public static IEnumerable ToUshorts(this ICollection? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToUshort(val, dfltVal); + } + } + + public static IEnumerable ToUshorts(this object?[]? vals, object? dfltVal = null) + { + if (vals.IsEmptyOrNull()) + { + yield break; + } + + foreach (var val in vals) + { + yield return YANLib.Nullable.YANNum.ToUshort(val, dfltVal); + } + } +} diff --git a/lib/YANLib/Ultimate/Nullable/YANText.Char.cs b/lib/YANLib/Ultimate/Nullable/YANText.Char.cs new file mode 100644 index 00000000..a18ee154 --- /dev/null +++ b/lib/YANLib/Ultimate/Nullable/YANText.Char.cs @@ -0,0 +1,162 @@ +using YANLib.Core; + +namespace YANLib.Ultimate.Nullable; + +public static partial class YANText +{ + public static IEnumerable? Lowers(this IEnumerable? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return YANLib.Nullable.YANText.Lower(c); + } + } + + public static IEnumerable? Lowers(this ICollection? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return YANLib.Nullable.YANText.Lower(c); + } + } + + public static IEnumerable? Lowers(params char?[]? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return YANLib.Nullable.YANText.Lower(c); + } + } + + public static IEnumerable? LowerInvariants(this IEnumerable? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return YANLib.Nullable.YANText.LowerInvariant(c); + } + } + + public static IEnumerable? LowerInvariants(this ICollection? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return YANLib.Nullable.YANText.LowerInvariant(c); + } + } + + public static IEnumerable? LowerInvariants(params char?[]? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return YANLib.Nullable.YANText.LowerInvariant(c); + } + } + + public static IEnumerable? Uppers(this IEnumerable? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return YANLib.Nullable.YANText.Upper(c); + } + } + + public static IEnumerable? Uppers(this ICollection? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return YANLib.Nullable.YANText.Upper(c); + } + } + + public static IEnumerable? Uppers(params char?[]? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return YANLib.Nullable.YANText.Upper(c); + } + } + + public static IEnumerable? UpperInvariants(this IEnumerable? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return YANLib.Nullable.YANText.UpperInvariant(c); + } + } + + public static IEnumerable? UpperInvariants(this ICollection? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return YANLib.Nullable.YANText.UpperInvariant(c); + } + } + + public static IEnumerable? UpperInvariants(params char?[]? cs) + { + if (cs.IsEmptyOrNull()) + { + yield break; + } + + foreach (var c in cs) + { + yield return YANLib.Nullable.YANText.UpperInvariant(c); + } + } +} diff --git a/lib/YANLib/YANLib.csproj b/lib/YANLib/YANLib.csproj index 8fbf497a..9997aead 100644 --- a/lib/YANLib/YANLib.csproj +++ b/lib/YANLib/YANLib.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable ic.ico diff --git a/lib/YANLib/YANPass.cs b/lib/YANLib/YANPass.cs index e513cff7..f81b454c 100644 --- a/lib/YANLib/YANPass.cs +++ b/lib/YANLib/YANPass.cs @@ -1,6 +1,7 @@ using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; +using YANLib.Core; using static System.Convert; using static System.Security.Cryptography.CryptographicOperations; using static System.Security.Cryptography.RandomNumberGenerator; @@ -39,7 +40,7 @@ public class YANPass public bool Verify(string password, string strHash) { - if (strHash.IsNotWhiteSpaceAndNull() && SegmentDelimiter.IsNotEmptyAndWhiteSpace()) + if (strHash.IsNotWhiteSpaceAndNull() && SegmentDelimiter.IsNotWhiteSpaceAndEmpty()) { var segs = strHash.Split(SegmentDelimiter); diff --git a/src/YANLib.Application.Redis/Redis/ConnectionFactory/IRedisConnectionFactory.cs b/src/YANLib.Application.Redis/Redis/ConnectionFactory/IRedisConnectionFactory.cs index f896d6b4..338ba841 100644 --- a/src/YANLib.Application.Redis/Redis/ConnectionFactory/IRedisConnectionFactory.cs +++ b/src/YANLib.Application.Redis/Redis/ConnectionFactory/IRedisConnectionFactory.cs @@ -1,6 +1,4 @@ -using StackExchange.Redis; - -namespace YANLib.Application.Redis.ConnectionFactory; +namespace YANLib.Application.Redis.ConnectionFactory; public interface IRedisConnectionFactory { diff --git a/src/YANLib.Application.Redis/Redis/ConnectionFactory/Implements/RedisConnectionFactory.cs b/src/YANLib.Application.Redis/Redis/ConnectionFactory/Implements/RedisConnectionFactory.cs index 54c437e0..62d63d92 100644 --- a/src/YANLib.Application.Redis/Redis/ConnectionFactory/Implements/RedisConnectionFactory.cs +++ b/src/YANLib.Application.Redis/Redis/ConnectionFactory/Implements/RedisConnectionFactory.cs @@ -1,9 +1,4 @@ -using Microsoft.Extensions.Options; -using StackExchange.Redis; -using Volo.Abp.DependencyInjection; -using static StackExchange.Redis.ConnectionMultiplexer; - -namespace YANLib.Application.Redis.ConnectionFactory.Implements; +namespace YANLib.Application.Redis.ConnectionFactory.Implements; public class RedisConnectionFactory : IRedisConnectionFactory, ISingletonDependency { diff --git a/src/YANLib.Application.Redis/Services/IRedisService.cs b/src/YANLib.Application.Redis/Services/IRedisService.cs index b8ea2647..135e6ad1 100644 --- a/src/YANLib.Application.Redis/Services/IRedisService.cs +++ b/src/YANLib.Application.Redis/Services/IRedisService.cs @@ -1,6 +1,4 @@ -using Volo.Abp.Application.Services; - -namespace YANLib.Application.Redis.Services; +namespace YANLib.Application.Redis.Services; public interface IRedisService : IApplicationService { diff --git a/src/YANLib.Application.Redis/Services/Implements/DeveloperTypeRedisService.cs b/src/YANLib.Application.Redis/Services/Implements/DeveloperTypeRedisService.cs index 0c731ca6..77910f4b 100644 --- a/src/YANLib.Application.Redis/Services/Implements/DeveloperTypeRedisService.cs +++ b/src/YANLib.Application.Redis/Services/Implements/DeveloperTypeRedisService.cs @@ -1,13 +1,4 @@ -using Microsoft.Extensions.Logging; -using StackExchange.Redis; -using Volo.Abp; -using YANLib.Application.Redis.ConnectionFactory; -using YANLib.Core; -using YANLib.RedisDtos; -using static System.Text.Encoding; -using static System.Threading.Tasks.Task; -using static YANLib.YANLibConsts.RedisConstant; -using static YANLib.YANLibDomainErrorCodes; +using YANLib.Application.Redis.ConnectionFactory; namespace YANLib.Application.Redis.Services.Implements; diff --git a/src/YANLib.Application.Redis/YANLibApplicationRedisModule.cs b/src/YANLib.Application.Redis/YANLibApplicationRedisModule.cs index bea1f28d..b0d143de 100644 --- a/src/YANLib.Application.Redis/YANLibApplicationRedisModule.cs +++ b/src/YANLib.Application.Redis/YANLibApplicationRedisModule.cs @@ -1,10 +1,6 @@ -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp; -using Volo.Abp.Modularity; -using YANLib.Application.Redis.ConnectionFactory; +using YANLib.Application.Redis.ConnectionFactory; using YANLib.Application.Redis.Services; using YANLib.Application.Redis.Services.Implements; -using YANLib.RedisDtos; namespace YANLib.Application.Redis; diff --git a/src/YANLib.Application/EsServices/DeveloperEsService.cs b/src/YANLib.Application/EsServices/DeveloperEsService.cs index 33a0dcea..cbe8b691 100644 --- a/src/YANLib.Application/EsServices/DeveloperEsService.cs +++ b/src/YANLib.Application/EsServices/DeveloperEsService.cs @@ -1,15 +1,4 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; -using Nest; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using YANLib.Core; -using YANLib.EsIndices; -using YANLib.Utilities; -using static System.Threading.Tasks.Task; -using static YANLib.YANLibConsts.ElasticsearchIndex; +using YANLib.Utilities; namespace YANLib.EsServices; diff --git a/src/YANLib.Application/Handlers/AdjustCertificateHandler.cs b/src/YANLib.Application/Handlers/AdjustCertificateHandler.cs index 84b81ab6..fb25bd33 100644 --- a/src/YANLib.Application/Handlers/AdjustCertificateHandler.cs +++ b/src/YANLib.Application/Handlers/AdjustCertificateHandler.cs @@ -1,12 +1,4 @@ -using Microsoft.Extensions.Logging; -using System.Threading.Tasks; -using Volo.Abp.EventBus.Distributed; -using YANLib.Core; -using YANLib.RabbitMq.Etos; -using YANLib.Requests; -using YANLib.Services; - -namespace YANLib.Handlers; +namespace YANLib.Handlers; public class AdjustCertificateHandler( ILogger logger, diff --git a/src/YANLib.Application/Mappers/CertificateMapper.cs b/src/YANLib.Application/Mappers/CertificateMapper.cs index 681d6c6f..176c85c7 100644 --- a/src/YANLib.Application/Mappers/CertificateMapper.cs +++ b/src/YANLib.Application/Mappers/CertificateMapper.cs @@ -1,12 +1,4 @@ -using AutoMapper; -using Volo.Abp.AutoMapper; -using YANLib.Entities; -using YANLib.Kafka.Etos; -using YANLib.RabbitMq.Etos; -using YANLib.Requests; -using YANLib.Responses; - -namespace YANLib.Mappers; +namespace YANLib.Mappers; public sealed class CertificateMapper : Profile { diff --git a/src/YANLib.Application/Mappers/DeveloperMapper.cs b/src/YANLib.Application/Mappers/DeveloperMapper.cs index dd32f443..e9ea9730 100644 --- a/src/YANLib.Application/Mappers/DeveloperMapper.cs +++ b/src/YANLib.Application/Mappers/DeveloperMapper.cs @@ -1,11 +1,4 @@ -using AutoMapper; -using Volo.Abp.AutoMapper; -using YANLib.Entities; -using YANLib.EsIndices; -using YANLib.Requests.Developer; -using YANLib.Responses; - -namespace YANLib.Mappers; +namespace YANLib.Mappers; public sealed class DeveloperMapper : Profile { diff --git a/src/YANLib.Application/Mappers/DeveloperTypeMapper.cs b/src/YANLib.Application/Mappers/DeveloperTypeMapper.cs index e9539138..f644fb2d 100644 --- a/src/YANLib.Application/Mappers/DeveloperTypeMapper.cs +++ b/src/YANLib.Application/Mappers/DeveloperTypeMapper.cs @@ -1,12 +1,4 @@ -using AutoMapper; -using System.Collections.Generic; -using Volo.Abp.AutoMapper; -using YANLib.Entities; -using YANLib.RedisDtos; -using YANLib.Requests.DeveloperType; -using YANLib.Responses; - -namespace YANLib.Mappers; +namespace YANLib.Mappers; public sealed class DeveloperTypeMapper : Profile { diff --git a/src/YANLib.Application/Services/CertificateService.cs b/src/YANLib.Application/Services/CertificateService.cs index 75676fcf..041420e8 100644 --- a/src/YANLib.Application/Services/CertificateService.cs +++ b/src/YANLib.Application/Services/CertificateService.cs @@ -1,12 +1,4 @@ -using Microsoft.Extensions.Logging; -using System; -using System.Threading.Tasks; -using YANLib.Core; -using YANLib.Entities; -using YANLib.Repositories; -using YANLib.Requests; - -namespace YANLib.Services; +namespace YANLib.Services; public class CertificateService( ILogger logger, diff --git a/src/YANLib.Application/Services/DeveloperService.cs b/src/YANLib.Application/Services/DeveloperService.cs index e3f695b2..4c8798f8 100644 --- a/src/YANLib.Application/Services/DeveloperService.cs +++ b/src/YANLib.Application/Services/DeveloperService.cs @@ -1,30 +1,4 @@ -using DotNetCore.CAP; -using Id_Generator_Snowflake; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Volo.Abp; -using Volo.Abp.EventBus.Distributed; -using YANLib.Core; -using YANLib.Entities; -using YANLib.EsIndices; -using YANLib.EsServices; -using YANLib.Kafka.Etos; -using YANLib.RabbitMq.Etos; -using YANLib.Repositories; -using YANLib.Requests.Developer; -using YANLib.Responses; -using static System.DateTime; -using static System.Threading.Tasks.Task; -using static YANLib.Kafka.KafkaTopic; -using static YANLib.YANLibConsts.SnowflakeId.DatacenterId; -using static YANLib.YANLibConsts.SnowflakeId.WorkerId; -using static YANLib.YANLibDomainErrorCodes; - -namespace YANLib.Services; +namespace YANLib.Services; public class DeveloperService( ILogger logger, diff --git a/src/YANLib.Application/Services/DeveloperTypeService.cs b/src/YANLib.Application/Services/DeveloperTypeService.cs index d0efa41d..112a022b 100644 --- a/src/YANLib.Application/Services/DeveloperTypeService.cs +++ b/src/YANLib.Application/Services/DeveloperTypeService.cs @@ -1,22 +1,4 @@ -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Volo.Abp; -using Volo.Abp.Domain.Repositories; -using YANLib.Application.Redis.Services; -using YANLib.Core; -using YANLib.Entities; -using YANLib.RedisDtos; -using YANLib.Requests.DeveloperType; -using YANLib.Responses; -using static System.DateTime; -using static System.Threading.Tasks.Task; -using static YANLib.YANLibConsts.RedisConstant; -using static YANLib.YANLibDomainErrorCodes; - -namespace YANLib.Services; +namespace YANLib.Services; public class DeveloperTypeService( ILogger logger, diff --git a/src/YANLib.Application/Services/YANJsonService.cs b/src/YANLib.Application/Services/YANJsonService.cs index be6aed49..09422936 100644 --- a/src/YANLib.Application/Services/YANJsonService.cs +++ b/src/YANLib.Application/Services/YANJsonService.cs @@ -1,16 +1,4 @@ -using System; -using System.Diagnostics; -using System.Text.Json; -using System.Threading.Tasks; -using Volo.Abp.Json; -using YANLib.Core; -using YANLib.Responses; -using static Newtonsoft.Json.JsonConvert; -using static System.Guid; -using static System.Text.Json.JsonSerializer; -using static System.Threading.Tasks.Task; - -namespace YANLib.Services; +namespace YANLib.Services; public class YANJsonService(IJsonSerializer jsonSerializer) : YANLibAppService, IYANJsonService { diff --git a/src/YANLib.Application/Subscribers/CreateCertificateSubscriber.cs b/src/YANLib.Application/Subscribers/CreateCertificateSubscriber.cs index 659bfb9b..5f5ed92e 100644 --- a/src/YANLib.Application/Subscribers/CreateCertificateSubscriber.cs +++ b/src/YANLib.Application/Subscribers/CreateCertificateSubscriber.cs @@ -1,13 +1,4 @@ -using DotNetCore.CAP; -using Microsoft.Extensions.Logging; -using System.Threading.Tasks; -using YANLib.Core; -using YANLib.Kafka.Etos; -using YANLib.Requests; -using YANLib.Services; -using static YANLib.Kafka.KafkaTopic; - -namespace YANLib.Subscribers; +namespace YANLib.Subscribers; public class CreateCertificateSubscriber( ILogger logger, diff --git a/src/YANLib.Application/Utilities/ElasticsearchUtil.cs b/src/YANLib.Application/Utilities/ElasticsearchUtil.cs index 907fcea7..3b105aae 100644 --- a/src/YANLib.Application/Utilities/ElasticsearchUtil.cs +++ b/src/YANLib.Application/Utilities/ElasticsearchUtil.cs @@ -1,15 +1,4 @@ -using Elasticsearch.Net; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Nest; -using System; -using System.Linq; -using YANLib.EsIndices; -using static Elasticsearch.Net.CertificateValidations; -using static System.TimeSpan; -using static YANLib.YANLibConsts.ElasticsearchIndex; - -namespace YANLib.Utilities; +namespace YANLib.Utilities; public static class ElasticsearchUtil { diff --git a/src/YANLib.Application/Validations/CertificateValidation.cs b/src/YANLib.Application/Validations/CertificateValidation.cs index ecc3faa4..2ab86ccf 100644 --- a/src/YANLib.Application/Validations/CertificateValidation.cs +++ b/src/YANLib.Application/Validations/CertificateValidation.cs @@ -1,11 +1,4 @@ -using FluentValidation; -using System.Collections.Generic; -using System.Linq; -using YANLib.Core; -using YANLib.Requests; -using static YANLib.YANLibDomainErrorCodes; - -namespace YANLib.Validations; +namespace YANLib.Validations; public sealed class CertificateValidator : AbstractValidator { diff --git a/src/YANLib.Application/Validations/DeveloperTypeValidation.cs b/src/YANLib.Application/Validations/DeveloperTypeValidation.cs index 74707c79..2bc2c46e 100644 --- a/src/YANLib.Application/Validations/DeveloperTypeValidation.cs +++ b/src/YANLib.Application/Validations/DeveloperTypeValidation.cs @@ -1,11 +1,4 @@ -using FluentValidation; -using System.Collections.Generic; -using System.Linq; -using YANLib.Core; -using YANLib.Requests.DeveloperType; -using static YANLib.YANLibDomainErrorCodes; - -namespace YANLib.Validations; +namespace YANLib.Validations; public sealed class DeveloperTypeCreateValidator : AbstractValidator { diff --git a/src/YANLib.Application/Validations/DeveloperValidation.cs b/src/YANLib.Application/Validations/DeveloperValidation.cs index 5e5c3021..ee3f5afa 100644 --- a/src/YANLib.Application/Validations/DeveloperValidation.cs +++ b/src/YANLib.Application/Validations/DeveloperValidation.cs @@ -1,11 +1,4 @@ -using FluentValidation; -using System.Collections.Generic; -using System.Linq; -using YANLib.Core; -using YANLib.Requests.Developer; -using static YANLib.YANLibDomainErrorCodes; - -namespace YANLib.Validations; +namespace YANLib.Validations; public sealed class DeveloperCreateValidator : AbstractValidator { diff --git a/src/YANLib.Application/Validations/SampleValidation.cs b/src/YANLib.Application/Validations/SampleValidation.cs index 4f96dbc6..08c18e1d 100644 --- a/src/YANLib.Application/Validations/SampleValidation.cs +++ b/src/YANLib.Application/Validations/SampleValidation.cs @@ -1,10 +1,4 @@ -using FluentValidation; -using System.Collections.Generic; -using YANLib.Core; -using YANLib.Responses; -using static YANLib.YANLibDomainErrorCodes; - -namespace YANLib.Validations; +namespace YANLib.Validations; public sealed class SampleValidator : AbstractValidator { diff --git a/src/YANLib.Application/YANLibAppService.cs b/src/YANLib.Application/YANLibAppService.cs index be9b4a94..b882d783 100644 --- a/src/YANLib.Application/YANLibAppService.cs +++ b/src/YANLib.Application/YANLibAppService.cs @@ -1,7 +1,4 @@ -using Volo.Abp.Application.Services; -using YANLib.Localization; - -namespace YANLib; +namespace YANLib; public abstract class YANLibAppService : ApplicationService { diff --git a/src/YANLib.Application/YANLibApplicationAutoMapperProfile.cs b/src/YANLib.Application/YANLibApplicationAutoMapperProfile.cs index a3498faa..2a155c96 100644 --- a/src/YANLib.Application/YANLibApplicationAutoMapperProfile.cs +++ b/src/YANLib.Application/YANLibApplicationAutoMapperProfile.cs @@ -1,8 +1,4 @@ -using AutoMapper; -using YANLib.Entities; -using YANLib.Requests.Developer; - -namespace YANLib; +namespace YANLib; public class YANLibApplicationAutoMapperProfile : Profile { diff --git a/src/YANLib.Application/YANLibApplicationModule.cs b/src/YANLib.Application/YANLibApplicationModule.cs index 4962c7e0..72d2e819 100644 --- a/src/YANLib.Application/YANLibApplicationModule.cs +++ b/src/YANLib.Application/YANLibApplicationModule.cs @@ -1,10 +1,4 @@ -using Volo.Abp.Application; -using Volo.Abp.AutoMapper; -using Volo.Abp.FluentValidation; -using Volo.Abp.Modularity; -using YANLib.Application.Redis; - -namespace YANLib; +namespace YANLib; [DependsOn( typeof(YANLibDomainModule), diff --git a/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/DbContext/IYANLibDbContext.cs b/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/DbContext/IYANLibDbContext.cs index b41108f2..b10df06b 100644 --- a/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/DbContext/IYANLibDbContext.cs +++ b/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/DbContext/IYANLibDbContext.cs @@ -1,10 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Data; -using Volo.Abp.EntityFrameworkCore; -using YANLib.Entities; -using static YANLib.YANLibConsts.ConnectionStringName; - -namespace YANLib.EntityFrameworkCore.DbContext; +namespace YANLib.EntityFrameworkCore.DbContext; [ConnectionStringName(Default)] public interface IYANLibDbContext : IEfCoreDbContext diff --git a/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/DbContext/Implements/YANLibDbContext.cs b/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/DbContext/Implements/YANLibDbContext.cs index 97168f1f..8f13c06b 100644 --- a/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/DbContext/Implements/YANLibDbContext.cs +++ b/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/DbContext/Implements/YANLibDbContext.cs @@ -1,11 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Data; -using Volo.Abp.EntityFrameworkCore; -using YANLib.Entities; -using static YANLib.YANLibConsts.ConnectionStringName; -using static YANLib.YANLibConsts.DbSchema; - -namespace YANLib.EntityFrameworkCore.DbContext.Implements; +namespace YANLib.EntityFrameworkCore.DbContext.Implements; [ConnectionStringName(Default)] public class YANLibDbContext(DbContextOptions options) : AbpDbContext(options), IYANLibDbContext diff --git a/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/YANLibDbContextModelCreatingExtensions.cs b/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/YANLibDbContextModelCreatingExtensions.cs index ebfd4881..98e08712 100644 --- a/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/YANLibDbContextModelCreatingExtensions.cs +++ b/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/YANLibDbContextModelCreatingExtensions.cs @@ -1,7 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using static Volo.Abp.Check; - -namespace YANLib.EntityFrameworkCore; +namespace YANLib.EntityFrameworkCore; public static class YANLibDbContextModelCreatingExtensions { diff --git a/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/YANLibEntityFrameworkCoreModule.cs b/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/YANLibEntityFrameworkCoreModule.cs index 65b8ac77..ad2fbed4 100644 --- a/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/YANLibEntityFrameworkCoreModule.cs +++ b/src/YANLib.EntityFrameworkCore/EntityFrameworkCore/YANLibEntityFrameworkCoreModule.cs @@ -1,8 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.EntityFrameworkCore; -using Volo.Abp.Modularity; -using YANLib.Entities; -using YANLib.EntityFrameworkCore.DbContext.Implements; +using YANLib.EntityFrameworkCore.DbContext.Implements; namespace YANLib.EntityFrameworkCore; diff --git a/src/YANLib.EntityFrameworkCore/Repositories/CertificateRepository.cs b/src/YANLib.EntityFrameworkCore/Repositories/CertificateRepository.cs index 76ec98e4..4a77b35c 100644 --- a/src/YANLib.EntityFrameworkCore/Repositories/CertificateRepository.cs +++ b/src/YANLib.EntityFrameworkCore/Repositories/CertificateRepository.cs @@ -1,13 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using YANLib.Core; -using YANLib.Entities; -using YANLib.EntityFrameworkCore.DbContext; -using static System.DateTime; +using YANLib.EntityFrameworkCore.DbContext; namespace YANLib.Repositories; diff --git a/src/YANLib.EntityFrameworkCore/Repositories/DeveloperRepository.cs b/src/YANLib.EntityFrameworkCore/Repositories/DeveloperRepository.cs index f2244de0..98ce72cb 100644 --- a/src/YANLib.EntityFrameworkCore/Repositories/DeveloperRepository.cs +++ b/src/YANLib.EntityFrameworkCore/Repositories/DeveloperRepository.cs @@ -1,13 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using YANLib.Core; -using YANLib.Entities; -using YANLib.EntityFrameworkCore.DbContext; -using static System.DateTime; +using YANLib.EntityFrameworkCore.DbContext; namespace YANLib.Repositories; diff --git a/src/YANLib.HttpApi/Controllers/DeveloperController.cs b/src/YANLib.HttpApi/Controllers/DeveloperController.cs index 9c38ecd6..a29643a0 100644 --- a/src/YANLib.HttpApi/Controllers/DeveloperController.cs +++ b/src/YANLib.HttpApi/Controllers/DeveloperController.cs @@ -1,14 +1,4 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Swashbuckle.AspNetCore.Annotations; -using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; -using Volo.Abp; -using YANLib.Core; -using YANLib.Requests.Developer; -using YANLib.Services; - -namespace YANLib.Controllers; +namespace YANLib.Controllers; [RemoteService] [ApiExplorerSettings(GroupName = "sample")] diff --git a/src/YANLib.HttpApi/Controllers/DeveloperTypeController.cs b/src/YANLib.HttpApi/Controllers/DeveloperTypeController.cs index c80d3191..7c072186 100644 --- a/src/YANLib.HttpApi/Controllers/DeveloperTypeController.cs +++ b/src/YANLib.HttpApi/Controllers/DeveloperTypeController.cs @@ -1,14 +1,4 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Swashbuckle.AspNetCore.Annotations; -using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; -using Volo.Abp; -using YANLib.Core; -using YANLib.Requests.DeveloperType; -using YANLib.Services; - -namespace YANLib.Controllers; +namespace YANLib.Controllers; [RemoteService] [ApiExplorerSettings(GroupName = "sample")] diff --git a/src/YANLib.HttpApi/Controllers/ElasticsearchController.cs b/src/YANLib.HttpApi/Controllers/ElasticsearchController.cs index 567583f1..2ff33ceb 100644 --- a/src/YANLib.HttpApi/Controllers/ElasticsearchController.cs +++ b/src/YANLib.HttpApi/Controllers/ElasticsearchController.cs @@ -1,14 +1,4 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Swashbuckle.AspNetCore.Annotations; -using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; -using Volo.Abp; -using YANLib.Core; -using YANLib.EsIndices; -using YANLib.EsServices; - -namespace YANLib.Controllers; +namespace YANLib.Controllers; [RemoteService] [ApiExplorerSettings(GroupName = "sample")] diff --git a/src/YANLib.HttpApi/Controllers/IdSnowflakeController.cs b/src/YANLib.HttpApi/Controllers/IdSnowflakeController.cs index 3563c675..7fbff734 100644 --- a/src/YANLib.HttpApi/Controllers/IdSnowflakeController.cs +++ b/src/YANLib.HttpApi/Controllers/IdSnowflakeController.cs @@ -1,11 +1,4 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Swashbuckle.AspNetCore.Annotations; -using System.ComponentModel.DataAnnotations; -using Volo.Abp; -using static Id_Generator_Snowflake.IdGenerator; - -namespace YANLib.Controllers; +namespace YANLib.Controllers; [RemoteService] [ApiExplorerSettings(GroupName = "test")] diff --git a/src/YANLib.HttpApi/Controllers/YANJsonController.cs b/src/YANLib.HttpApi/Controllers/YANJsonController.cs index a2149f00..7df02f66 100644 --- a/src/YANLib.HttpApi/Controllers/YANJsonController.cs +++ b/src/YANLib.HttpApi/Controllers/YANJsonController.cs @@ -1,13 +1,4 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Swashbuckle.AspNetCore.Annotations; -using System; -using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; -using Volo.Abp; -using YANLib.Services; - -namespace YANLib.Controllers; +namespace YANLib.Controllers; [RemoteService] [ApiExplorerSettings(GroupName = "test")] diff --git a/src/YANLib.HttpApi/YANLibController.cs b/src/YANLib.HttpApi/YANLibController.cs index d9ddd865..58352f1b 100644 --- a/src/YANLib.HttpApi/YANLibController.cs +++ b/src/YANLib.HttpApi/YANLibController.cs @@ -1,7 +1,4 @@ -using Volo.Abp.AspNetCore.Mvc; -using YANLib.Localization; - -namespace YANLib; +namespace YANLib; public abstract class YANLibController : AbpControllerBase { diff --git a/src/YANLib.HttpApi/YANLibHttpApiModule.cs b/src/YANLib.HttpApi/YANLibHttpApiModule.cs index 57098303..df5fbc6c 100644 --- a/src/YANLib.HttpApi/YANLibHttpApiModule.cs +++ b/src/YANLib.HttpApi/YANLibHttpApiModule.cs @@ -1,10 +1,4 @@ -using Localization.Resources.AbpUi; -using Volo.Abp.AspNetCore.Mvc; -using Volo.Abp.Localization; -using Volo.Abp.Modularity; -using YANLib.Localization; - -namespace YANLib; +namespace YANLib; [DependsOn( typeof(YANLibApplicationContractsModule),