增加项目,分层
This commit is contained in:
1 parent
6e995a5bdb
commit
0a3e5af6a9
234 files changed
+26994
-1
No files matched your search
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Product.Publish;
|
||||
|
||||
public class PublishPipeline<TContext> where TContext : PublishContextBase
|
||||
{
|
||||
private readonly IEnumerable<IPublishStep<TContext>> _steps;
|
||||
|
||||
public PublishPipeline(IEnumerable<IPublishStep<TContext>> steps)
|
||||
{
|
||||
_steps = steps;
|
||||
}
|
||||
|
||||
public async Task ExecuteAsync(
|
||||
TContext context,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var step in _steps)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
if (await step.CanExecuteAsync(context, token))
|
||||
{
|
||||
await step.ExecuteAsync(context, token);
|
||||
}
|
||||
|
||||
// 步骤正常提前结束(提交成功/上传到草稿箱)时会写入 Result 并标记完成,此处跳出后续步骤。
|
||||
if (context.WxUpload?.IsCompleted == true)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user