diff --git a/console/YANLib.Benchmarks/YANLib.Benchmarks.csproj b/console/YANLib.Benchmarks/YANLib.Benchmarks.csproj
index 09466ba..c346cb2 100644
--- a/console/YANLib.Benchmarks/YANLib.Benchmarks.csproj
+++ b/console/YANLib.Benchmarks/YANLib.Benchmarks.csproj
@@ -1,19 +1,19 @@
-
- Exe
- net6.0
- enable
- enable
-
+
+ Exe
+ net6.0
+ enable
+ enable
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
diff --git a/database/YANLIB.sql b/database/YANLIB.sql
new file mode 100644
index 0000000..0fceaac
--- /dev/null
+++ b/database/YANLIB.sql
@@ -0,0 +1,38 @@
+CREATE DATABASE YANLIB;
+
+USE YANLIB;
+
+CREATE SCHEMA sample;
+
+CREATE TABLE sample.DeveloperTypes
+(
+ Code INT PRIMARY KEY NOT NULL,
+ Name NVARCHAR(100) NOT NULL,
+ IsActive BIT NOT NULL,
+ CreatedDate DATETIME NOT NULL,
+ ModifiedDate DATETIME
+);
+
+CREATE TABLE sample.Developers
+(
+ Id VARCHAR(20) PRIMARY KEY NOT NULL,
+ Name NVARCHAR(100) NOT NULL,
+ Phone VARCHAR(20),
+ IdCard VARCHAR(20) NOT NULL,
+ DeveloperTypeCode INT NOT NULL,
+ IsActive BIT NOT NULL,
+ Version INT NOT NULL,
+ CreatedDate DATETIME NOT NULL,
+ ModifiedDate DATETIME,
+ FOREIGN KEY (DeveloperTypeCode) REFERENCES sample.DeveloperTypes(Code)
+);
+
+CREATE TABLE sample.Certificates
+(
+ Id VARCHAR(20) PRIMARY KEY NOT NULL,
+ Name NVARCHAR(100) NOT NULL,
+ GPA DOUBLE PRECISION,
+ DeveloperId VARCHAR(20),
+ CreatedDate DATETIME NOT NULL,
+ ModifiedDate DATETIME
+);
diff --git a/docker-compose.dcproj b/docker-compose.dcproj
index 968c7b3..f8b0df7 100644
--- a/docker-compose.dcproj
+++ b/docker-compose.dcproj
@@ -18,6 +18,9 @@
+
+
+
diff --git a/docker-compose.yml b/docker-compose.yml
index c020658..aab161a 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -107,7 +107,7 @@ services:
depends_on:
- elasticsearch
restart: unless-stopped
-
+
rabbitmq:
image: rabbitmq:3-management
container_name: rabbitmq
@@ -119,8 +119,6 @@ services:
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS:-}
networks:
- yan
- depends_on:
- - logstash
restart: unless-stopped
zookeeper:
@@ -132,8 +130,6 @@ services:
- ALLOW_ANONYMOUS_LOGIN=yes
networks:
- yan
- depends_on:
- - logstash
restart: unless-stopped
kafka:
@@ -183,6 +179,7 @@ networks:
volumes:
setup:
elasticsearch:
+ es-ingest:
# Run with
# docker-compose \
diff --git a/es-ingest/.dockerignore b/es-ingest/.dockerignore
new file mode 100644
index 0000000..37eef9d
--- /dev/null
+++ b/es-ingest/.dockerignore
@@ -0,0 +1,6 @@
+# Ignore Docker build files
+Dockerfile
+.dockerignore
+
+# Ignore OS artifacts
+**/.DS_Store
diff --git a/es-ingest/Dockerfile b/es-ingest/Dockerfile
new file mode 100644
index 0000000..22528c6
--- /dev/null
+++ b/es-ingest/Dockerfile
@@ -0,0 +1,7 @@
+ARG ELASTIC_VERSION
+
+# https://www.docker.elastic.co/
+FROM docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION}
+
+# Add your elasticsearch plugins setup here
+# Example: RUN elasticsearch-plugin install analysis-icu
diff --git a/es-ingest/config/elasticsearch.yml b/es-ingest/config/elasticsearch.yml
new file mode 100644
index 0000000..edebb87
--- /dev/null
+++ b/es-ingest/config/elasticsearch.yml
@@ -0,0 +1,18 @@
+---
+## Default Elasticsearch configuration from Elasticsearch base image.
+## https://github.com/elastic/elasticsearch/blob/main/distribution/docker/src/docker/config/elasticsearch.yml
+#
+cluster.name: docker-cluster-neo
+network.host: 0.0.0.0
+
+## X-Pack settings
+## see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-settings.html
+#
+xpack.license.self_generated.type: trial
+xpack.security.enabled: true
+
+# server.publicBaseUrl: https://my-elasticsearch-cluster.example.com
+
+## Set the built-in users' passwords.
+# Run the following command from the Elasticsearch directory:
+# ./bin/elasticsearch-setup-passwords interactive
diff --git a/extensions/curator/curator-compose.yml b/extensions/curator/curator-compose.yml
index fc137e6..65ae2ba 100644
--- a/extensions/curator/curator-compose.yml
+++ b/extensions/curator/curator-compose.yml
@@ -4,10 +4,11 @@ services:
curator:
build:
context: extensions/curator/
+ container_name: curator
init: true
volumes:
- - ./config/curator.yml:/.curator/curator.yml:ro,Z
- - ./config/delete_log_files_curator.yml:/.curator/delete_log_files_curator.yml:ro,Z
+ - ./extensions/curator/config/curator.yml:/.curator/curator.yml:ro,Z
+ - ./extensions/curator/config/delete_log_files_curator.yml:/.curator/delete_log_files_curator.yml:ro,Z
environment:
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD:-}
networks:
diff --git a/extensions/enterprise-search/config/enterprise-search.yml b/extensions/enterprise-search/config/enterprise-search.yml
index a1f098d..a1beab2 100644
--- a/extensions/enterprise-search/config/enterprise-search.yml
+++ b/extensions/enterprise-search/config/enterprise-search.yml
@@ -6,7 +6,7 @@
## --------------------- REQUIRED ---------------------
# Encryption keys to protect application secrets.
-secret_management.encryption_keys:
+secret_management.encryption_keys: [680f94e568c90364bedf927b2f0f49609702d3eab9098688585a375b14274546]
# example:
#- 680f94e568c90364bedf927b2f0f49609702d3eab9098688585a375b14274546
diff --git a/extensions/enterprise-search/enterprise-search-compose.yml b/extensions/enterprise-search/enterprise-search-compose.yml
index c4d422d..3b11d2e 100644
--- a/extensions/enterprise-search/enterprise-search-compose.yml
+++ b/extensions/enterprise-search/enterprise-search-compose.yml
@@ -6,8 +6,9 @@ services:
context: extensions/enterprise-search/
args:
ELASTIC_VERSION: ${ELASTIC_VERSION}
+ container_name: enterprise-search
volumes:
- - ./config/enterprise-search.yml:/usr/share/enterprise-search/config/enterprise-search.yml:ro,Z
+ - ./extensions/enterprise-search/config/enterprise-search.yml:/usr/share/enterprise-search/config/enterprise-search.yml:ro,Z
environment:
JAVA_OPTS: -Xms2g -Xmx2g
ENT_SEARCH_DEFAULT_PASSWORD: 'changeme'
diff --git a/extensions/filebeat/filebeat-compose.yml b/extensions/filebeat/filebeat-compose.yml
index 84e3d1b..2eb56c1 100644
--- a/extensions/filebeat/filebeat-compose.yml
+++ b/extensions/filebeat/filebeat-compose.yml
@@ -8,6 +8,7 @@ services:
ELASTIC_VERSION: ${ELASTIC_VERSION}
# Run as 'root' instead of 'filebeat' (uid 1000) to allow reading
# 'docker.sock' and the host's filesystem.
+ container_name: filebeat
user: root
command:
# Log to stderr.
@@ -17,7 +18,7 @@ services:
# see: https://www.elastic.co/guide/en/beats/libbeat/current/config-file-permissions.html
- --strict.perms=false
volumes:
- - ./config/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro,Z
+ - ./extensions/filebeat/config/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro,Z
- type: bind
source: /var/lib/docker/containers
target: /var/lib/docker/containers
diff --git a/extensions/fleet/agent-apmserver-compose.yml b/extensions/fleet/agent-apmserver-compose.yml
index 0cda861..4d338ba 100644
--- a/extensions/fleet/agent-apmserver-compose.yml
+++ b/extensions/fleet/agent-apmserver-compose.yml
@@ -10,6 +10,7 @@ services:
context: extensions/fleet/
args:
ELASTIC_VERSION: ${ELASTIC_VERSION}
+ container_name: apm-server
volumes:
- apm-server:/usr/share/elastic-agent/state:Z
environment:
diff --git a/extensions/fleet/fleet-compose.yml b/extensions/fleet/fleet-compose.yml
index 89a3ebc..61369e5 100644
--- a/extensions/fleet/fleet-compose.yml
+++ b/extensions/fleet/fleet-compose.yml
@@ -6,6 +6,7 @@ services:
context: extensions/fleet/
args:
ELASTIC_VERSION: ${ELASTIC_VERSION}
+ container_name: fleet-server
volumes:
- fleet-server:/usr/share/elastic-agent/state:Z
environment:
diff --git a/extensions/heartbeat/heartbeat-compose.yml b/extensions/heartbeat/heartbeat-compose.yml
index 6ad85c8..e31d6b7 100644
--- a/extensions/heartbeat/heartbeat-compose.yml
+++ b/extensions/heartbeat/heartbeat-compose.yml
@@ -6,6 +6,7 @@ services:
context: extensions/heartbeat/
args:
ELASTIC_VERSION: ${ELASTIC_VERSION}
+ container_name: heartbeat
command:
# Log to stderr.
- -e
@@ -14,7 +15,7 @@ services:
# see: https://www.elastic.co/guide/en/beats/libbeat/current/config-file-permissions.html
- --strict.perms=false
volumes:
- - ./config/heartbeat.yml:/usr/share/heartbeat/heartbeat.yml:ro,Z
+ - ./extensions/heartbeat/config/heartbeat.yml:/usr/share/heartbeat/heartbeat.yml:ro,Z
environment:
HEARTBEAT_INTERNAL_PASSWORD: ${HEARTBEAT_INTERNAL_PASSWORD:-}
BEATS_SYSTEM_PASSWORD: ${BEATS_SYSTEM_PASSWORD:-}
diff --git a/extensions/logspout/logspout-compose.yml b/extensions/logspout/logspout-compose.yml
index a05603e..f0ef100 100644
--- a/extensions/logspout/logspout-compose.yml
+++ b/extensions/logspout/logspout-compose.yml
@@ -4,6 +4,7 @@ services:
logspout:
build:
context: extensions/logspout
+ container_name: logspout
volumes:
- type: bind
source: /var/run/docker.sock
diff --git a/extensions/metricbeat/config/metricbeat.yml b/extensions/metricbeat/config/metricbeat.yml
index 1c2b6cb..33a1c54 100644
--- a/extensions/metricbeat/config/metricbeat.yml
+++ b/extensions/metricbeat/config/metricbeat.yml
@@ -18,7 +18,7 @@ metricbeat.autodiscover:
metricbeat.modules:
- module: elasticsearch
hosts: [ http://elasticsearch:9200 ]
- username: monitoring_internal
+ username: elastic
password: ${MONITORING_INTERNAL_PASSWORD}
xpack.enabled: true
period: 10s
@@ -30,7 +30,7 @@ metricbeat.modules:
enabled: true
- module: kibana
hosts: [ http://kibana:5601 ]
- username: monitoring_internal
+ username: elastic
password: ${MONITORING_INTERNAL_PASSWORD}
xpack.enabled: true
period: 10s
diff --git a/extensions/metricbeat/metricbeat-compose.yml b/extensions/metricbeat/metricbeat-compose.yml
index c55a5e5..7a91e5d 100644
--- a/extensions/metricbeat/metricbeat-compose.yml
+++ b/extensions/metricbeat/metricbeat-compose.yml
@@ -8,6 +8,7 @@ services:
ELASTIC_VERSION: ${ELASTIC_VERSION}
# Run as 'root' instead of 'metricbeat' (uid 1000) to allow reading
# 'docker.sock' and the host's filesystem.
+ container_name: metricbeat
user: root
command:
# Log to stderr.
@@ -20,7 +21,7 @@ services:
# from within a container.
- --system.hostfs=/hostfs
volumes:
- - ./config/metricbeat.yml:/usr/share/metricbeat/metricbeat.yml:ro,Z
+ - ./extensions/metricbeat/config/metricbeat.yml:/usr/share/metricbeat/metricbeat.yml:ro,Z
- type: bind
source: /
target: /hostfs
diff --git a/host/YANLib.HttpApi.Host/Program.cs b/host/YANLib.HttpApi.Host/Program.cs
index ffecdb7..b26d383 100644
--- a/host/YANLib.HttpApi.Host/Program.cs
+++ b/host/YANLib.HttpApi.Host/Program.cs
@@ -13,20 +13,27 @@ public class Program
public async static Task Main(string[] args)
{
Log.Logger = new LoggerConfiguration().MinimumLevel.Information().Enrich.FromLogContext().WriteTo.Async(c => c.Console()).CreateLogger();
+
try
{
Log.Information("Starting YANLib.HttpApi.Host.");
+
var builder = CreateBuilder(args);
+
_ = builder.Host.AddAppSettingsSecretsJson().UseAutofac().UseSerilog((t, f) => f.Enrich.FromLogContext().ReadFrom.Configuration(t.Configuration));
_ = await builder.AddApplicationAsync();
+
var app = builder.Build();
+
await app.InitializeApplicationAsync();
await app.RunAsync();
- return 0;
+
+ return default;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
+
return 1;
}
finally
diff --git a/host/YANLib.HttpApi.Host/YANLib.HttpApi.Host.csproj b/host/YANLib.HttpApi.Host/YANLib.HttpApi.Host.csproj
index 52dba7c..53d49aa 100644
--- a/host/YANLib.HttpApi.Host/YANLib.HttpApi.Host.csproj
+++ b/host/YANLib.HttpApi.Host/YANLib.HttpApi.Host.csproj
@@ -1,52 +1,51 @@
-
+
-
- net6.0
- YANLib
- true
- YANLib-4681b4fd-151f-4221-84a4-929d86723e4c
- Linux
- ..\..
- ..\..\docker-compose.dcproj
-
+
+ net6.0
+ YANLib
+ true
+ YANLib-4681b4fd-151f-4221-84a4-929d86723e4c
+ Linux
+ ..\..
+ ..\..\docker-compose.dcproj
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
diff --git a/host/YANLib.HttpApi.Host/YANLibHttpApiHostModule.cs b/host/YANLib.HttpApi.Host/YANLibHttpApiHostModule.cs
index cff997b..d315aee 100644
--- a/host/YANLib.HttpApi.Host/YANLibHttpApiHostModule.cs
+++ b/host/YANLib.HttpApi.Host/YANLibHttpApiHostModule.cs
@@ -3,6 +3,7 @@
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;
@@ -12,31 +13,33 @@
using System.Collections.Generic;
using System.Linq;
using Volo.Abp;
-using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.AspNetCore.Mvc;
-using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Serilog;
-using Volo.Abp.Autofac;
using Volo.Abp.Caching.StackExchangeRedis;
+using Volo.Abp.EntityFrameworkCore;
+using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.Http.Client;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.Swashbuckle;
using YANLib.EntityFrameworkCore;
+using YANLib.Utilities;
using static Elastic.Apm.Agent;
+using static HealthChecks.UI.Client.UIResponseWriter;
+using static Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus;
using static System.StringSplitOptions;
namespace YANLib;
+
[DependsOn(
typeof(YANLibHttpApiModule),
typeof(YANLibApplicationModule),
typeof(YANLibEntityFrameworkCoreModule),
- typeof(AbpAutofacModule),
- typeof(AbpAspNetCoreMultiTenancyModule),
- typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
+ //typeof(AbpAutofacModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule),
+ typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpHttpClientModule)
)]
@@ -45,10 +48,14 @@ public class YANLibHttpApiHostModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
+
+ context.Services.AddElasticsearch(configuration);
+ Configure(o => o.UseSqlServer());
ConfigureConventionalControllers();
ConfigureLocalization();
ConfigureCors(context, configuration);
ConfigureSwaggerServices(context, configuration);
+ ConfigureHealthChecks(context, configuration);
}
private void ConfigureConventionalControllers() => Configure(o => o.ConventionalControllers.Create(typeof(YANLibApplicationModule).Assembly));
@@ -56,14 +63,15 @@ public override void ConfigureServices(ServiceConfigurationContext context)
private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
+
_ = context.Services.AddAbpSwaggerGenWithOAuth(configuration["AuthServer:Authority"], new Dictionary
{
- {"YANLib", "YANLib API"},
- {"YANJson", "YANJson API"}
+ {"YANLib Sample", "YANLib API Sample"},
+ {"YANLib Test", "YANLib API Test"}
}, o =>
{
- o.SwaggerDoc("main", new OpenApiInfo { Title = $"YANLib API - {hostingEnvironment.EnvironmentName}", Version = "main" });
- o.SwaggerDoc("json", new OpenApiInfo { Title = $"YANJson API - {hostingEnvironment.EnvironmentName}", Version = "json" });
+ o.SwaggerDoc("sample", new OpenApiInfo { Title = $"YANLib API Sample - {hostingEnvironment.EnvironmentName}", Version = "sample" });
+ o.SwaggerDoc("test", new OpenApiInfo { Title = $"YANLib API Test - {hostingEnvironment.EnvironmentName}", Version = "test" });
o.CustomSchemaIds(t => t.FullName);
o.HideAbpEndpoints();
o.EnableAnnotations();
@@ -92,26 +100,39 @@ private void ConfigureLocalization() => Configure(o =>
o.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
o.Languages.Add(new LanguageInfo("es", "es", "Español", "es"));
o.Languages.Add(new LanguageInfo("el", "el", "Ελληνικά"));
+ o.Languages.Add(new LanguageInfo("vi", "vi", "Tiếng Việt"));
});
- private static void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) => context.Services.AddCors(o => o.AddDefaultPolicy(b => b.WithOrigins(configuration["App:CorsOrigins"].Split(",", RemoveEmptyEntries).Select(o => o.RemovePostFix("/")).ToArray()).WithAbpExposedHeaders().SetIsOriginAllowedToAllowWildcardSubdomains().AllowAnyHeader().AllowAnyMethod().AllowCredentials()));
+ private static void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) => context.Services.AddCors(o => o
+ .AddDefaultPolicy(b => b
+ .WithOrigins(configuration["App:CorsOrigins"].Split(",", RemoveEmptyEntries).Select(o => o
+ .RemovePostFix("/")).ToArray()).WithAbpExposedHeaders().SetIsOriginAllowedToAllowWildcardSubdomains().AllowAnyHeader().AllowAnyMethod().AllowCredentials()));
+
+ private static void ConfigureHealthChecks(ServiceConfigurationContext context, IConfiguration configuration) => context.Services.AddHealthChecks()
+ .AddSqlServer(connectionString: configuration["ConnectionStrings:Default"], name: "database", failureStatus: Degraded, tags: new string[] { "db", "sql", "sqlserver" });
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
+
_ = app.UseAllElasticApm(context.GetConfiguration());
_ = Subscribe(new HttpDiagnosticsSubscriber());
_ = Subscribe(new EfCoreDiagnosticsSubscriber());
+
var env = context.GetEnvironment();
+
if (env.IsDevelopment())
{
_ = app.UseDeveloperExceptionPage();
}
+
_ = app.UseAbpRequestLocalization();
+
if (!env.IsDevelopment())
{
_ = app.UseErrorPage();
}
+
_ = app.UseCorrelationId();
_ = app.UseStaticFiles();
_ = app.UseRouting();
@@ -120,15 +141,24 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
_ = app.UseUnitOfWork();
_ = app.UseAuthorization();
_ = app.UseSwagger();
+
_ = app.UseAbpSwaggerUI(c =>
{
- c.SwaggerEndpoint("/swagger/main/swagger.json", "YANLib API");
- c.SwaggerEndpoint("/swagger/json/swagger.json", "YANJson API");
+ c.SwaggerEndpoint("/swagger/sample/swagger.json", "YANLib API Sample");
+ c.SwaggerEndpoint("/swagger/test/swagger.json", "YANLib API Test");
c.OAuthClientId(context.ServiceProvider.GetRequiredService()["AuthServer:SwaggerClientId"]);
c.OAuthScopes("YANLib");
});
+
_ = app.UseAuditing();
_ = app.UseAbpSerilogEnrichers();
+
+ _ = app.UseHealthChecks("/health", new HealthCheckOptions()
+ {
+ Predicate = _ => true,
+ ResponseWriter = WriteHealthCheckUIResponse
+ });
+
_ = app.UseConfiguredEndpoints();
}
}
diff --git a/host/YANLib.HttpApi.Host/appsettings.Development.json b/host/YANLib.HttpApi.Host/appsettings.Development.json
index 6ef7dfb..4d4c738 100644
--- a/host/YANLib.HttpApi.Host/appsettings.Development.json
+++ b/host/YANLib.HttpApi.Host/appsettings.Development.json
@@ -1,4 +1,7 @@
{
+ "ConnectionStrings": {
+ "Default": "Server=localhost;Database=YANLIB;User ID=sa;Password=admin123@"
+ },
"Redis": {
"Configuration": "localhost,password=admin123@"
},
@@ -12,7 +15,7 @@
}
},
"EventBus": {
- "ClientName": "PublisherDev",
+ "ClientName": "SampleDev",
"ExchangeName": "YanlibDev"
}
},
@@ -29,9 +32,17 @@
"TopicName": "yan.lib"
}
},
+ "Elasticsearch": {
+ "Indices": {
+ "Sample": "yanlib_sample_index_dev"
+ },
+ "Url": "http://localhost:9200/",
+ "Username": "elastic",
+ "Password": "admin123"
+ },
"RemoteServices": {
"TestApi": {
- "BaseUrl": "http://test-api.local/"
+ "BaseUrl": "http://sample-api.local/"
}
},
"Serilog": {
@@ -90,7 +101,7 @@
"ElasticApm": {
"ServiceName": "YANLib",
"SecretToken": "YXBtOmFkbWluMTIz",
- "ServerUrl": "http://apm-server:8200",
+ "ServerUrl": "http://localhost:8200",
"Environment": "Development",
"CaptureBody": "all",
"LogLevel": "Trace"
diff --git a/host/YANLib.HttpApi.Host/appsettings.Production.json b/host/YANLib.HttpApi.Host/appsettings.Production.json
index 21a99ae..e98b888 100644
--- a/host/YANLib.HttpApi.Host/appsettings.Production.json
+++ b/host/YANLib.HttpApi.Host/appsettings.Production.json
@@ -1,4 +1,7 @@
{
+ "ConnectionStrings": {
+ "Default": "Server=localhost;Database=YANLIB;User ID=sa;Password=admin123@"
+ },
"Redis": {
"Configuration": "localhost,password=admin123@"
},
@@ -12,7 +15,7 @@
}
},
"EventBus": {
- "ClientName": "PublisherProd",
+ "ClientName": "SampleProd",
"ExchangeName": "YanlibProd"
}
},
@@ -26,12 +29,20 @@
},
"EventBus": {
"GroupId": "YanlibProd",
- "TopicName": "yan.prod"
+ "TopicName": "yan.lib"
}
},
+ "Elasticsearch": {
+ "Indices": {
+ "Sample": "yanlib_sample_index_prod"
+ },
+ "Url": "http://elasticsearch:9200/",
+ "Username": "elastic",
+ "Password": "admin123"
+ },
"RemoteServices": {
"TestApi": {
- "BaseUrl": "http://test-api.local/"
+ "BaseUrl": "http://sample-api.local/"
}
},
"Serilog": {
diff --git a/host/YANLib.HttpApi.Host/appsettings.json b/host/YANLib.HttpApi.Host/appsettings.json
index 6d1ea78..d10788b 100644
--- a/host/YANLib.HttpApi.Host/appsettings.json
+++ b/host/YANLib.HttpApi.Host/appsettings.json
@@ -5,7 +5,7 @@
"RedirectAllowedUrls": ""
},
"ConnectionStrings": {
- "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=YANLib;Trusted_Connection=True"
+ "Default": "Server=localhost;Database=YANLIB;User ID=sa;Password=admin123@"
},
"AuthServer": {
"Authority": "https://localhost:44380",
diff --git a/lib/YANLib/Nullable/YANBool.Nullable.cs b/lib/YANLib/Nullable/YANBool.Nullable.cs
index 4208e31..8e5c1ac 100644
--- a/lib/YANLib/Nullable/YANBool.Nullable.cs
+++ b/lib/YANLib/Nullable/YANBool.Nullable.cs
@@ -20,6 +20,7 @@ public static partial class YANBool
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToBool();
@@ -34,6 +35,7 @@ public static partial class YANBool
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToBool(dfltVal);
diff --git a/lib/YANLib/Nullable/YANBool.cs b/lib/YANLib/Nullable/YANBool.cs
index c09f855..5735e54 100644
--- a/lib/YANLib/Nullable/YANBool.cs
+++ b/lib/YANLib/Nullable/YANBool.cs
@@ -20,6 +20,7 @@ public static partial class YANBool
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToBool();
@@ -34,6 +35,7 @@ public static partial class YANBool
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToBool();
@@ -48,6 +50,7 @@ public static partial class YANBool
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToBool(dfltVal);
diff --git a/lib/YANLib/Nullable/YANDateTime.cs b/lib/YANLib/Nullable/YANDateTime.cs
index 70b2508..e5a7460 100644
--- a/lib/YANLib/Nullable/YANDateTime.cs
+++ b/lib/YANLib/Nullable/YANDateTime.cs
@@ -99,6 +99,7 @@ public static partial class YANDateTime
public static DateTime? ChangeTimeZone(this DateTime dt, T1 tzSrc, T2 tzDst) where T1 : struct where T2 : struct
{
var diff = tzDst.ToInt() - tzSrc.ToInt();
+
return diff.HasValue ? diff switch
{
< 0 when (dt - MinValue).TotalHours < Abs(diff.Value) => default,
diff --git a/lib/YANLib/Nullable/YANNum.Byte.Nullable.cs b/lib/YANLib/Nullable/YANNum.Byte.Nullable.cs
index e9be2b6..1836dd0 100644
--- a/lib/YANLib/Nullable/YANNum.Byte.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Byte.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToByte();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToByte(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Byte.cs b/lib/YANLib/Nullable/YANNum.Byte.cs
index e470221..b73bffd 100644
--- a/lib/YANLib/Nullable/YANNum.Byte.cs
+++ b/lib/YANLib/Nullable/YANNum.Byte.cs
@@ -22,6 +22,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToByte();
@@ -38,6 +39,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToByte();
@@ -54,6 +56,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToByte(dfltVal);
@@ -65,6 +68,7 @@ public static partial class YANNum
{
var minValue = min.ToByte();
var maxValue = max.ToByte();
+
return minValue.HasValue && maxValue.HasValue ? minValue > maxValue ? default : new Random().Next(minValue.Value, maxValue.Value).ToByte() : default;
}
diff --git a/lib/YANLib/Nullable/YANNum.Decimal.Nullable.cs b/lib/YANLib/Nullable/YANNum.Decimal.Nullable.cs
index 20e6ca6..f851887 100644
--- a/lib/YANLib/Nullable/YANNum.Decimal.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Decimal.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToDecimal();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToDecimal(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Decimal.cs b/lib/YANLib/Nullable/YANNum.Decimal.cs
index d8a915e..9566c21 100644
--- a/lib/YANLib/Nullable/YANNum.Decimal.cs
+++ b/lib/YANLib/Nullable/YANNum.Decimal.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToDecimal();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToDecimal();
@@ -49,6 +51,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToDecimal(dfltVal);
@@ -59,6 +62,7 @@ public static partial class YANNum
{
var minValue = min.ToDecimal();
var maxValue = max.ToDecimal();
+
return minValue.HasValue && maxValue.HasValue ? minValue > maxValue ? default : new Random().NextDecimal(minValue.Value, maxValue.Value) : default;
}
diff --git a/lib/YANLib/Nullable/YANNum.Double.Nullable.cs b/lib/YANLib/Nullable/YANNum.Double.Nullable.cs
index 1badb4c..aff85ae 100644
--- a/lib/YANLib/Nullable/YANNum.Double.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Double.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToDouble();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToDouble(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Double.cs b/lib/YANLib/Nullable/YANNum.Double.cs
index 39ed876..80a5ffa 100644
--- a/lib/YANLib/Nullable/YANNum.Double.cs
+++ b/lib/YANLib/Nullable/YANNum.Double.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToDouble();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToDouble();
@@ -49,6 +51,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToDouble(dfltVal);
@@ -59,6 +62,7 @@ public static partial class YANNum
{
var minValue = min.ToDouble();
var maxValue = max.ToDouble();
+
return minValue.HasValue && maxValue.HasValue ? minValue > maxValue ? default : new Random().NextDouble(minValue.Value, maxValue.Value) : default;
}
diff --git a/lib/YANLib/Nullable/YANNum.Float.Nullable.cs b/lib/YANLib/Nullable/YANNum.Float.Nullable.cs
index d6ddc8c..bf818a8 100644
--- a/lib/YANLib/Nullable/YANNum.Float.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Float.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToFloat();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToFloat(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Float.cs b/lib/YANLib/Nullable/YANNum.Float.cs
index 3582b88..ae68047 100644
--- a/lib/YANLib/Nullable/YANNum.Float.cs
+++ b/lib/YANLib/Nullable/YANNum.Float.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToFloat();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToFloat();
@@ -49,6 +51,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToFloat(dfltVal);
@@ -59,6 +62,7 @@ public static partial class YANNum
{
var minValue = min.ToFloat();
var maxValue = max.ToFloat();
+
return minValue.HasValue && maxValue.HasValue ? minValue > maxValue ? default : new Random().NextSingle(minValue.Value, maxValue.Value) : default;
}
diff --git a/lib/YANLib/Nullable/YANNum.Int.Nullable.cs b/lib/YANLib/Nullable/YANNum.Int.Nullable.cs
index 8f9aef3..9612d77 100644
--- a/lib/YANLib/Nullable/YANNum.Int.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Int.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToInt();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToInt(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Int.cs b/lib/YANLib/Nullable/YANNum.Int.cs
index d8fa337..29ecf96 100644
--- a/lib/YANLib/Nullable/YANNum.Int.cs
+++ b/lib/YANLib/Nullable/YANNum.Int.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToInt();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToInt();
@@ -49,6 +51,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToInt(dfltVal);
@@ -59,6 +62,7 @@ public static partial class YANNum
{
var minValue = min.ToInt();
var maxValue = max.ToInt();
+
return minValue.HasValue && maxValue.HasValue ? minValue > maxValue ? default : new Random().Next(minValue.Value, maxValue.Value) : default;
}
diff --git a/lib/YANLib/Nullable/YANNum.Long.Nullable.cs b/lib/YANLib/Nullable/YANNum.Long.Nullable.cs
index f1ce782..13a62aa 100644
--- a/lib/YANLib/Nullable/YANNum.Long.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Long.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToLong();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToLong(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Long.cs b/lib/YANLib/Nullable/YANNum.Long.cs
index 3edceef..6acad80 100644
--- a/lib/YANLib/Nullable/YANNum.Long.cs
+++ b/lib/YANLib/Nullable/YANNum.Long.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToLong();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToLong();
@@ -49,6 +51,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToLong(dfltVal);
@@ -59,6 +62,7 @@ public static partial class YANNum
{
var minValue = min.ToLong();
var maxValue = max.ToLong();
+
return minValue.HasValue && maxValue.HasValue ? minValue > maxValue ? default : new Random().NextInt64(minValue.Value, maxValue.Value) : default;
}
diff --git a/lib/YANLib/Nullable/YANNum.Nint.Nullable.cs b/lib/YANLib/Nullable/YANNum.Nint.Nullable.cs
index 2e95e71..47d8bb5 100644
--- a/lib/YANLib/Nullable/YANNum.Nint.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Nint.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToNint();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToNint(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Nint.cs b/lib/YANLib/Nullable/YANNum.Nint.cs
index be7caf3..78ff92f 100644
--- a/lib/YANLib/Nullable/YANNum.Nint.cs
+++ b/lib/YANLib/Nullable/YANNum.Nint.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToNint();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToNint();
@@ -49,6 +51,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToNint(dfltVal);
@@ -59,6 +62,7 @@ public static partial class YANNum
{
var minValue = min.ToNint();
var maxValue = max.ToNint();
+
return minValue.HasValue && maxValue.HasValue ? minValue > maxValue ? default : new Random().NextInt64(minValue.Value, maxValue.Value).ToNint() : default;
}
diff --git a/lib/YANLib/Nullable/YANNum.Nuint.Nullable.cs b/lib/YANLib/Nullable/YANNum.Nuint.Nullable.cs
index 12b4d0b..e335a87 100644
--- a/lib/YANLib/Nullable/YANNum.Nuint.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Nuint.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToNuint();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToNuint(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Nuint.cs b/lib/YANLib/Nullable/YANNum.Nuint.cs
index 92182f4..8e69ea8 100644
--- a/lib/YANLib/Nullable/YANNum.Nuint.cs
+++ b/lib/YANLib/Nullable/YANNum.Nuint.cs
@@ -23,6 +23,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToNuint();
@@ -37,6 +38,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToNuint();
@@ -51,6 +53,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToNuint(dfltVal);
@@ -61,6 +64,7 @@ public static partial class YANNum
{
var minValue = min.ToNuint();
var maxValue = max.ToNuint();
+
return minValue.HasValue && maxValue.HasValue ? minValue > maxValue ? default : (new Random().NextInt64(nint.MinValue, (long)(maxValue - (minValue - (BigInteger)nint.MinValue))) - nint.MinValue).ToNuint() + minValue : default;
}
diff --git a/lib/YANLib/Nullable/YANNum.Sbyte.Nullable.cs b/lib/YANLib/Nullable/YANNum.Sbyte.Nullable.cs
index 7791f85..12808c0 100644
--- a/lib/YANLib/Nullable/YANNum.Sbyte.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Sbyte.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToSbyte();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToSbyte(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Sbyte.cs b/lib/YANLib/Nullable/YANNum.Sbyte.cs
index 9075477..c32badd 100644
--- a/lib/YANLib/Nullable/YANNum.Sbyte.cs
+++ b/lib/YANLib/Nullable/YANNum.Sbyte.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToSbyte();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToSbyte();
@@ -49,6 +51,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToSbyte(dfltVal);
@@ -59,6 +62,7 @@ public static partial class YANNum
{
var minValue = min.ToSbyte();
var maxValue = max.ToSbyte();
+
return minValue.HasValue && maxValue.HasValue ? minValue > maxValue ? default : new Random().Next(minValue.Value, maxValue.Value).ToSbyte() : default;
}
diff --git a/lib/YANLib/Nullable/YANNum.Short.Nullable.cs b/lib/YANLib/Nullable/YANNum.Short.Nullable.cs
index 606d781..0cee16e 100644
--- a/lib/YANLib/Nullable/YANNum.Short.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Short.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToShort();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToShort(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Short.cs b/lib/YANLib/Nullable/YANNum.Short.cs
index d640e72..bad0d0a 100644
--- a/lib/YANLib/Nullable/YANNum.Short.cs
+++ b/lib/YANLib/Nullable/YANNum.Short.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToShort();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToShort();
@@ -49,6 +51,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToShort(dfltVal);
@@ -59,6 +62,7 @@ public static partial class YANNum
{
var minValue = min.ToShort();
var maxValue = max.ToShort();
+
return minValue.HasValue && maxValue.HasValue ? minValue > maxValue ? default : new Random().Next(minValue.Value, maxValue.Value).ToShort() : default;
}
diff --git a/lib/YANLib/Nullable/YANNum.Uint.Nullable.cs b/lib/YANLib/Nullable/YANNum.Uint.Nullable.cs
index cbe73d7..088fc92 100644
--- a/lib/YANLib/Nullable/YANNum.Uint.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Uint.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToUint();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToUint(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Uint.cs b/lib/YANLib/Nullable/YANNum.Uint.cs
index e3aa064..2d57f17 100644
--- a/lib/YANLib/Nullable/YANNum.Uint.cs
+++ b/lib/YANLib/Nullable/YANNum.Uint.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToUint();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToUint();
@@ -49,6 +51,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToUint(dfltVal);
@@ -59,6 +62,7 @@ public static partial class YANNum
{
var minValue = min.ToUint();
var maxValue = max.ToUint();
+
return minValue.HasValue && maxValue.HasValue ? minValue > maxValue ? default : new Random().NextInt64(minValue.Value, maxValue.Value).ToUint() : default;
}
diff --git a/lib/YANLib/Nullable/YANNum.Ulong.Nullable.cs b/lib/YANLib/Nullable/YANNum.Ulong.Nullable.cs
index 236cff4..0c02c79 100644
--- a/lib/YANLib/Nullable/YANNum.Ulong.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Ulong.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToUlong();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToUlong(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Ulong.cs b/lib/YANLib/Nullable/YANNum.Ulong.cs
index 8b50835..e7f0a09 100644
--- a/lib/YANLib/Nullable/YANNum.Ulong.cs
+++ b/lib/YANLib/Nullable/YANNum.Ulong.cs
@@ -23,6 +23,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToUlong();
@@ -37,6 +38,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToUlong();
@@ -51,6 +53,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToUlong(dfltVal);
@@ -61,6 +64,7 @@ public static partial class YANNum
{
var minValue = min.ToUlong();
var maxValue = max.ToUlong();
+
return minValue.HasValue && maxValue.HasValue ? minValue > maxValue ? default : (new Random().NextInt64(long.MinValue, (long)(maxValue - (minValue - (BigInteger)long.MinValue))) - long.MinValue).ToUlong() + minValue : default;
}
diff --git a/lib/YANLib/Nullable/YANNum.Ushort.Nullable.cs b/lib/YANLib/Nullable/YANNum.Ushort.Nullable.cs
index e79a551..6922b19 100644
--- a/lib/YANLib/Nullable/YANNum.Ushort.Nullable.cs
+++ b/lib/YANLib/Nullable/YANNum.Ushort.Nullable.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToUshort();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToUshort(dfltVal);
diff --git a/lib/YANLib/Nullable/YANNum.Ushort.cs b/lib/YANLib/Nullable/YANNum.Ushort.cs
index dcb29b7..cebbae2 100644
--- a/lib/YANLib/Nullable/YANNum.Ushort.cs
+++ b/lib/YANLib/Nullable/YANNum.Ushort.cs
@@ -21,6 +21,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToUshort();
@@ -35,6 +36,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToUshort();
@@ -49,6 +51,7 @@ public static partial class YANNum
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToUshort(dfltVal);
diff --git a/lib/YANLib/Ultimate/Nullable/YANDateTime.Nullable.cs b/lib/YANLib/Ultimate/Nullable/YANDateTime.Nullable.cs
index e1cf69f..1772861 100644
--- a/lib/YANLib/Ultimate/Nullable/YANDateTime.Nullable.cs
+++ b/lib/YANLib/Ultimate/Nullable/YANDateTime.Nullable.cs
@@ -16,6 +16,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var str in strs)
{
yield return str.ToDateTime(fmt, dfltVal);
@@ -76,6 +77,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.GetWeekOfYear();
@@ -88,6 +90,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzSrc, tzDst);
@@ -100,6 +103,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzSrc, tzDst);
@@ -112,6 +116,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzSrc, tzDst);
diff --git a/lib/YANLib/Ultimate/Nullable/YANDateTime.cs b/lib/YANLib/Ultimate/Nullable/YANDateTime.cs
index 45968ef..3284e0a 100644
--- a/lib/YANLib/Ultimate/Nullable/YANDateTime.cs
+++ b/lib/YANLib/Ultimate/Nullable/YANDateTime.cs
@@ -14,6 +14,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var str in strs)
{
yield return str.ToDateTime();
@@ -33,6 +34,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var str in strs)
{
yield return str.ToDateTime(fmt);
@@ -53,6 +55,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var str in strs)
{
yield return str.ToDateTime(fmt, dfltVal);
@@ -73,6 +76,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.GetWeekOfYear();
@@ -85,6 +89,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzSrc, tzDst);
@@ -97,6 +102,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzDst);
@@ -109,6 +115,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzSrc, tzDst);
@@ -121,6 +128,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzSrc, tzDst);
@@ -133,6 +141,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzSrc, tzDst);
@@ -145,6 +154,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzSrc, tzDst);
@@ -157,6 +167,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzDst);
@@ -169,6 +180,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzDst);
@@ -181,6 +193,7 @@ public static partial class YANDateTime
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzDst);
diff --git a/lib/YANLib/Ultimate/YANBytes.cs b/lib/YANLib/Ultimate/YANBytes.cs
index f2618c5..30c6462 100644
--- a/lib/YANLib/Ultimate/YANBytes.cs
+++ b/lib/YANLib/Ultimate/YANBytes.cs
@@ -8,6 +8,7 @@ public static partial class YANBytes
{
yield break;
}
+
foreach (var obj in objs)
{
yield return obj.ToByteArray();
@@ -20,6 +21,7 @@ public static partial class YANBytes
{
yield break;
}
+
foreach (var arr in arrs)
{
yield return arr.FromByteArray();
diff --git a/lib/YANLib/Ultimate/YANDateTime.Nullable.cs b/lib/YANLib/Ultimate/YANDateTime.Nullable.cs
index d2af07c..14896e5 100644
--- a/lib/YANLib/Ultimate/YANDateTime.Nullable.cs
+++ b/lib/YANLib/Ultimate/YANDateTime.Nullable.cs
@@ -16,6 +16,7 @@ public static IEnumerable ToDateTime(this IEnumerable strs, st
{
yield break;
}
+
foreach (var str in strs)
{
yield return str.ToDateTime(fmt, dfltVal);
@@ -76,6 +77,7 @@ public static IEnumerable GetWeekOfYear(this IEnumerable dts)
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.GetWeekOfYear();
@@ -88,6 +90,7 @@ public static IEnumerable ChangeTimeZone(this IEnumerable ChangeTimeZone(this IEnumerable ChangeTimeZone(this IEnumerable ChangeTimeZone(this IEnumerable ChangeTimeZone(this IEnumerable ChangeTimeZone(this IEnumerable ChangeTimeZone(this IEnumerable ChangeTimeZone(this IEnumerable ChangeTimeZone(this IEnumerable
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzDst);
@@ -196,6 +207,7 @@ public static IEnumerable ChangeTimeZone(this IEnumerable ToDateTime(this IEnumerable strs)
{
yield break;
}
+
foreach (var str in strs)
{
yield return str.ToDateTime();
@@ -33,6 +34,7 @@ public static IEnumerable ToDateTime(this IEnumerable strs, st
{
yield break;
}
+
foreach (var str in strs)
{
yield return str.ToDateTime(fmt);
@@ -53,6 +55,7 @@ public static IEnumerable ToDateTime(this IEnumerable strs, st
{
yield break;
}
+
foreach (var str in strs)
{
yield return str.ToDateTime(fmt, dfltVal);
@@ -73,6 +76,7 @@ public static IEnumerable GetWeekOfYear(this IEnumerable dts)
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.GetWeekOfYear();
@@ -85,6 +89,7 @@ public static IEnumerable ChangeTimeZone(this IEnumerable ChangeTimeZone(this IEnumerable
{
yield break;
}
+
foreach (var dt in dts)
{
yield return dt.ChangeTimeZone(tzDst);
diff --git a/lib/YANLib/Ultimate/YANJson.cs b/lib/YANLib/Ultimate/YANJson.cs
index e977a38..153ca48 100644
--- a/lib/YANLib/Ultimate/YANJson.cs
+++ b/lib/YANLib/Ultimate/YANJson.cs
@@ -8,6 +8,7 @@ public static IEnumerable Serializes(this IEnumerable mdls)
{
yield break;
}
+
foreach (var mdl in mdls)
{
yield return mdl.Serialize();
@@ -20,6 +21,7 @@ public static IEnumerable CamelSerializes(this IEnumerable mdls)
{
yield break;
}
+
foreach (var mdl in mdls)
{
yield return mdl.CamelSerialize();
@@ -32,6 +34,7 @@ public static IEnumerable CamelSerializes(this IEnumerable mdls)
{
yield break;
}
+
foreach (var str in strs)
{
yield return str.StandardDeserialize();
@@ -44,6 +47,7 @@ public static IEnumerable CamelSerializes(this IEnumerable mdls)
{
yield break;
}
+
foreach (var str in strs)
{
yield return str.Deserialize();
diff --git a/lib/YANLib/Ultimate/YANNum.Byte.Nullable.cs b/lib/YANLib/Ultimate/YANNum.Byte.Nullable.cs
index 109e832..29d0a6c 100644
--- a/lib/YANLib/Ultimate/YANNum.Byte.Nullable.cs
+++ b/lib/YANLib/Ultimate/YANNum.Byte.Nullable.cs
@@ -8,6 +8,7 @@ public static IEnumerable ToByte(this IEnumerable nums) where T : s
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToByte();
@@ -20,6 +21,7 @@ public static IEnumerable ToByte(this IEnumerable strs, T? dflt
{
yield break;
}
+
foreach (var str in strs)
{
yield return str.ToByte(dfltVal);
diff --git a/lib/YANLib/Ultimate/YANNum.Byte.cs b/lib/YANLib/Ultimate/YANNum.Byte.cs
index aa6caa7..e789bd5 100644
--- a/lib/YANLib/Ultimate/YANNum.Byte.cs
+++ b/lib/YANLib/Ultimate/YANNum.Byte.cs
@@ -8,6 +8,7 @@ public static IEnumerable ToByte(this IEnumerable nums) where T : st
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToByte();
@@ -20,6 +21,7 @@ public static IEnumerable ToByte(this IEnumerable strs)
{
yield break;
}
+
foreach (var str in strs)
{
yield return YANLib.YANNum.ToByte(str);
@@ -32,6 +34,7 @@ public static IEnumerable ToByte(this IEnumerable strs, T dfltV
{
yield break;
}
+
foreach (var str in strs)
{
yield return str.ToByte(dfltVal);
diff --git a/lib/YANLib/YANBool.Nullable.cs b/lib/YANLib/YANBool.Nullable.cs
index a0988ed..5771fdf 100644
--- a/lib/YANLib/YANBool.Nullable.cs
+++ b/lib/YANLib/YANBool.Nullable.cs
@@ -22,6 +22,7 @@ public static IEnumerable ToBool(this IEnumerable nums) where T : s
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToBool();
@@ -36,6 +37,7 @@ public static IEnumerable ToBool(this IEnumerable strs, T? dflt
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToBool(dfltVal);
diff --git a/lib/YANLib/YANBool.cs b/lib/YANLib/YANBool.cs
index e54f94c..338f359 100644
--- a/lib/YANLib/YANBool.cs
+++ b/lib/YANLib/YANBool.cs
@@ -23,6 +23,7 @@ public static IEnumerable ToBool(this IEnumerable nums) where T : st
{
yield break;
}
+
foreach (var num in nums)
{
yield return num.ToBool();
@@ -37,6 +38,7 @@ public static IEnumerable ToBool(this IEnumerable strs)
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToBool();
@@ -51,6 +53,7 @@ public static IEnumerable ToBool(this IEnumerable strs, T dfltV
{
yield break;
}
+
foreach (var num in strs)
{
yield return num.ToBool(dfltVal);
diff --git a/lib/YANLib/YANDateTime.cs b/lib/YANLib/YANDateTime.cs
index 227a5b7..1a4ff39 100644
--- a/lib/YANLib/YANDateTime.cs
+++ b/lib/YANLib/YANDateTime.cs
@@ -96,6 +96,7 @@ public static partial class YANDateTime
public static DateTime ChangeTimeZone(this DateTime dt, T1 tzSrc, T2 tzDst) where T1 : struct where T2 : struct
{
var diff = tzDst.ToInt() - tzSrc.ToInt();
+
return diff switch
{
< 0 when (dt - MinValue).TotalHours < Abs(diff) => default,
diff --git a/lib/YANLib/YANEnumerable.cs b/lib/YANLib/YANEnumerable.cs
index 8055d3b..3a8efc7 100644
--- a/lib/YANLib/YANEnumerable.cs
+++ b/lib/YANLib/YANEnumerable.cs
@@ -10,11 +10,14 @@ public static partial class YANEnumerable
public static IEnumerable> ChunkBySize(this List srcs, T1 chunkSize) where T1 : struct
{
var size = chunkSize.ToInt();
+
if (srcs.IsEmptyOrNull() && size < 1)
{
yield break;
}
+
var cnt = srcs.Count;
+
for (var i = 0; i < cnt; i += size)
{
yield return srcs.GetRange(i, Min(size, cnt - i));
@@ -27,7 +30,9 @@ public static IEnumerable Clean(this IEnumerable srcs)
{
yield break;
}
+
var t = typeof(T);
+
if (t.IsClass || GetUnderlyingType(t) is not null)
{
foreach (var src in srcs)
@@ -53,6 +58,7 @@ public static IEnumerable Clean(this IEnumerable srcs)
{
yield break;
}
+
foreach (var src in srcs)
{
if (src.IsNotWhiteSpaceAndNull())
diff --git a/lib/YANLib/YANModel.Property.cs b/lib/YANLib/YANModel.Property.cs
index 0ab7500..f348296 100644
--- a/lib/YANLib/YANModel.Property.cs
+++ b/lib/YANLib/YANModel.Property.cs
@@ -12,14 +12,17 @@ public static bool AllPropertiesNotDefault(this T? mdl)
{
return false;
}
+
foreach (var prop in mdl.GetType().GetProperties(Public | Instance | DeclaredOnly))
{
var type = prop.PropertyType;
+
if (EqualityComparer