Gu5.Core
1.2.0
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Gu5.Core --version 1.2.0
NuGet\Install-Package Gu5.Core -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Gu5.Core" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Gu5.Core" Version="1.2.0" />
<PackageReference Include="Gu5.Core" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Gu5.Core --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Gu5.Core, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Gu5.Core@1.2.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Gu5.Core&version=1.2.0
#tool nuget:?package=Gu5.Core&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Gu5.Core
.NET 通用工具库
安装与使用
using Gu5.Core
功能列表
异常
| 名称 | 参数 | 默认值 |
|---|---|---|
| GException | msg,pre,code | 操作失败, 发生错误 |
| GExiException | prop,msg | 数据已存在 |
| GSelException | name,msg | 未选择数据项 |
| GMustException | name,msg | 缺少必填项 |
| GMissException | name,msg | 数据不存在 |
| GRuleException | name,msg | 规则错误 |
| GWrongException | name,msg | 数据错误 |
| GNopeException | name,msg | 功能未实现 |
工具
- 计时器扩展
var tw = new TimeWatch();
tw.Start();
// ...Run Task
tw.Stop();
var start = tw.BeginTime;
var end = tw.EndTime;
var dur = tw.Elapsed.TotalMilliseconds;
Console.WriteLine($"{start} - {end}: {dur} ms")
函数式编程
- Then / Else 条件执行
(value > 0)
.Then(() => Console.WriteLine("OK"))
.Else(() => Console.WriteLine("NG"));
- Also / With 条件赋值
var rs = new Object()
.Also(x => x.Init())
.Also(x => x.Validate());
var len = text.With(x => x.Length);
- Find / ForEach / WhereIn 列表操作扩展
- AddRange 集合操作扩展
- Sample 随机采样
- At / Range / Mod 安全索引
- GetDescription 枚举描述
时间序列
- RangeFrom 获取时间轴
var timeline = RangeFrom(start, end);
- Resample 重采样(Pandas
resample+last)
var dict = data.Resample(x => x.Timestamp);
- FFill Pandas
ffill
var values = dict.FFill(keys, lim: 3);
依赖注入
using Gu5.Framework.Core.DependencyInjection;
- AddImplOf 扫描注册所有实现
services.AddImplOf<IMyService>(
(services, serviceType, implType) =>
services.AddSingleton(serviceType, implType),
typeof(IMyService).Assembly
);
- AddSingletonOf / AddScopedOf / AddTransientOf 全局/实例/单次 生命周期
var asm = typeof(T).Assembly;
services.AddSingletonOf<T>(asm);
services.AddScopedOf<T>(asm);
services.AddTransientOf<T>(asm);
动画
- EaseOut 淡出
类型转换
- AsGuid 整型转 GUID
var i = 1;
i.AsGuid(); // 00000001-0000-0000-0000-000000000000
- GetEnums 获取枚举所有值
- GetDescription 获取枚举的 Description 特性
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
-
net8.0
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Gu5.Core:
| Package | Downloads |
|---|---|
|
Gu5.UI
Gu5 UI package with AntdUI |
GitHub repositories
This package is not used by any popular GitHub repositories.
feat: Collection AddRange