mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-20 10:50:48 +08:00
10.7.22
This commit is contained in:
@@ -126,35 +126,8 @@ dotnet_style_qualification_for_property = false:silent
|
||||
dotnet_style_qualification_for_method = false:silent
|
||||
dotnet_style_qualification_for_event = false:silent
|
||||
|
||||
|
||||
dotnet_diagnostic.CA2208.severity = none
|
||||
dotnet_diagnostic.CA2008.severity = none
|
||||
dotnet_diagnostic.CA1812.severity = none
|
||||
dotnet_diagnostic.CA1508.severity = none
|
||||
dotnet_diagnostic.CA1512.severity = none
|
||||
dotnet_diagnostic.CA1513.severity = none
|
||||
dotnet_diagnostic.CA1810.severity = none
|
||||
dotnet_diagnostic.CA1814.severity = none
|
||||
dotnet_diagnostic.CA1815.severity = none
|
||||
dotnet_diagnostic.CA1835.severity = none
|
||||
dotnet_diagnostic.CA1819.severity = none
|
||||
dotnet_diagnostic.CA1823.severity = none
|
||||
dotnet_diagnostic.CA2002.severity = none
|
||||
dotnet_diagnostic.CA5350.severity = none
|
||||
dotnet_diagnostic.CA5351.severity = none
|
||||
dotnet_diagnostic.CA5358.severity = none
|
||||
dotnet_diagnostic.CA5384.severity = none
|
||||
dotnet_diagnostic.CA5392.severity = none
|
||||
dotnet_diagnostic.CA1805.severity = none
|
||||
dotnet_diagnostic.CA1851.severity = none
|
||||
dotnet_diagnostic.CA1510.severity = none
|
||||
dotnet_diagnostic.CA5401.severity = none
|
||||
dotnet_diagnostic.CA2022.severity = none
|
||||
dotnet_diagnostic.CA1848.severity = none
|
||||
dotnet_diagnostic.CA2000.severity = none
|
||||
dotnet_diagnostic.CA5394.severity = none
|
||||
dotnet_diagnostic.CA3003.severity = none
|
||||
dotnet_diagnostic.CA1515.severity = none
|
||||
dotnet_diagnostic.CA1849.severity = none
|
||||
dotnet_diagnostic.RCS1146.severity = warning
|
||||
dotnet_diagnostic.RCS1059.severity = none
|
||||
dotnet_diagnostic.RCS1138.severity = suggestion
|
||||
|
||||
dotnet_code_quality.CA1822.api_surface = private, internal
|
@@ -13,14 +13,16 @@ namespace ThingsGateway.Admin.Application;
|
||||
/// <summary>
|
||||
/// 需要角色授权权限
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
||||
public sealed class RolePermissionAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 忽略角色授权权限
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)]
|
||||
public sealed class IgnoreRolePermissionAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class CacheConst
|
||||
public static class CacheConst
|
||||
{
|
||||
/// <summary>
|
||||
/// Token表缓存Key
|
||||
|
@@ -13,7 +13,7 @@ namespace ThingsGateway.Admin.Application;
|
||||
/// <summary>
|
||||
/// 通讯器常量
|
||||
/// </summary>
|
||||
public class HubConst
|
||||
public static class HubConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统HubUrl
|
||||
|
@@ -14,7 +14,7 @@ namespace ThingsGateway.Admin.Application;
|
||||
/// 资源表常量
|
||||
/// </summary>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class ResourceConst
|
||||
public static class ResourceConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统内置编码
|
||||
|
@@ -14,7 +14,7 @@ namespace ThingsGateway.Admin.Application;
|
||||
/// 角色常量
|
||||
/// </summary>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class RoleConst
|
||||
public static class RoleConst
|
||||
{
|
||||
/// <summary>
|
||||
/// api角色
|
||||
|
@@ -14,7 +14,7 @@ namespace ThingsGateway.Admin.Application;
|
||||
/// SqlSugar系统常量
|
||||
/// </summary>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class SqlSugarConst
|
||||
public static class SqlSugarConst
|
||||
{
|
||||
/// <summary>
|
||||
/// DB_Admin
|
||||
|
@@ -1,14 +1,4 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 版权信息
|
||||
// 版权归百小僧及百签科技(广东)有限公司所有。
|
||||
// 所有权利保留。
|
||||
// 官方网站:https://baiqian.com
|
||||
//
|
||||
// 许可证信息
|
||||
// 项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。
|
||||
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
using ThingsGateway.DependencyInjection;
|
||||
|
||||
namespace System;
|
||||
|
@@ -1,14 +1,4 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 版权信息
|
||||
// 版权归百小僧及百签科技(广东)有限公司所有。
|
||||
// 所有权利保留。
|
||||
// 官方网站:https://baiqian.com
|
||||
//
|
||||
// 许可证信息
|
||||
// 项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。
|
||||
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
using ThingsGateway.DependencyInjection;
|
||||
|
||||
namespace System;
|
||||
|
@@ -261,4 +261,17 @@ public class AdminOAuthHandler<TOptions>(
|
||||
}
|
||||
|
||||
/// <summary>自定义 Token 异常</summary>
|
||||
public class OAuthTokenException(string message) : Exception(message);
|
||||
public class OAuthTokenException : Exception
|
||||
{
|
||||
public OAuthTokenException() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public OAuthTokenException(string? message, Exception? innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public OAuthTokenException(string? message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ namespace ThingsGateway.Admin.Application;
|
||||
/// <summary>
|
||||
/// 日志常量
|
||||
/// </summary>
|
||||
public class LoggingConst
|
||||
public static class LoggingConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 分类
|
||||
|
@@ -87,7 +87,7 @@ public class BlazorAuthenticationHandler : AppAuthorizeHandler
|
||||
var roles = await _sysRoleService.GetRoleListByUserIdAsync(userId).ConfigureAwait(false);
|
||||
|
||||
//这里鉴别用户使能状态
|
||||
if (user == null || !user.Status)
|
||||
if (user?.Status != true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public class BlazorAuthenticationHandler : AppAuthorizeHandler
|
||||
else
|
||||
{
|
||||
//这里鉴别用户使能状态
|
||||
if (user == null || !user.Status)
|
||||
if (user?.Status != true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@@ -334,7 +334,7 @@ internal sealed class SysResourceService : BaseService<SysResource>, ISysResourc
|
||||
flatList.Add(node);
|
||||
|
||||
// 如果当前节点有子节点,则递归处理每个子节点
|
||||
if (node.Children != null && node.Children.Count > 0)
|
||||
if (node.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in node.Children)
|
||||
{
|
||||
|
@@ -47,7 +47,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ThingsGateway.Razor\ThingsGateway.Razor.csproj" />
|
||||
<ProjectReference Include="..\ThingsGateway.SqlSugar\ThingsGateway.SqlSugar.csproj" />
|
||||
<ProjectReference Include="..\ThingsGateway.DB\ThingsGateway.DB.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@@ -13,7 +13,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class ClearTokenUtil
|
||||
public static class ClearTokenUtil
|
||||
{
|
||||
private static IRelationService RelationService;
|
||||
private static ISysUserService SysUserService;
|
||||
|
@@ -13,7 +13,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class NoticeUtil
|
||||
public static class NoticeUtil
|
||||
{
|
||||
private static INoticeService NoticeService;
|
||||
|
||||
|
@@ -14,7 +14,7 @@ namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class OpenApiUtil
|
||||
public static class OpenApiUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建树节点,传入的列表已经是树结构
|
||||
|
@@ -14,7 +14,7 @@ namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class OrgUtil
|
||||
public static class OrgUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造选择项,ID/TITLE
|
||||
|
@@ -14,7 +14,7 @@ namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class PositionUtil
|
||||
public static class PositionUtil
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
@@ -14,7 +14,7 @@ namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class RoleUtil
|
||||
public static class RoleUtil
|
||||
{
|
||||
|
||||
|
||||
|
@@ -14,7 +14,7 @@ namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class UserUtil
|
||||
public static class UserUtil
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
@@ -14,7 +14,7 @@ using ThingsGateway.Extension.Generic;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public class VerificatInfoUtil
|
||||
public static class VerificatInfoUtil
|
||||
{
|
||||
private static IVerificatInfoService VerificatInfoService { get; set; }
|
||||
static VerificatInfoUtil()
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace ThingsGateway.Admin.Razor;
|
||||
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class AdminOperConst
|
||||
public static class AdminOperConst
|
||||
{
|
||||
public const string Add = "新增";
|
||||
public const string Delete = "删除";
|
||||
|
@@ -48,7 +48,7 @@ public partial class SysUserAvatarEdit : IDisposable
|
||||
|
||||
private async Task OnAvatarUpload(UploadFile file)
|
||||
{
|
||||
if (file != null && file.File != null)
|
||||
if (file?.File != null)
|
||||
{
|
||||
var format = file.File.ContentType;
|
||||
ReadAvatarToken ??= new CancellationTokenSource();
|
||||
|
@@ -48,7 +48,7 @@ public partial class UserInfoEditComponent
|
||||
|
||||
private async Task OnAvatarUpload(UploadFile file)
|
||||
{
|
||||
if (file != null && file.File != null)
|
||||
if (file?.File != null)
|
||||
{
|
||||
var format = file.File.ContentType;
|
||||
ReadAvatarToken ??= new CancellationTokenSource();
|
||||
|
@@ -16,7 +16,7 @@ namespace ThingsGateway.Admin.Razor;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class ResourceUtil
|
||||
public static class ResourceUtil
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
@@ -1,12 +1 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 版权信息
|
||||
// 版权归百小僧及百签科技(广东)有限公司所有。
|
||||
// 所有权利保留。
|
||||
// 官方网站:https://baiqian.com
|
||||
//
|
||||
// 许可证信息
|
||||
// 项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。
|
||||
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
global using ThingsGateway.Admin.Application;
|
||||
global using ThingsGateway.Admin.Application;
|
||||
|
@@ -14,7 +14,7 @@ namespace ThingsGateway.Admin.Application;
|
||||
/// 授权用户常量
|
||||
/// </summary>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class ClaimConst
|
||||
public static class ClaimConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 账号
|
@@ -225,7 +225,7 @@ public static class SqlSugarExtensions
|
||||
|
||||
private static IEnumerable<T> Sort<T>(this IEnumerable<T> list, BasePageInput basePageInput)
|
||||
{
|
||||
if (basePageInput != null && basePageInput.SortField != null)
|
||||
if (basePageInput?.SortField != null)
|
||||
{
|
||||
for (int i = 0; i < basePageInput.SortField.Count; i++)
|
||||
{
|
11
src/Admin/ThingsGateway.DB/GlobalUsings.cs
Normal file
11
src/Admin/ThingsGateway.DB/GlobalUsings.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
global using ThingsGateway.NewLife.Extension;
|
@@ -25,7 +25,7 @@ namespace ThingsGateway.Admin.Application;
|
||||
/// 种子数据工具类
|
||||
/// </summary>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public class SeedDataUtil
|
||||
public static class SeedDataUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取List列表
|
33
src/Admin/ThingsGateway.DB/ThingsGateway.DB.csproj
Normal file
33
src/Admin/ThingsGateway.DB/ThingsGateway.DB.csproj
Normal file
@@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net9.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BootstrapBlazor.TableExport" Version="9.2.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="..\README.zh-CN.md" Pack="true" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ThingsGateway.Razor\ThingsGateway.Razor.csproj" />
|
||||
<ProjectReference Include="..\ThingsGateway.SqlSugar\ThingsGateway.SqlSugar.csproj" />
|
||||
<!--<PackageReference Include="SqlSugarCore" Version="5.1.4.195" />-->
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
|
||||
</Project>
|
@@ -471,7 +471,7 @@ public static class App
|
||||
IEnumerable<string> pathOfExternalAssemblies = Array.Empty<string>();
|
||||
|
||||
// 加载 appsettings.json 配置的外部程序集
|
||||
if (Settings.ExternalAssemblies != null && Settings.ExternalAssemblies.Length > 0)
|
||||
if (Settings.ExternalAssemblies?.Length > 0)
|
||||
{
|
||||
var externalDlls = new List<string>();
|
||||
foreach (var item in Settings.ExternalAssemblies)
|
||||
@@ -552,7 +552,7 @@ public static class App
|
||||
}
|
||||
|
||||
// 处理排除的程序集
|
||||
if (Settings.ExcludeAssemblies != null && Settings.ExcludeAssemblies.Length > 0)
|
||||
if (Settings.ExcludeAssemblies?.Length > 0)
|
||||
{
|
||||
scanAssemblies = scanAssemblies.Where(ass => !Settings.ExcludeAssemblies.Contains(ass.GetName().Name, StringComparer.OrdinalIgnoreCase));
|
||||
}
|
||||
|
@@ -455,7 +455,7 @@ public static class ObjectExtensions
|
||||
foreach (var property in propertys)
|
||||
{
|
||||
var p = oldType.GetProperty(property.Name);
|
||||
if (property.CanWrite && p != null && p.CanRead)
|
||||
if (property.CanWrite && p?.CanRead == true)
|
||||
{
|
||||
property.SetValue(o, ChangeType(p.GetValue(obj, null), property.PropertyType), null);
|
||||
}
|
||||
@@ -647,7 +647,7 @@ public static class ObjectExtensions
|
||||
/// <returns><see cref="bool"/> 实例,true 表示空集合,false 表示非空集合</returns>
|
||||
internal static bool IsEmpty<T>(this IEnumerable<T> collection)
|
||||
{
|
||||
return collection == null || !collection.Any();
|
||||
return collection?.Any() != true;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -54,8 +54,7 @@ public class FromConvertBinderProvider : IModelBinderProvider
|
||||
|
||||
// 判断是否定义 [FromConvert] 特性
|
||||
if (context.Metadata is DefaultModelMetadata actMetadata
|
||||
&& actMetadata.Attributes.ParameterAttributes != null
|
||||
&& actMetadata.Attributes.ParameterAttributes.Count > 0
|
||||
&& actMetadata.Attributes.ParameterAttributes?.Count > 0
|
||||
&& actMetadata.Attributes.ParameterAttributes.Any(u => u.GetType() == typeof(FromConvertAttribute)))
|
||||
{
|
||||
return new FromConvertBinder(_modelBinderConverts);
|
||||
|
@@ -25,7 +25,7 @@ public sealed class AppAuthorizeAttribute : AuthorizeAttribute
|
||||
/// <param name="policies">多个策略</param>
|
||||
public AppAuthorizeAttribute(params string[] policies)
|
||||
{
|
||||
if (policies != null && policies.Length > 0) Policies = policies;
|
||||
if (policies?.Length > 0) Policies = policies;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -47,7 +47,7 @@ public sealed class DependsOnAttribute : Attribute
|
||||
var components = new List<Type>();
|
||||
|
||||
// 遍历所有依赖组件
|
||||
if (dependComponents != null && dependComponents.Length > 0)
|
||||
if (dependComponents?.Length > 0)
|
||||
{
|
||||
foreach (var component in dependComponents)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ public sealed class DependsOnAttribute : Attribute
|
||||
var components = new List<Type>();
|
||||
|
||||
// 遍历所有依赖组件
|
||||
if (value != null && value.Length > 0)
|
||||
if (value?.Length > 0)
|
||||
{
|
||||
foreach (var component in value)
|
||||
{
|
||||
|
@@ -65,7 +65,7 @@ internal static class Penetrates
|
||||
IEnumerable<string> exposedHeaders = corsAccessorSettings.FixedClientToken == true
|
||||
? _defaultExposedHeaders
|
||||
: Array.Empty<string>();
|
||||
if (corsAccessorSettings.WithExposedHeaders != null && corsAccessorSettings.WithExposedHeaders.Length > 0)
|
||||
if (corsAccessorSettings.WithExposedHeaders?.Length > 0)
|
||||
{
|
||||
exposedHeaders = exposedHeaders.Concat(corsAccessorSettings.WithExposedHeaders).Distinct(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ namespace ThingsGateway.DataEncryption;
|
||||
/// AES 加解密
|
||||
/// </summary>
|
||||
[SuppressSniffer]
|
||||
public class AESEncryption
|
||||
public static class AESEncryption
|
||||
{
|
||||
/// <summary>
|
||||
/// 加密
|
||||
|
@@ -20,7 +20,7 @@ namespace ThingsGateway.DataEncryption;
|
||||
/// DES 加解密
|
||||
/// </summary>
|
||||
[SuppressSniffer]
|
||||
public class DESEncryption
|
||||
public static class DESEncryption
|
||||
{
|
||||
/// <summary>
|
||||
/// 加密
|
||||
|
@@ -18,7 +18,7 @@ namespace ThingsGateway.DataEncryption;
|
||||
/// KSort 加密(数据签名)
|
||||
/// </summary>
|
||||
[SuppressSniffer]
|
||||
public class KSortEncryption
|
||||
public static class KSortEncryption
|
||||
{
|
||||
private static DateTime _timeStampStartTime = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
|
@@ -17,7 +17,7 @@ namespace ThingsGateway.DataEncryption;
|
||||
/// PBKDF2 加密
|
||||
/// </summary>
|
||||
[SuppressSniffer]
|
||||
public class PBKDF2Encryption
|
||||
public static class PBKDF2Encryption
|
||||
{
|
||||
private const string SaltHashSeparator = ":";
|
||||
|
||||
|
@@ -18,7 +18,7 @@ namespace ThingsGateway.DataEncryption;
|
||||
/// SHA1 加密
|
||||
/// </summary>
|
||||
[SuppressSniffer]
|
||||
public class SHA1Encryption
|
||||
public static class SHA1Encryption
|
||||
{
|
||||
/// <summary>
|
||||
/// SHA1 加密
|
||||
|
@@ -18,6 +18,7 @@ namespace System.ComponentModel.DataAnnotations;
|
||||
/// 数据类型验证特性
|
||||
/// </summary>
|
||||
[SuppressSniffer]
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false)]
|
||||
public sealed class DataValidationAttribute : ValidationAttribute
|
||||
{
|
||||
/// <summary>
|
||||
|
@@ -215,7 +215,7 @@ public static class DependencyInjectionServiceCollectionExtensions
|
||||
private static void AddDispatchProxy(IServiceCollection services, Type dependencyType, Type type, Type proxyType, Type inter, bool hasTarget = true)
|
||||
{
|
||||
proxyType ??= GlobalServiceProxyType;
|
||||
if (proxyType == null || (type != null && type.IsDefined(typeof(SuppressProxyAttribute), true))) return;
|
||||
if (proxyType == null || (type?.IsDefined(typeof(SuppressProxyAttribute), true) == true)) return;
|
||||
|
||||
var lifetime = TryGetServiceLifetime(dependencyType);
|
||||
|
||||
|
@@ -220,8 +220,7 @@ internal sealed class DynamicApiControllerApplicationModelConvention : IApplicat
|
||||
// 解决 Gitee 该 Issue:https://gitee.com/dotnetchina/Furion/issues/I59B74
|
||||
if (CheckIsForceWithDefaultRoute(controllerApiDescriptionSettings)
|
||||
&& !string.IsNullOrWhiteSpace(_dynamicApiControllerSettings.DefaultRoutePrefix)
|
||||
&& controller.Selectors[0] != null
|
||||
&& controller.Selectors[0].AttributeRouteModel != null
|
||||
&& controller.Selectors[0]?.AttributeRouteModel != null
|
||||
&& !ForceWithDefaultPrefixRouteControllerTypes.Contains(controller.ControllerType))
|
||||
{
|
||||
// 读取模块
|
||||
|
@@ -126,7 +126,7 @@ public static class DynamicApiControllerServiceCollectionExtensions
|
||||
{
|
||||
var partManager = mvcBuilder.PartManager;
|
||||
// 载入程序集部件
|
||||
if (partManager != null && assemblies != null && assemblies.Any())
|
||||
if (partManager != null && assemblies?.Any() == true)
|
||||
{
|
||||
foreach (var assembly in assemblies)
|
||||
{
|
||||
|
@@ -48,7 +48,7 @@ internal sealed class DynamicApiRuntimeChangeProvider : IDynamicApiRuntimeChange
|
||||
/// <param name="assemblies">程序集</param>
|
||||
public void AddAssemblies(params Assembly[] assemblies)
|
||||
{
|
||||
if (assemblies != null && assemblies.Length > 0)
|
||||
if (assemblies?.Length > 0)
|
||||
{
|
||||
foreach (var assembly in assemblies)
|
||||
{
|
||||
@@ -63,7 +63,7 @@ internal sealed class DynamicApiRuntimeChangeProvider : IDynamicApiRuntimeChange
|
||||
/// <param name="assemblies">程序集</param>
|
||||
public void AddAssembliesWithNotifyChanges(params Assembly[] assemblies)
|
||||
{
|
||||
if (assemblies != null && assemblies.Length > 0)
|
||||
if (assemblies?.Length > 0)
|
||||
{
|
||||
AddAssemblies(assemblies);
|
||||
NotifyChanges();
|
||||
@@ -76,7 +76,7 @@ internal sealed class DynamicApiRuntimeChangeProvider : IDynamicApiRuntimeChange
|
||||
/// <param name="assemblyNames">程序集名称</param>
|
||||
public void RemoveAssemblies(params string[] assemblyNames)
|
||||
{
|
||||
if (assemblyNames != null && assemblyNames.Length > 0)
|
||||
if (assemblyNames?.Length > 0)
|
||||
{
|
||||
foreach (var assemblyName in assemblyNames)
|
||||
{
|
||||
@@ -93,7 +93,7 @@ internal sealed class DynamicApiRuntimeChangeProvider : IDynamicApiRuntimeChange
|
||||
/// <param name="assemblies">程序集</param>
|
||||
public void RemoveAssemblies(params Assembly[] assemblies)
|
||||
{
|
||||
if (assemblies != null && assemblies.Length > 0)
|
||||
if (assemblies?.Length > 0)
|
||||
{
|
||||
RemoveAssemblies(assemblies.Select(ass => ass.GetName().Name).ToArray());
|
||||
}
|
||||
@@ -105,7 +105,7 @@ internal sealed class DynamicApiRuntimeChangeProvider : IDynamicApiRuntimeChange
|
||||
/// <param name="assemblyNames">程序集名称</param>
|
||||
public void RemoveAssembliesWithNotifyChanges(params string[] assemblyNames)
|
||||
{
|
||||
if (assemblyNames != null && assemblyNames.Length > 0)
|
||||
if (assemblyNames?.Length > 0)
|
||||
{
|
||||
RemoveAssemblies(assemblyNames);
|
||||
NotifyChanges();
|
||||
@@ -118,7 +118,7 @@ internal sealed class DynamicApiRuntimeChangeProvider : IDynamicApiRuntimeChange
|
||||
/// <param name="assemblies">程序集</param>
|
||||
public void RemoveAssembliesWithNotifyChanges(params Assembly[] assemblies)
|
||||
{
|
||||
if (assemblies != null && assemblies.Length > 0)
|
||||
if (assemblies?.Length > 0)
|
||||
{
|
||||
RemoveAssemblies(assemblies);
|
||||
NotifyChanges();
|
||||
|
@@ -49,6 +49,14 @@ public class AppFriendlyException : Exception
|
||||
ErrorCode = OriginErrorCode = errorCode;
|
||||
}
|
||||
|
||||
public AppFriendlyException(string? message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public AppFriendlyException(string? message, Exception? innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 错误码
|
||||
/// </summary>
|
||||
|
@@ -102,7 +102,7 @@ public sealed class Retry
|
||||
}
|
||||
|
||||
// 如果填写了 exceptionTypes 且异常类型不在 exceptionTypes 之内,则终止重试
|
||||
if (exceptionTypes != null && exceptionTypes.Length > 0 && !exceptionTypes.Any(u => u.IsAssignableFrom(ex.GetType())))
|
||||
if (exceptionTypes?.Length > 0 && !exceptionTypes.Any(u => u.IsAssignableFrom(ex.GetType())))
|
||||
{
|
||||
if (finalThrow)
|
||||
{
|
||||
|
@@ -604,7 +604,7 @@ public sealed class LoggingMonitorAttribute : Attribute, IAsyncActionFilter, IAs
|
||||
private string TrySerializeObject(object obj, LoggingMonitorMethod monitorMethod, out bool succeed)
|
||||
{
|
||||
// 排除 IQueryable<> 泛型
|
||||
if (obj != null && obj.GetType().HasImplementedRawGeneric(typeof(IQueryable<>)))
|
||||
if (obj?.GetType().HasImplementedRawGeneric(typeof(IQueryable<>)) == true)
|
||||
{
|
||||
succeed = true;
|
||||
return "{}";
|
||||
@@ -961,8 +961,7 @@ public sealed class LoggingMonitorAttribute : Attribute, IAsyncActionFilter, IAs
|
||||
// token 信息
|
||||
// 判断是否是授权访问
|
||||
var isAuth = actionMethod.GetFoundAttribute<AllowAnonymousAttribute>(true) == null
|
||||
&& resultHttpContext.User != null
|
||||
&& resultHttpContext.User.Identity.IsAuthenticated;
|
||||
&& resultHttpContext.User?.Identity.IsAuthenticated == true;
|
||||
// 获取响应头信息
|
||||
var accessToken = resultHttpContext.Response.Headers["access-token"].ToString();
|
||||
var authorization = string.IsNullOrWhiteSpace(accessToken)
|
||||
|
@@ -47,7 +47,7 @@ public sealed partial class StringLoggingPart
|
||||
/// <param name="args"></param>
|
||||
public StringLoggingPart SetArgs(params object[] args)
|
||||
{
|
||||
if (args != null && args.Length > 0) Args = args;
|
||||
if (args?.Length > 0) Args = args;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@@ -47,7 +47,7 @@ public static class ObjectMapperServiceCollectionExtensions
|
||||
var config = TypeAdapterConfig.GlobalSettings;
|
||||
|
||||
// 扫描所有继承 IRegister 接口的对象映射配置
|
||||
if (assemblies != null && assemblies.Length > 0) config.Scan(assemblies);
|
||||
if (assemblies?.Length > 0) config.Scan(assemblies);
|
||||
|
||||
// 配置支持依赖注入
|
||||
services.AddSingleton(config);
|
||||
|
@@ -235,7 +235,7 @@ public sealed class SchedulerBuilder
|
||||
var schedulerBuilder = new SchedulerBuilder(jobBuilder);
|
||||
|
||||
// 批量添加触发器
|
||||
if (triggerBuilders != null && triggerBuilders.Length > 0)
|
||||
if (triggerBuilders?.Length > 0)
|
||||
{
|
||||
schedulerBuilder.TriggerBuilders.AddRange(triggerBuilders);
|
||||
}
|
||||
|
@@ -192,7 +192,7 @@ public static class ScheduleExtensions
|
||||
var underScoreCasePropertyName = Penetrates.GetNaming(propertyName, NamingConventions.UnderScoreCase);
|
||||
|
||||
// 处理忽略属性问题
|
||||
if (ignorePropertyNames != null && ignorePropertyNames.Length > 0)
|
||||
if (ignorePropertyNames?.Length > 0)
|
||||
{
|
||||
if (ignorePropertyNames.Contains(propertyName, StringComparer.OrdinalIgnoreCase)
|
||||
|| ignorePropertyNames.Contains(camelCasePropertyName, StringComparer.OrdinalIgnoreCase)
|
||||
|
@@ -327,7 +327,7 @@ internal sealed class ScheduleHostedService : BackgroundService
|
||||
};
|
||||
|
||||
// 是否定义 FallbackAsync 方法
|
||||
var isDefinedFallbackAsyncMethod = jobHandler != null && jobHandler.GetType().GetMethod(nameof(IJob.FallbackAsync)
|
||||
var isDefinedFallbackAsyncMethod = jobHandler?.GetType().GetMethod(nameof(IJob.FallbackAsync)
|
||||
, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly
|
||||
, null
|
||||
, new[] { typeof(JobExecutedContext), typeof(CancellationToken) }
|
||||
|
@@ -101,7 +101,7 @@ public class HttpJob : IJob
|
||||
}
|
||||
|
||||
// 添加请求头
|
||||
if (httpJobMessage.Headers != null && httpJobMessage.Headers.Count > 0)
|
||||
if (httpJobMessage.Headers?.Count > 0)
|
||||
{
|
||||
foreach (var (name, value) in httpJobMessage.Headers)
|
||||
{
|
||||
|
@@ -711,7 +711,7 @@ public static class SpecificationDocumentBuilder
|
||||
.Union(
|
||||
actions.SelectMany(u => GetActionGroups(u))
|
||||
)
|
||||
.Where(u => u != null && u.Visible)
|
||||
.Where(u => u?.Visible == true)
|
||||
// 分组后取最大排序
|
||||
.GroupBy(u => u.Group)
|
||||
.Select(u => new GroupExtraInfo
|
||||
|
@@ -47,7 +47,7 @@ public static class TP
|
||||
}
|
||||
|
||||
// 添加项
|
||||
if (items != null && items.Length > 0)
|
||||
if (items?.Length > 0)
|
||||
{
|
||||
var propMaxLength = items.Where(u => _lazyRegex.Value.IsMatch(u))
|
||||
.DefaultIfEmpty(string.Empty)
|
||||
|
@@ -343,7 +343,7 @@ public partial class Crontab
|
||||
|
||||
// 如果存在且唯一,则进入下一轮判断
|
||||
// 接下来的判断是处理 SUN + L 的情况,如 SUNL == 0L == SUNDAY,它们都是合法的 Cron 值
|
||||
if (replaceVal != null && replaceVal.Count == 1)
|
||||
if (replaceVal?.Count == 1)
|
||||
{
|
||||
var missingParser = "";
|
||||
|
||||
|
@@ -140,10 +140,10 @@ public static class UnifyContext
|
||||
if (unifyResultSettings == null) return;
|
||||
|
||||
// 篡改响应状态码
|
||||
if (unifyResultSettings.AdaptStatusCodes != null && unifyResultSettings.AdaptStatusCodes.Length > 0)
|
||||
if (unifyResultSettings.AdaptStatusCodes?.Length > 0)
|
||||
{
|
||||
var adaptStatusCode = unifyResultSettings.AdaptStatusCodes.FirstOrDefault(u => u[0] == statusCode);
|
||||
if (adaptStatusCode != null && adaptStatusCode.Length > 0 && adaptStatusCode[0] > 0)
|
||||
if (adaptStatusCode?.Length > 0 && adaptStatusCode[0] > 0)
|
||||
{
|
||||
context.Response.StatusCode = adaptStatusCode[1];
|
||||
return;
|
||||
|
@@ -139,8 +139,7 @@ internal static class TypeExtensions
|
||||
}
|
||||
|
||||
// 类型限定名是否以 <> 开头且以 AnonymousType 结尾
|
||||
return type.FullName is not null
|
||||
&& type.FullName.StartsWith("<>")
|
||||
return type.FullName?.StartsWith("<>") == true
|
||||
&& type.FullName.Contains("AnonymousType");
|
||||
}
|
||||
|
||||
@@ -463,7 +462,7 @@ internal static class TypeExtensions
|
||||
var elementType = type.GetElementType();
|
||||
|
||||
// 检查元素类型是否是 KeyValuePair<,> 类型
|
||||
if (elementType is null || !elementType.IsKeyValuePair())
|
||||
if (elementType?.IsKeyValuePair() != true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@@ -135,7 +135,7 @@ internal static class V5_ObjectExtensions
|
||||
var runtimeProperty = obj.GetType().GetRuntimeProperty("Count");
|
||||
|
||||
// 反射获取 Count 属性值
|
||||
if (runtimeProperty is not null && runtimeProperty.CanRead && runtimeProperty.PropertyType == typeof(int))
|
||||
if (runtimeProperty?.CanRead == true && runtimeProperty.PropertyType == typeof(int))
|
||||
{
|
||||
count = (int)runtimeProperty.GetValue(obj)!;
|
||||
return true;
|
||||
@@ -332,7 +332,7 @@ internal static class V5_ObjectExtensions
|
||||
var property = current.GetType().GetProperty(part, bindingFlags);
|
||||
|
||||
// 空检查
|
||||
if (property is null || !property.CanRead)
|
||||
if (property?.CanRead != true)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@@ -1591,7 +1591,7 @@ public sealed partial class HttpRequestBuilder
|
||||
public HttpRequestBuilder SetBaseAddress(Uri? baseAddress)
|
||||
{
|
||||
// 检查基地址是否是绝对路径地址
|
||||
if (baseAddress is not null && !baseAddress.IsAbsoluteUri)
|
||||
if (baseAddress?.IsAbsoluteUri == false)
|
||||
{
|
||||
throw new ArgumentException("The base address must be absolute.", nameof(baseAddress));
|
||||
}
|
||||
|
@@ -136,7 +136,7 @@ public partial class Clay
|
||||
{
|
||||
handler(this, new ClayEventArgs(identifier, Contains(identifier)));
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
@@ -177,15 +177,6 @@ public partial class Clay
|
||||
enumerableClay = this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <param name="clay">dynamic 类型的 <see cref="Clay" /></param>
|
||||
/// <param name="enumerableClay">
|
||||
/// <see cref="IEnumerable{T}" />
|
||||
/// </param>
|
||||
/// <param name="rawClay">
|
||||
/// <see cref="Clay" />
|
||||
/// </param>
|
||||
public void Deconstruct(out dynamic clay, out IEnumerable<dynamic?> enumerableClay, out Clay rawClay)
|
||||
{
|
||||
clay = this;
|
||||
@@ -888,7 +879,7 @@ public partial class Clay
|
||||
foreach (var item in values)
|
||||
{
|
||||
// 检查值是否为空值或基本类型的值
|
||||
if (item is null || item.GetType().IsBasicType())
|
||||
if (item?.GetType().IsBasicType() != false)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot extend a single object with null or basic type values.");
|
||||
}
|
||||
|
@@ -12,9 +12,11 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ThingsGateway;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 最小值校验
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
|
||||
public sealed class MinValueAttribute : ValidationAttribute
|
||||
{
|
||||
/// <summary>
|
||||
|
@@ -244,7 +244,6 @@ public ref struct SpanReader
|
||||
while (true)
|
||||
{
|
||||
var bt = ReadByte();
|
||||
if (bt < 0) throw new Exception($"The data stream is out of range! The integer read is {rs: n0}");
|
||||
b = (Byte)bt;
|
||||
|
||||
// 必须转为Int32,否则可能溢出
|
||||
|
@@ -120,7 +120,7 @@ public class MemoryCache : Cache
|
||||
/// <summary>是否包含缓存项</summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public override Boolean ContainsKey(String key) => _cache.TryGetValue(key, out var item) && item != null && !item.Expired;
|
||||
public override Boolean ContainsKey(String key) => _cache.TryGetValue(key, out var item) && item?.Expired == false;
|
||||
|
||||
/// <summary>添加缓存项,已存在时更新</summary>
|
||||
/// <typeparam name="T">值类型</typeparam>
|
||||
@@ -166,7 +166,7 @@ public class MemoryCache : Cache
|
||||
[return: MaybeNull]
|
||||
public override T Get<T>(String key)
|
||||
{
|
||||
if (!_cache.TryGetValue(key, out var item) || item == null || item.Expired) return default;
|
||||
if (!_cache.TryGetValue(key, out var item) || item?.Expired != false) return default;
|
||||
|
||||
return item.Visit<T>();
|
||||
}
|
||||
@@ -712,7 +712,7 @@ public class MemoryCache : Cache
|
||||
for (var i = 0; i < slist.Count && over > 0; i++)
|
||||
{
|
||||
var ss = slist.Values[i];
|
||||
if (ss != null && ss.Count > 0)
|
||||
if (ss?.Count > 0)
|
||||
{
|
||||
foreach (var item in ss)
|
||||
{
|
||||
|
@@ -402,7 +402,7 @@ public class ObjectPool<T> : DisposeBase, IPool<T> where T : notnull
|
||||
/// <param name="args"></param>
|
||||
public void WriteLog(String format, params Object?[] args)
|
||||
{
|
||||
if (Log == null || !Log.Enable) return;
|
||||
if (Log?.Enable != true) return;
|
||||
|
||||
Log.Info(Name + "." + format, args);
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ namespace ThingsGateway.NewLife;
|
||||
/// <summary>
|
||||
/// FileUtil
|
||||
/// </summary>
|
||||
public class FileUtil
|
||||
public static class FileUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// 读取文件
|
||||
|
@@ -633,7 +633,7 @@ public class MachineInfo
|
||||
if (!_excludes.Contains(nameof(Temperature)))
|
||||
{
|
||||
var temp = ReadWmic(@"/namespace:\\root\wmi path MSAcpi_ThermalZoneTemperature", "CurrentTemperature");
|
||||
if (temp != null && temp.Count > 0)
|
||||
if (temp?.Count > 0)
|
||||
{
|
||||
if (temp.TryGetValue("CurrentTemperature", out var str) && !str.IsNullOrEmpty())
|
||||
Temperature = (str.SplitAsInt().Average() - 2732) / 10.0;
|
||||
@@ -651,7 +651,7 @@ public class MachineInfo
|
||||
else if (!_excludes.Contains(nameof(Battery)))
|
||||
{
|
||||
var battery = ReadWmic("path win32_battery", "EstimatedChargeRemaining");
|
||||
if (battery != null && battery.Count > 0)
|
||||
if (battery?.Count > 0)
|
||||
{
|
||||
if (battery.TryGetValue("EstimatedChargeRemaining", out var str) && !str.IsNullOrEmpty())
|
||||
Battery = str.SplitAsInt().Average() / 100.0;
|
||||
@@ -937,7 +937,7 @@ public class MachineInfo
|
||||
foreach (var item in ss)
|
||||
{
|
||||
var ks = item?.Split('=');
|
||||
if (ks != null && ks.Length >= 2)
|
||||
if (ks?.Length >= 2)
|
||||
{
|
||||
var k = ks[0].Trim();
|
||||
var v = ks[1].Trim().TrimInvisible();
|
||||
@@ -1079,7 +1079,7 @@ public class MachineInfo
|
||||
if (root.IsNullOrEmpty()) return 0;
|
||||
|
||||
var driveInfo = new DriveInfo(root);
|
||||
if (driveInfo == null || !driveInfo.IsReady) return -1;
|
||||
if (driveInfo?.IsReady != true) return -1;
|
||||
|
||||
try
|
||||
{
|
||||
|
@@ -6,7 +6,7 @@ namespace ThingsGateway.NewLife.Common;
|
||||
/// <remarks>
|
||||
/// 文档 https://newlifex.com/core/pinyin
|
||||
/// </remarks>
|
||||
public class PinYin
|
||||
public static class PinYin
|
||||
{
|
||||
#region 数组信息
|
||||
private static readonly Int32[] pyValue = new[] {
|
||||
|
@@ -199,7 +199,7 @@ public static class Runtime
|
||||
if (processId != ProcessId) gc = false;
|
||||
|
||||
var log = XTrace.Log;
|
||||
if (log != null && log.Enable && log.Level <= LogLevel.Debug)
|
||||
if (log?.Enable == true && log.Level <= LogLevel.Debug)
|
||||
{
|
||||
p ??= Process.GetCurrentProcess();
|
||||
var gcm = GC.GetTotalMemory(false) / 1024;
|
||||
@@ -243,7 +243,7 @@ public static class Runtime
|
||||
}
|
||||
}
|
||||
|
||||
if (log != null && log.Enable && log.Level <= LogLevel.Debug)
|
||||
if (log?.Enable == true && log.Level <= LogLevel.Debug)
|
||||
{
|
||||
p ??= Process.GetProcessById(processId);
|
||||
p.Refresh();
|
||||
|
@@ -108,7 +108,7 @@ public static class ConfigHelper
|
||||
|
||||
dic[cfg.Key] = cfg.Value;
|
||||
|
||||
if (cfg.Childs != null && cfg.Childs.Count > 0)
|
||||
if (cfg.Childs?.Count > 0)
|
||||
dic[cfg.Key] = cfg.Childs;
|
||||
}
|
||||
|
||||
|
@@ -54,6 +54,6 @@ public class ConfigSection : IConfigSection
|
||||
|
||||
/// <summary>已重载。</summary>
|
||||
/// <returns></returns>
|
||||
public override String ToString() => Childs != null && Childs.Count > 0 ? $"{Key}[{Childs.Count}]" : $"{Key}={Value}";
|
||||
public override String ToString() => Childs?.Count > 0 ? $"{Key}[{Childs.Count}]" : $"{Key}={Value}";
|
||||
#endregion
|
||||
}
|
@@ -75,7 +75,7 @@ public class InIConfigProvider : FileConfigProvider
|
||||
var sb = new StringBuilder();
|
||||
foreach (var item in section.Childs.ToArray())
|
||||
{
|
||||
if (item.Childs != null && item.Childs.Count > 0)
|
||||
if (item.Childs?.Count > 0)
|
||||
{
|
||||
// 段前空一行
|
||||
sb.AppendLine();
|
||||
|
@@ -41,7 +41,7 @@ public class WeakAction<TArgs>
|
||||
var target = Target;
|
||||
if (target == null && Method.IsStatic) return true;
|
||||
|
||||
return target != null && target.IsAlive;
|
||||
return target?.IsAlive == true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@@ -65,7 +65,7 @@ public static class DateExtensions
|
||||
/// <param name="beginTime">开始时间</param>
|
||||
/// <param name="endTime">结束时间</param>
|
||||
/// <returns>时间差</returns>
|
||||
public static string GetDiffTime(this in DateTime beginTime, in DateTime endTime)
|
||||
public static string GetDiffTime(this DateTime beginTime, DateTime endTime)
|
||||
{
|
||||
TimeSpan timeDifference = endTime - beginTime;
|
||||
if (timeDifference.TotalDays >= 1)
|
||||
@@ -88,7 +88,7 @@ public static class DateExtensions
|
||||
/// <param name="beginTime">开始时间</param>
|
||||
/// <param name="endTime">结束时间</param>
|
||||
/// <returns>时间差</returns>
|
||||
public static string GetDiffTime(this in DateTimeOffset beginTime, in DateTimeOffset endTime)
|
||||
public static string GetDiffTime(this DateTimeOffset beginTime, DateTimeOffset endTime)
|
||||
{
|
||||
TimeSpan timeDifference = endTime - beginTime;
|
||||
if (timeDifference.TotalDays >= 1)
|
||||
@@ -108,7 +108,7 @@ public static class DateExtensions
|
||||
/// <summary>
|
||||
/// 返回yyyy-MM-ddTHH:mm:ss.fffffffzzz时间格式字符串
|
||||
/// </summary>
|
||||
public static string ToDefaultDateTimeFormat(this in DateTime dt, TimeSpan offset)
|
||||
public static string ToDefaultDateTimeFormat(this DateTime dt, TimeSpan offset)
|
||||
{
|
||||
if (dt.Kind == DateTimeKind.Utc)
|
||||
return new DateTimeOffset(dt.ToLocalTime(), offset).ToString("yyyy-MM-ddTHH:mm:ss.fffffffzzz");
|
||||
@@ -129,7 +129,7 @@ public static class DateExtensions
|
||||
/// <summary>
|
||||
/// 返回yyyy-MM-ddTHH:mm:ss.fffffffzzz时间格式字符串
|
||||
/// </summary>
|
||||
public static string ToDefaultDateTimeFormat(this in DateTime dt)
|
||||
public static string ToDefaultDateTimeFormat(this DateTime dt)
|
||||
{
|
||||
return dt.ToString("yyyy-MM-ddTHH:mm:ss.fffffffzzz");
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public static class DateExtensions
|
||||
/// <summary>
|
||||
/// 返回yyyy-MM-dd HH-mm-ss-fff zz时间格式字符串
|
||||
/// </summary>
|
||||
public static string ToFileDateTimeFormat(this in DateTime dt)
|
||||
public static string ToFileDateTimeFormat(this DateTime dt)
|
||||
{
|
||||
return ToDefaultDateTimeFormat(dt).Replace(":", "-");
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public static class DateExtensions
|
||||
/// <summary>
|
||||
/// 返回yyyy-MM-dd HH-mm-ss-fff zz时间格式字符串
|
||||
/// </summary>
|
||||
public static string ToFileDateTimeFormat(this in DateTime dt, TimeSpan offset)
|
||||
public static string ToFileDateTimeFormat(this DateTime dt, TimeSpan offset)
|
||||
{
|
||||
return ToDefaultDateTimeFormat(dt, offset).Replace(":", "-");
|
||||
}
|
||||
|
@@ -6,31 +6,18 @@ namespace ThingsGateway.NewLife.Extension;
|
||||
/// <summary>网络结点扩展</summary>
|
||||
public static class EndPointExtensions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="endpoint"></param>
|
||||
/// <returns></returns>
|
||||
public static String ToAddress(this EndPoint endpoint)
|
||||
{
|
||||
return ((IPEndPoint)endpoint).ToAddress();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="endpoint"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static String ToAddress(this IPEndPoint endpoint)
|
||||
{
|
||||
return String.Format("{0}:{1}", endpoint.Address, endpoint.Port);
|
||||
}
|
||||
private static readonly String[] SplitColon = new String[] { ":" };
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static IPEndPoint ToEndPoint(this String address)
|
||||
{
|
||||
var array = address.Split(SplitColon, StringSplitOptions.RemoveEmptyEntries);
|
||||
@@ -44,11 +31,7 @@ public static class EndPointExtensions
|
||||
}
|
||||
|
||||
private static readonly String[] SplitComma = new String[] { "," };
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="addresses"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static IEnumerable<IPEndPoint> ToEndPoints(this String addresses)
|
||||
{
|
||||
var array = addresses.Split(SplitComma, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
@@ -24,7 +24,7 @@ public static class ProcessHelper
|
||||
if (pname == "dotnet" || "*/dotnet".IsMatch(pname))
|
||||
{
|
||||
var args = GetCommandLineArgs(process.Id);
|
||||
if (args != null && args.Length >= 2 && args[0].Contains("dotnet"))
|
||||
if (args?.Length >= 2 && args[0].Contains("dotnet"))
|
||||
{
|
||||
return Path.GetFileNameWithoutExtension(args[1]);
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public static class ProcessHelper
|
||||
if (pname == "java" || "*/java".IsMatch(pname))
|
||||
{
|
||||
var args = GetCommandLineArgs(process.Id);
|
||||
if (args != null && args.Length >= 3 && args[0].Contains("java") && args[1] == "-jar")
|
||||
if (args?.Length >= 3 && args[0].Contains("java") && args[1] == "-jar")
|
||||
{
|
||||
return Path.GetFileNameWithoutExtension(args[2]);
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public static class ProcessHelper
|
||||
/// <returns></returns>
|
||||
public static Process? SafetyKill(this Process process, Int32 msWait = 5_000, Int32 times = 50, Int32 interval = 200)
|
||||
{
|
||||
if (process == null || process.GetHasExited()) return process;
|
||||
if (process?.GetHasExited() != false) return process;
|
||||
|
||||
//XTrace.WriteLine("安全,温柔一刀!PID={0}/{1}", process.Id, process.ProcessName);
|
||||
|
||||
@@ -248,7 +248,7 @@ public static class ProcessHelper
|
||||
/// <returns></returns>
|
||||
public static Process? ForceKill(this Process process, Int32 msWait = 5_000)
|
||||
{
|
||||
if (process == null || process.GetHasExited()) return process;
|
||||
if (process?.GetHasExited() != false) return process;
|
||||
|
||||
//XTrace.WriteLine("强杀,大力出奇迹!PID={0}/{1}", process.Id, process.ProcessName);
|
||||
|
||||
|
@@ -137,7 +137,7 @@ public static class StringHelper
|
||||
public static IDictionary<String, String> SplitAsDictionary(this String? value, String nameValueSeparator = "=", String separator = ";", Boolean trimQuotation = false)
|
||||
{
|
||||
var dic = new NullableDictionary<String, String>(StringComparer.OrdinalIgnoreCase);
|
||||
if (value == null || value.IsNullOrWhiteSpace()) return dic;
|
||||
if (value?.IsNullOrWhiteSpace() != false) return dic;
|
||||
|
||||
if (nameValueSeparator.IsNullOrEmpty()) nameValueSeparator = "=";
|
||||
//if (separator == null || separator.Length <= 0) separator = new String[] { ",", ";" };
|
||||
@@ -515,7 +515,7 @@ public static class StringHelper
|
||||
p += after.Length;
|
||||
|
||||
// 记录位置
|
||||
if (positions != null && positions.Length > 0) positions[0] = p;
|
||||
if (positions?.Length > 0) positions[0] = p;
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(before)) return str[p..];
|
||||
@@ -524,7 +524,7 @@ public static class StringHelper
|
||||
if (f < 0) return String.Empty;
|
||||
|
||||
// 记录位置
|
||||
if (positions != null && positions.Length > 1) positions[1] = f;
|
||||
if (positions?.Length > 1) positions[1] = f;
|
||||
|
||||
if (p >= 0)
|
||||
return str[p..f];
|
||||
@@ -770,7 +770,7 @@ public static class StringHelper
|
||||
{
|
||||
var rs = new List<KeyValuePair<T, Double>>();
|
||||
|
||||
if (list == null || !list.Any()) return rs;
|
||||
if (list?.Any() != true) return rs;
|
||||
if (keys.IsNullOrWhiteSpace()) return rs;
|
||||
if (keySelector == null) throw new ArgumentNullException(nameof(keySelector));
|
||||
|
||||
@@ -825,7 +825,7 @@ public static class StringHelper
|
||||
{
|
||||
var rs = new List<KeyValuePair<T, Double>>();
|
||||
|
||||
if (list == null || !list.Any()) return rs;
|
||||
if (list?.Any() != true) return rs;
|
||||
if (keys.IsNullOrWhiteSpace()) return rs;
|
||||
if (keySelector == null) throw new ArgumentNullException(nameof(keySelector));
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user