SharpBoxesCore 1.1.4.3
dotnet add package SharpBoxesCore --version 1.1.4.3
NuGet\Install-Package SharpBoxesCore -Version 1.1.4.3
<PackageReference Include="SharpBoxesCore" Version="1.1.4.3" />
<PackageVersion Include="SharpBoxesCore" Version="1.1.4.3" />
<PackageReference Include="SharpBoxesCore" />
paket add SharpBoxesCore --version 1.1.4.3
#r "nuget: SharpBoxesCore, 1.1.4.3"
#:package SharpBoxesCore@1.1.4.3
#addin nuget:?package=SharpBoxesCore&version=1.1.4.3
#tool nuget:?package=SharpBoxesCore&version=1.1.4.3
SharpBoxesCore
集成了一些常用的方法;如通用的缓存静态操作类、通用的反射加载dll类DynamicLoadHelper、HTTPHelper、IniHelper、XMLHelper、ZipHelper、CSVHelper、Preview Features Import、ClassHelper、EventHelper、ValidationHelper其他是一些通用的扩展方法类
:bowtie:
It integrates some commonly used methods. Such as the general cache static operation class, the general reflection loading dll class'DynamicLoadHelper','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(()=>{ });...
Table of Contents
- Installation
- API Documentation
Install
Install-Package SharpBoxesCore
API Documentation
Helpers
HTTPHelper
用于处理HTTP请求的帮助类。
Methods:
Get(string url)- 发送GET请求Get<T>(string url)- 发送GET请求并反序列化为指定类型Post(string url, string data, Encoding encoding = null)- 发送POST请求Post<T>(string url, string data, Encoding encoding = null)- 发送POST请求并反序列化为指定类型GetAsync(string url)- 异步发送GET请求GetAsync<T>(string url)- 异步发送GET请求并反序列化为指定类型PostAsync(string url, string data, Encoding encoding = null)- 异步发送POST请求PostAsync<T>(string url, string data, Encoding encoding = null)- 异步发送POST请求并反序列化为指定类型
Example:
// 发送GET请求
var response = HTTPHelper.Get("https://api.example.com/data");
var content = response.ReadAsStringAsync().Result;
// 发送GET请求并反序列化为指定类型
var user = HTTPHelper.Get<User>("https://api.example.com/user/123");
// 发送POST请求
var result = HTTPHelper.Post("https://api.example.com/users", "{\"name\":\"John\"}");
IniHelper
用于处理INI文件的操作类。
Methods:
ReadSectionNames(string iniPath)- 读取INI文件中所有节点名称ReadAllItems(string iniPath, string section)- 获取指定节点中的所有条目ReadAllItemKeys(string iniPath, string section)- 获取指定节点中的所有条目的Key列表ReadItemValue(string iniPath, string section, string key, string defaultValue = "")- 读取指定KEY的字符串型值WriteItems(string iniPath, string section, string items)- 写入多个键值对到指定节点WriteValue(string iniPath, string section, string key, string value)- 写入指定的键和值DeleteKey(string iniPath, string section, string key)- 删除指定节点中的指定键DeleteSection(string iniPath, string section)- 删除指定节点EmptySection(string iniPath, string section)- 清空指定节点中的所有内容ToDictionary(string iniPath, string section, char split = '=')- 获取指定节点下的key和value,返回字典
Example:
// 读取INI值
string value = IniHelper.ReadItemValue("config.ini", "Section1", "Key1", "默认值");
// 写入INI值
IniHelper.WriteValue("config.ini", "Section1", "Key1", "NewValue");
// 获取指定节点的字典
var dict = IniHelper.ToDictionary("config.ini", "Section1");
ZipHelper
压缩与解压工具类。
Methods:
PackFiles(string outputFileName, string dirBePacked)- 压缩文件夹UnpackFiles(string fileBeUnpacked, string outputDir)- 解压缩
Example:
// 压缩文件夹
ZipHelper.PackFiles("output.zip", "sourceFolder");
// 解压文件
ZipHelper.UnpackFiles("archive.zip", "outputFolder");
ConfigFileHelper
配置文件操作类。
Properties:
NormalConfigFileName- config.jsonSystemConfigFileName- system.jsonSetupConfigFileName- setup.jsonUserConfigFileName- user.jsonExeFolder- 当前exe所在目录ConfigFolder- 配置文件目录LogFolder- 日志目录DataFolder- 数据目录TempFolder- 临时目录
Methods:
GetFolder(string folderName)- 获取指定名称的文件夹GetNormalConfigFilePathByExePath()- 获取默认配置文件路径GetSystemConfigFilePathByExePath()- 获取系统配置文件路径GetSetupConfigFilePathByExePath()- 获取安装配置文件路径GetUserConfigFilePathByExePath()- 获取用户配置文件路径
ConfigBase Methods:
Save<T>(T t, string filepath)- 保存配置到文件Load<T>(string filepath, out T t)- 从文件加载配置
Example:
// 获取配置文件路径
string configPath = ConfigFileHelper.GetNormalConfigFilePathByExePath();
// 保存配置
var config = new MyConfig { Setting1 = "value" };
config.Save(configPath);
// 加载配置
ConfigFileHelper.Load(configPath, out MyConfig loadedConfig);
PathHelper
路径操作帮助类(具体功能需查看源代码)。
IOHelper
输入输出操作帮助类(具体功能需查看源代码)。
XMLHelper
XML文件操作类(具体功能需查看源代码)。
AdvancedStopWatch
高级计时器类(具体功能需查看源代码)。
FastDateTime
快速日期时间操作类(具体功能需查看源代码)。
FolderDeleteService
文件夹删除服务类(具体功能需查看源代码)。
SmartFileWriter
智能文件写入器(具体功能需查看源代码)。
EventManager
事件管理器(具体功能需查看源代码)。
TCP Helpers
位于 Helpers/TCP 目录下的Socket客户端和服务器帮助类。
Office
CSV
CSV文件操作相关类。
Main Classes:
CSVLite- 轻量级CSV处理类CsvDataBase- CSV数据基类CsvDataNormal<T>- 普通CSV数据类CsvDataBlank- 空CSV数据类CsvDataCustom- 自定义CSV数据类CsvOprHelper- CSV操作帮助类CsvServiceExtensions- CSV服务扩展类
CsvOprHelper Methods:
ToDT<T>(List<T> datas, bool isUseDisplayName = false)- 将列表转换为DataTableToDT<T>(T data, bool isUseDisplayName = false)- 将单个对象转换为DataTableToCSV(DataTable dt, bool isWriteColumnName = true)- 将DataTable转换为CSV格式ToCSV(List<CsvDataBase> csvDatas)- 将CSV数据列表转换为CSV格式SaveToFile(StringBuilder sb, string filename)- 保存到文件AppendDataToFile(StringBuilder sb, string filename)- 追加到文件ReadCsvToList(string csvPath)- 读取CSV到嵌套列表ReadCsvToListEntity<T>(string csvPath, bool useDisplayName = false, ...)- 读取CSV到实体列表
Example:
var students = new List<Student> { /* ... */ };
// 创建CSV文件
var csv = CsvOprHelper.ToCSV(new List<CsvDataBase> {
new CsvDataNormal<Student>(students)
});
csv.SaveToFile("students.csv");
// 从CSV文件读取实体列表
var users = CsvOprHelper.ReadCsvToListEntity<User>("data.csv", useDisplayName: true);
Excel
Excel导出相关类。
Classes:
ExcelExporter- Excel导出器IExcelExporter- Excel导出器接口
Example: ``csharp // Excel导出示例(具体用法需查看源代码)
## Validation
### ValidationHelper
验证帮助类,提供参数验证方法。
**Methods:**
- `Assert(bool condition, string message)` - 断言条件为真
- `MustLessThan<T>(T argument, T limit)` - 验证参数小于限制
- `MustMoreThan<T>(T argument, T limit)` - 验证参数大于限制
- `InRange<T>(T argument, T low, T high)` - 验证参数在范围内
- `ThrowIfNull<T>(T argument)` - 验证参数不为null
- `ArrayLengthNotEqualZero<T>(T[] argument)` - 验证数组长度不为0
- `CollectionCountNotEqualZero<T>(ICollection<T> argument)` - 验证集合元素数量不为0
**Example:**
```csharp
// 验证参数范围
ValidationHelper.InRange(5, 1, 10, "Value must be between 1 and 10");
// 验证参数不为null
ValidationHelper.ThrowIfNull(myObject, "myObject cannot be null");
// 验证参数小于限制
ValidationHelper.MustLessThan(5, 10, "Value must be less than 10");
FormatValidationHelper
格式验证帮助类(具体功能需查看源代码)。
Reflection
ClassHelper
反射类帮助类,提供类的辅助方法。
Methods:
SetDisplayName<T>(string propertyName, string newDisplayName)- 设置属性显示名称SetDescription<T>(string propertyName, string newDesc)- 设置属性描述SetBrowsable<T>(string propertyName, bool isBrowsable)- 设置属性是否可见SetCategory<T>(string propertyName, string newCate)- 设置属性类别GetFieldValue<TInstance, TResult>(TInstance t, string name)- 获取字段值GetPropertyValue<TInstance, TResult>(TInstance t, string name)- 获取属性值SetInstanceFieldValue<TInstance, TValue>(TInstance instance, string name, TValue value)- 设置实例字段值SetInstancePropertyValue<TInstance, TValue>(TInstance instance, string name, TValue value)- 设置实例属性值GetStaticFieldValue<TClass, TResult>(string name)- 获取静态字段值SetStaticFieldValue<TClass, TValue>(string name, TValue value)- 设置静态字段值InvokeInstanceMethod<TInstance, TResult>(TInstance instance, string name, params object[] args)- 调用实例方法InvokeStaticMethod<TClass, TResult>(string name, params object[] args)- 调用静态方法GetStaticMethods<TClass>()- 获取静态方法列表GetInstanceMethods<TInstance>()- 获取实例方法列表IsInstanceOfGenericType<T>(T obj, Type genericType)- 判断对象是否是指定泛型类型
Example:
// 设置属性的显示名称
ClassHelper.SetDisplayName<Person>("Name", "姓名");
// 设置属性是否可见
ClassHelper.SetBrowsable<Person>("Age", false);
// 设置属性分类
ClassHelper.SetCategory<Person>("Email", "联系信息");
// 获取属性值
var name = ClassHelper.GetPropertyValue<Person, string>(person, "Name");
// 调用方法
ClassHelper.InvokeInstanceMethod(person, "SetName", "John");
EventHelper
事件帮助类(具体功能需查看源代码)。
DynamicLoad
DynamicLoadHelper
动态加载DLL的帮助类。
Methods:
LoadDll<T>(string dllName, string namespaceName, string typeName, out string message)- 加载指定的DLL并获取指定类型的实例LoadDll<T>(string dllName, string namespaceName, string typeName, object[] args, out string message)- 加载指定的DLL并获取指定类型的实例(带参数)GetDllModelsFromFolder(string folder, Type baseTypeFilter = null)- 从指定文件夹获取DllModel列表GetDllModelFromFile(string file, Type baseTypeFilter = null)- 从指定文件获取DllModelFindSpecifiedTypeInheritFromAssembly(Assembly assembly, Type baseType = null)- 从程序集中查找指定类型的子类FindSpecifiedTypeInheritFromAssembliesAndSpecifiedAttributes(string dllFile, Type[] baseTypes, Type[] attributes)- 从DLL中查找指定特性的类型FindSpecifiedTypeInheritFromFolderAndSpecifiedAttributes(string folder, Type[] baseTypes, Type[] attributes)- 从文件夹中查找指定特性的类型GetAllNamespacesFromDll(string dllFile)- 获取DLL中所有命名空间GetTypesFromDll(string dllFile)- 获取DLL中所有类型CreateObjectFromType<T>(out string message, object[] args = null)- 创建指定类型的实例FindSpecifiedTypeHasAttributeFromAssembly(Assembly assembly, Type attr)- 从程序集中查找附加了指定Attribute的类型FindSpecifiedPropertyHasAttributeFromType(Type classType, params Type[] attrs)- 从类型中查找附加了指定Attribute的属性FindSpecifiedMethodHasAttributeFromType(Type classType, Type attr)- 从类型中查找附加了指定Attribute的方法
Example:
// 加载DLL并创建实例
string message;
var instance = DynamicLoadHelper.LoadDll<IMyInterface>(
"MyPlugin.dll",
"MyNamespace",
"MyClass",
out message
);
// 从文件夹中查找特定类型的类
var types = DynamicLoadHelper.FindSpecifiedTypeInheritFromFolderAndSpecifiedAttributes(
"Plugins",
new Type[] { typeof(BasePlugin) },
new Type[] { typeof(PluginAttribute) }
);
DataStruct
Data Structures
数据结构相关类,位于 DataStruct/Structure 目录。
Classes:
Point- 点结构Line- 线结构Rectangle1D- 一维矩形Rectangle2D- 二维矩形Circle- 圆形Ellipse- 椭圆Polygon- 多边形Cross- 十字形Hexagon- 六边形Size- 尺寸IShapeStructure- 形状结构接口EmptyShape- 空形状
Math Extensions
数学扩展方法。
Extensions:
Round()- 四舍五入扩展方法Angle()- 计算两点间角度DistanceToLine()- 计算点到线段的距离Translate()- 平移Rotate()- 旋转ExtendLine()- 延长线段ProjectionOfLine()- 计算点在线段上的投影Centroid()- 计算点集的质心IsIntersect()- 判断线段是否相交ToListAsync()- 异步转换为列表
Example: ``csharp // 计算两点间距离 var point1 = new Point(0, 0); var point2 = new Point(3, 4); var distance = point1.DistanceToLine(point2, new Point(1, 1));
// 旋转点 var rotatedPoint = point1.Rotate(45, new Point(0, 0));
// 四舍五入 var roundedValue = 3.14159.Round(2); // 3.14
## Everything
### Everything Search Integration
Everything搜索集成,提供对Everything搜索工具的访问。
**Classes:**
- `Everything` - Everything搜索主类
- `EverythingState` - Everything状态管理
- `EverythingWrapper` - Everything API包装器
- `SearchResult` - 搜索结果类
- 各种查询接口和实现类
**Example:**
```csharp
// 使用Everything搜索
var everything = new Everything();
var results = everything.Search().Name("*.txt").ToList();
Mvvm
RelayCommand
命令实现类,用于MVVM模式。
Example:
// 创建命令
var command = new RelayCommand(param => ExecuteMethod(), param => CanExecuteMethod());
VMBase
ViewModel基类,提供基本的MVVM功能。
Example:
// 继承VMBase
public class MyViewModel : VMBase
{
private string _name;
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
}
TaskHelper
BackgroundTaskManager
后台任务管理器。
Example: ``csharp // 使用后台任务管理器(具体用法需查看源代码)
### ThreadPoolManager
线程池管理器。
**Example:**
``csharp
// 使用线程池管理器(具体用法需查看源代码)
| Product | Versions 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 Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- MiniExcel (>= 1.41.3)
- Newtonsoft.Json (>= 13.0.3)
-
net5.0
- MiniExcel (>= 1.41.3)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on SharpBoxesCore:
| Package | Downloads |
|---|---|
|
SharpCodePad
SharpCodePad 是一个基于 AvalonEdit 的高级代码编辑器控件,集成了代码编辑、语法高亮、编译运行、调试和项目管理等功能。该控件专为 C# 代码编辑和执行设计,适用于需要内嵌代码编辑功能的 WPF 应用程序 |
|
|
SharpCodePad.Compile
Package Description |
|
|
SharpCodePad.VariableDisplayPluginCore
Package Description |
|
|
SharpJSScriptControl
SharpJSScriptControl是一个WPF控件,用来编辑JavaScript脚本代码。同时支持格式化、自动补全、语法高亮、代码折叠、编译、运行等功能。 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.4.3 | 19 | 12/23/2025 |
| 1.1.4.2 | 23 | 12/23/2025 |
| 1.1.4.1 | 264 | 12/16/2025 |
| 1.1.4 | 425 | 12/10/2025 |
| 1.1.3.9 | 180 | 12/4/2025 |
| 1.1.3.8 | 289 | 11/17/2025 |
| 1.1.3.7 | 223 | 11/10/2025 |
| 1.1.3.6 | 205 | 11/9/2025 |
| 1.1.3.5 | 191 | 11/6/2025 |
| 1.1.3.4 | 187 | 11/6/2025 |
| 1.1.3.3 | 158 | 10/24/2025 |
| 1.1.3.2 | 312 | 9/18/2025 |
| 1.1.3.1 | 172 | 9/10/2025 |
| 1.1.3 | 184 | 9/10/2025 |