SharpBoxesCore 1.0.0.9

dotnet add package SharpBoxesCore --version 1.0.0.9
                    
NuGet\Install-Package SharpBoxesCore -Version 1.0.0.9
                    
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="SharpBoxesCore" Version="1.0.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpBoxesCore" Version="1.0.0.9" />
                    
Directory.Packages.props
<PackageReference Include="SharpBoxesCore" />
                    
Project file
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 SharpBoxesCore --version 1.0.0.9
                    
#r "nuget: SharpBoxesCore, 1.0.0.9"
                    
#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.
#addin nuget:?package=SharpBoxesCore&version=1.0.0.9
                    
Install SharpBoxesCore as a Cake Addin
#tool nuget:?package=SharpBoxesCore&version=1.0.0.9
                    
Install SharpBoxesCore as a Cake Tool

SharpBoxesCore

alternate text is missing from this package README image alternate text is missing from this package README image

集成了一些常用的方法; 如通用的缓存静态操作类、通用的反射加载dll类LibLoadHelperHTTPHelperIniHelperXMLHelperZipHelperCSVHelperPreview Features ImportClassHelperEventHelperValidationHelper其他是一些通用的扩展方法类

:bowtie:

It integrates some commonly used methods. Such as the general cache static operation class, the general reflection loading dll class'LibLoadHelper ',' HTTPHelper ',' IniHelper ',' XMLHelper ',' ZipHelper ',' CSVHelper ',' Preview Features Import ',' ClassHelper ',' EventHelper ',' ValidationHelper ', and others are some general extension method classes

Orignal Source: SharpBoxesCore

其他相关工具、扩展 Other Toolkit: SharpBoxesCore.Cuts

其中提供了许多cSharp、xaml有用的代码片段,如OnPropertyChanged的完整属性语句,Task.Run()=>{})的自动环绕;…

which provided lots of csharp、xaml useful code snippets Like full property statement with OnPropertyChanged, auto surround with Task.Run(()=>{ });...

Install

Install-Package SharpBoxesCore

功能代码示例

1. 反射工具(ClassHelper)

// 设置属性的显示名称
ClassHelper.SetDisplayName<Person>("Name", "姓名");
// 设置属性是否可见
ClassHelper.SetBrowsable<Person>("Age", false);
// 设置属性分类
ClassHelper.SetCategory<Person>("Email", "联系信息");

2. INI文件操作(IniHelper)

// 读取INI值
string value = IniHelper.ReadItemValue("Section1", "Key1", "default.ini", "默
认值");
// 写入INI值
IniHelper.WriteItems("Section1", "Key1", "NewValue", "config.ini");

3. ZIP压缩解压(ZipHelper)

// 压缩文件夹
ZipHelper.PackFiles("output.zip", "sourceFolder");
// 解压文件
ZipHelper.UnpackFiles("archive.zip", "outputFolder");

4. CSV操作(CsvOprHelper)

var students = Student.FakeMany(10);
// 创建CSV文件
CsvOprHelper.ToCSV(new List<CsvDataBase> {
    new CsvDataNormal<Student>(students)
}).SaveToFile("students.csv");

5. DLL动态加载(LibLoadHelper)

string message;
var instance = LibLoadHelper.LoadDll<IMyInterface>(
    "MyPlugin.dll", 
    "MyNamespace", 
    "MyClass", 
    out message
);

6. 配置管理(ConfigFileHelper)

// 读取配置
var config = ConfigFileHelper.ReadConfig<AppConfig>();
// 保存配置
ConfigFileHelper.SaveConfig(config);

主要API一览


1. 缓存操作类 (CacheHelper)

功能描述 方法名 参数 返回值 说明
设置缓存 SetCache string key, object value void 将对象存储到缓存中
获取缓存 GetCache string key object 根据键获取缓存对象
删除缓存 RemoveCache string key void 根据键删除缓存

2. 反射加载DLL类 (LibLoadHelper)

功能描述 方法名 参数 返回值 说明
加载DLL并创建实例 LoadDll string dllPath, string namespaceName, string className, out string message T 通过反射加载指定DLL并创建指定类的实例
获取类型 GetTypeFromDll string dllPath, string fullName Type 从指定 DLL 获取指定类型的 Type 对象

3. HTTP请求帮助类 (HTTPHelper)

功能描述 方法名 参数 返回值 说明
发送GET请求 GetRequest string url string 发送 GET 请求并返回响应结果
发送POST请求 PostRequest string url, string jsonData string 发送 POST 请求并返回响应结果

4. INI文件操作类 (IniHelper)

功能描述 方法名 参数 返回值 说明
读取INI值 ReadItemValue string section, string key, string filePath, string defaultValue string 从指定的INI文件中读取值
写入INI值 WriteItems string section, string key, string value, string filePath void 向指定的INI文件写入值

5. XML文件操作类 (XMLHelper)

功能描述 方法名 参数 返回值 说明
序列化对象为XML SerializeToXml object obj, string filePath void 将对象序列化为XML文件
反序列化XML为对象 DeserializeFromXml string filePath, Type type object 将XML文件反序列化为指定类型的对象

6. 压缩与解压工具类 (ZipHelper)

功能描述 方法名 参数 返回值 说明
压缩文件夹 PackFiles string zipFilePath, string sourceFolder void 将指定文件夹压缩为ZIP文件
解压文件 UnpackFiles string zipFilePath, string outputFolder void 将ZIP文件解压到指定目录

7. CSV文件操作类 (CSVHelper)

功能描述 方法名 参数 返回值 说明
导出数据到CSV ToCSV List<CsvDataBase> dataList string 将数据列表导出为CSV格式字符串
保存CSV文件 SaveToFile string filePath void 将CSV格式字符串保存为文件

8. 类型辅助类 (ClassHelper)

功能描述 方法名 参数 返回值 说明
设置属性显示名称 SetDisplayName Type type, string propertyName, string displayName void 给指定类的属性设置自定义显示名称
设置属性是否可见 SetBrowsable Type type, string propertyName, bool isBrowsable void 设置指定属性在设计时是否可见
设置属性分类 SetCategory Type type, string propertyName, string category void 给指定属性设置分类信息

9. 事件管理类 (EventHelper)

功能描述 方法名 参数 返回值 说明
注册事件 RegisterEvent EventHandler handler void 注册一个事件处理程序
触发事件 TriggerEvent object sender, EventArgs e void 触发已注册的事件
移除事件 UnregisterEvent EventHandler handler void 移除一个事件处理程序

10. 数据验证类 (ValidationHelper)

功能描述 方法名 参数 返回值 说明
验证对象有效性 ValidateObject object obj bool 验证传入的对象是否符合预定义的规则
获取验证错误信息 GetValidationErrors object obj List<string> 获取对象的验证错误信息列表

11. 配置文件操作类 (ConfigFileHelper)

功能描述 方法名 参数 返回值 说明
读取配置 ReadConfig string filePath T 从指定路径读取配置文件并返回强类型对象
保存配置 SaveConfig T config void 将强类型对象保存为配置文件

12. 扩展方法类

扩展方法通常用于增强现有类的功能,以下是一些常用扩展方法: | 功能描述 | 方法名 | 参数 | 返回值 | 说明 | |---------|--------|------|--------|------| | 对象克隆 | Clone | T source | T | 深度克隆对象 | | 列表排序 | SortByProperty | List<T> list, Func<T, object> selector | List<T> | 根据指定属性对列表进行排序 |


Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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 was computed.  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 is compatible.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0.9 106 6/5/2025
1.0.0.8 114 6/5/2025
1.0.0.7 132 5/29/2025

Add Result<T> class and AdvancedStopWatch functionality