XFEExtension
【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等
关注
0
Fork
0
Star
0
返回提交历史
Modified
XFEExtension.NetCore/XFEExtension.NetCore.csproj
+9
-7
Added
XFEExtension.NetCore/XFEExtension/AllException/StopAction.cs
+37
-0
XFEstudio/XFEExtension
add-新增流程控制语句,现在,你可以通过抛出StopAction异常来执行方法并抛出异常,从而穿插在代码中
c679a45
代码差异
2 个文件
+46
-7
@@ -5,7 +5,7 @@
5
5
<ImplicitUsings>enable</ImplicitUsings>
6
6
<Nullable>enable</Nullable>
7
7
<GenerateDocumentationFile>True</GenerateDocumentationFile>
8
<Version>3.1.6</Version>
8
<Version>3.2.0</Version>
9
9
<Title>XFEExtension</Title>
10
10
<RepositoryUrl>https://github.com/XFEstudio/XFEExtension</RepositoryUrl>
11
11
<AnalysisLevel>latest</AnalysisLevel>
@@ -18,17 +18,19 @@
18
18
<Description>XFEExtension提供,免费ChatGPTAPI接口,快速搭建服务器/客户端,免费通讯服务器,XFE下载器,新增格式等</Description>
19
19
<PackageReadmeFile>README.md</PackageReadmeFile>
20
20
<PackageTags>XFE;拓展;GPT;Server;服务器;测试;XFEExtension</PackageTags>
21
<PackageReleaseNotes>## 调整
21
<PackageReleaseNotes>
22
## 调整
22
23
23
对象解析现在不会对ValueType进行误处理
24
无
24
25
25
## 新增
26
## 新增
26
27
27
无
28
新增流程控制语句,现在,你可以通过抛出StopAction异常来执行方法并抛出异常,从而穿插在代码中
28
29
29
## 严重
30
## 严重
30
31
31
无</PackageReleaseNotes>
32
无
33
</PackageReleaseNotes>
32
34
<NeutralLanguage>zh-CN</NeutralLanguage>
33
35
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
34
36
<PackageLicenseFile>LICENSE</PackageLicenseFile>
@@ -0,0 +1,37 @@
1
namespace XFEExtension.NetCore;
2
3
/// <summary>
4
/// 流程控制:停止并执行方法
5
/// </summary>
6
public class StopAction : Exception
7
{
8
/// <summary>
9
/// 执行方法并抛出异常
10
/// </summary>
11
/// <param name="stopAction">需要执行的方法</param>
12
/// <param name="message">异常消息</param>
13
public StopAction(Action stopAction, string? message = null) : base(message) => stopAction.Invoke();
14
15
/// <summary>
16
/// 执行方法并抛出异常
17
/// </summary>
18
/// <param name="stopAction">需要执行的方法</param>
19
/// <param name="message">异常消息</param>
20
/// <param name="innerException">内部错误</param>
21
public StopAction(Action stopAction, string? message, Exception? innerException) : base(message, innerException) => stopAction.Invoke();
22
23
/// <summary>
24
/// 执行异步方法并抛出异常
25
/// </summary>
26
/// <param name="stopAction">需要执行的方法</param>
27
/// <param name="message">异常消息</param>
28
public StopAction(Func<Task> stopAction, string? message = null) : base(message) => stopAction.Invoke().Wait();
29
30
/// <summary>
31
/// 执行异步方法并抛出异常
32
/// </summary>
33
/// <param name="stopAction">需要执行的方法</param>
34
/// <param name="message">异常消息</param>
35
/// <param name="innerException">内部错误</param>
36
public StopAction(Func<Task> stopAction, string? message, Exception? innerException) : base(message, innerException) => stopAction.Invoke().Wait();
37
}