CSharp: Decorator Pattern
项目结构/* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : IBusinessFlow​.cs */ using System; using System.Collections.Generic; using System.Text; using System.Threading; using System.Threading.Tasks; namespace DecoratorPattern.Abstractions { /// summary /// /// /summary public interface IBusinessFlow { string FlowName { get; } Task ExecuteAsync(CancellationToken cancellationToken default); } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : LoggingBusinessFlowDecorator​.cs */ using DecoratorPattern.Abstractions; using Microsoft.Extensions.Logging; using System; using System.Threading; using System.Threading.Tasks; namespace DecoratorPattern.Decorators { /// summary /// /// /summary public class LoggingBusinessFlowDecorator : IBusinessFlow { private readonly IBusinessFlow _innerBusinessFlow; private readonly ILoggerLoggingBusinessFlowDecorator _logger; /// summary /// /// /summary /// param nameinnerBusinessFlow/param /// param namelogger/param /// exception crefArgumentNullException/exception public LoggingBusinessFlowDecorator( IBusinessFlow innerBusinessFlow, ILoggerLoggingBusinessFlowDecorator logger) { _innerBusinessFlow innerBusinessFlow ?? throw new ArgumentNullException(nameof(innerBusinessFlow)); _logger logger ?? throw new ArgumentNullException(nameof(logger)); } public string FlowName _innerBusinessFlow.FlowName; /// summary /// /// /summary /// param namecancellationToken/param /// returns/returns public async Task ExecuteAsync(CancellationToken cancellationToken default) { _logger.LogInformation( 【流程启动】{FlowName} , FlowName); try { await _innerBusinessFlow.ExecuteAsync(cancellationToken); _logger.LogInformation( 【流程完成】{FlowName} , FlowName); } catch (Exception ex) { _logger.LogError(ex, 【流程异常】{FlowName} 执行过程中发生未预期的异常 , FlowName); throw; } } } }/* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : BusinessFlow​.cs */ using DecoratorPattern.Abstractions; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 9.业务订单流程 /// 业务客户接单、订单录入、需求确认、订单跟进、售后对接 /// /summary public class BusinessFlow : IBusinessFlow { public string FlowName 业务订单流程; public async Task ExecuteAsync(CancellationToken cancellationToken default) { // 1.接待客户、确认定制需求 // 2.系统录入订单信息、定价核算 // 3.订单状态全程跟进 // 4.交付后售后对接登记 await Task.Delay(170, cancellationToken); } } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : DesignDrawingFlow​.cs */ using DecoratorPattern.Abstractions; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 2.设计制图流程 /// 业务客户需求对接、首饰建模、CAD制图、方案审核定稿 /// /summary public class DesignDrawingFlow : IBusinessFlow { public string FlowName 设计制图流程; public async Task ExecuteAsync(CancellationToken cancellationToken default) { // 1.收集客户定制需求 // 2.首饰三维建模、CAD图纸绘制 // 3.初稿审核、客户确认 // 4.定稿归档下发生产图纸 await Task.Delay(250, cancellationToken); } } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : FinanceFlow​.cs */ using DecoratorPattern.Abstractions; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 7.财务流程 /// 业务订单对账、成本核算、开票登记、回款核销、账务归档 /// /summary public class FinanceFlow : IBusinessFlow { public string FlowName 财务流程; public async Task ExecuteAsync(CancellationToken cancellationToken default) { // 1.订单金额对账 // 2.原料、人工、加工成本核算 // 3.增值税开票登记 // 4.客户回款核销、账务归档 await Task.Delay(210, cancellationToken); } } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : ItFlow​.cs */ using DecoratorPattern.Abstractions; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 11.IT技术支撑流程 /// 业务业务系统维护、服务器监控、日志运维、故障排查、权限管理 /// /summary public class ItFlow : IBusinessFlow { public string FlowName IT技术支撑流程; public async Task ExecuteAsync(CancellationToken cancellationToken default) { // 1.业务系统日常巡检 // 2.服务器与数据库监控 // 3.系统权限分配与维护 // 4.运维故障记录与修复 await Task.Delay(130, cancellationToken); } } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : LogisticsFlow​.cs */ using DecoratorPattern.Abstractions; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 6.物流流程 /// 业务仓储出库、物流对接、保价发货、物流轨迹录入、签收跟踪 /// /summary public class LogisticsFlow : IBusinessFlow { public string FlowName 物流流程; public async Task ExecuteAsync(CancellationToken cancellationToken default) { // 1.仓库出库核验 // 2.贵重物品保价配置 // 3.物流单生成、揽收发货 // 4.系统录入物流轨迹 await Task.Delay(180, cancellationToken); } } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : MarketingPromotionFlow​.cs */ using DecoratorPattern.Abstractions; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 8.营销推广流程 /// 业务新品宣传、活动策划、线上引流、门店推广、数据统计 /// /summary public class MarketingPromotionFlow : IBusinessFlow { public string FlowName 营销推广流程; public async Task ExecuteAsync(CancellationToken cancellationToken default) { // 1.新品款式宣传素材制作 // 2.线上商城、短视频推广投放 // 3.门店促销活动落地 // 4.推广转化数据统计汇总 await Task.Delay(190, cancellationToken); } } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : PackagingFlow​.cs */ using DecoratorPattern.Abstractions; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 5.包装流程 /// 业务首饰清洁、防护包装、礼盒封装、证书配套、防伪贴标 /// /summary public class PackagingFlow : IBusinessFlow { public string FlowName 包装流程; public async Task ExecuteAsync(CancellationToken cancellationToken default) { // 1.成品清洁除尘 // 2.独立防护包装 // 3.配套质检证书、售后卡 // 4.礼盒封装、粘贴防伪码 await Task.Delay(120, cancellationToken); } } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : PersonnelAdminFlow​.cs */ using DecoratorPattern.Abstractions; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 10.人事行政流程 /// 业务人员考勤、排班调度、行政物资、制度落地、人员异动 /// /summary public class PersonnelAdminFlow : IBusinessFlow { public string FlowName 人事行政流程; public async Task ExecuteAsync(CancellationToken cancellationToken default) { // 1.员工考勤统计、排班调整 // 2.办公物资申领核销 // 3.日常行政巡查 // 4.人员入职、异动、离职登记 await Task.Delay(100, cancellationToken); } } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : ProcessingProductionFlow​.cs */ using DecoratorPattern.Abstractions; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 3.加工生产流程 /// 业务金属浇筑、切割、镶嵌、打磨、抛光、电镀全工序 /// 模拟高并发多工序并行执行 /// /summary public class ProcessingProductionFlow : IBusinessFlow { public string FlowName 加工生产流程; public async Task ExecuteAsync(CancellationToken cancellationToken default) { // 多工序并行模拟工厂高并发生产场景 var tasks new ListTask { SingleProcess(金属基材浇筑成型, 150, cancellationToken), SingleProcess(宝石精密镶嵌定位, 180, cancellationToken), SingleProcess(首饰精细打磨修边, 160, cancellationToken), SingleProcess(镜面抛光真空电镀, 200, cancellationToken) }; await Task.WhenAll(tasks); } /// summary /// 单个生产工序模拟 /// /summary private async Task SingleProcess(string processName, int ms, CancellationToken ct) { await Task.Delay(ms, ct); } } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : QualityInspectionFlow​.cs */ using DecoratorPattern.Abstractions; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 4.质检流程 /// 业务成品尺寸校验、牢固度检测、瑕疵筛查、品级定级、出具质检报告 /// /summary public class QualityInspectionFlow : IBusinessFlow { public string FlowName 质检流程; public async Task ExecuteAsync(CancellationToken cancellationToken default) { // 1.外观瑕疵检测 // 2.宝石牢固度、金属纯度检测 // 3.尺寸参数核对 // 4.合格品定级、不合格品返修登记 await Task.Delay(220, cancellationToken); } } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : RawMaterialPurchaseFlow​.cs */ using DecoratorPattern.Abstractions; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 1.原料采购核验流程 /// 业务珠宝贵金属、宝石原料采购、到货核验、证书校验、入库登记 /// /summary public class RawMaterialPurchaseFlow : IBusinessFlow { public string FlowName 原料采购核验流程; public async Task ExecuteAsync(CancellationToken cancellationToken default) { // 1.核对采购合同与到货清单 // 2.贵金属称重、宝石品级核验 // 3.质检证书真伪校验 // 4.录入供应链系统、完成原料入库 await Task.Delay(200, cancellationToken); } } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : TrainingFlow​.cs */ using DecoratorPattern.Abstractions; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 12.员工培训流程 /// 业务新员工岗前培训、工艺培训、服务培训、考核归档 /// /summary public class TrainingFlow : IBusinessFlow { public string FlowName 员工培训流程; public async Task ExecuteAsync(CancellationToken cancellationToken default) { // 1.制定月度培训计划 // 2.首饰工艺、销售服务培训落地 // 3.员工技能考核 // 4.培训成绩归档存档 await Task.Delay(140, cancellationToken); } } } /* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : WorkflowScheduler​.cs */ using DecoratorPattern.Abstractions; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern.Services { /// summary /// 珠宝全业务流程调度器 /// 负责按行业标准顺序执行所有业务流程、统一日志调度、异常管控、取消令牌支持 /// 线程安全、兼容高并发、适配DI生命周期 /// /summary public class WorkflowScheduler { private readonly IEnumerableIBusinessFlow _businessFlows; private readonly ILoggerWorkflowScheduler _logger; /// summary /// 构造注入有序业务流程集合 日志器 /// /summary public WorkflowScheduler(IEnumerableIBusinessFlow businessFlows, ILoggerWorkflowScheduler logger) { _businessFlows businessFlows ?? throw new ArgumentNullException(nameof(businessFlows)); _logger logger ?? throw new ArgumentNullException(nameof(logger)); } /// summary /// 启动完整珠宝行业业务链路 /// /summary /// param namecancellationToken/param /// returns/returns public async Task RunEntireWorkflowAsync(CancellationToken cancellationToken default) { _logger.LogInformation( 珠宝行业全业务流程调度启动 ); _logger.LogInformation(待执行业务流程总数{Count}, _businessFlows.Count()); var index 0; foreach (var flow in _businessFlows) { if (cancellationToken.IsCancellationRequested) { _logger.LogWarning(流程调度收到取消指令终止后续所有流程); break; } index; _logger.LogInformation(开始执行第{Index}项业务流程, index); try { await flow.ExecuteAsync(cancellationToken); } catch (Exception ex) { _logger.LogError(ex, 第{Index}项流程执行失败全流程终止, index); throw; } } _logger.LogInformation( 珠宝行业全业务流程全部执行完成 ); } } }调用/* # encoding: utf-8 # 版权所有 2026 ©涂聚文有限公司™ ® # 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 # 描述结构型模式 Structural Patterns 装饰器模式 Decorator Pattern 演示业务层 # Author : geovindu,Geovin Du 涂聚文. # IDE : vs2026 c# .net 10 # os : windows 10 # database : mysql 9.0 sql server 2019, postgreSQL 17.0 Oracle 21c Neo4j # Datetime : 2026/07/04 22:16 # User : geovindu # Product : Visual Studio 2026 # Project : CSharpDesignPattern # File : DecoratorBll.cs */ using DecoratorPattern.Abstractions; using DecoratorPattern.Decorators; using DecoratorPattern.Services; using Karambolo.Extensions.Logging.File; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.IO; namespace BLL { /// summary /// /// /summary public class DecoratorBll { public async void Demo() { // 1.构建.NET通用主机DI、日志、生命周期托管 var host Host.CreateDefaultBuilder() .ConfigureLogging((context, loggingBuilder) { // 清空默认日志避免重复输出 loggingBuilder.ClearProviders(); // 控制台日志配置 loggingBuilder.AddConsole(options { options.IncludeScopes true; options.TimestampFormat yyyy-MM-dd HH:mm:ss.fff; }); loggingBuilder.AddFile(fileBuilder { fileBuilder.RootPath Directory.GetCurrentDirectory(); string todayDate DateTime.Now.ToString(yyyy-MM-dd); Directory.CreateDirectory(Path.Combine(fileBuilder.RootPath, Logs, todayDate)); fileBuilder.Files new[] { new LogFileOptions { Path $Logs/{todayDate}/app-debug.log, MaxFileSize 1000000, MinLevel new Dictionarystring, LogLevel { [] LogLevel.Debug }, IncludeScopes true }, new LogFileOptions { Path $Logs/{todayDate}/app-info.log, MaxFileSize 1000000, MinLevel new Dictionarystring, LogLevel { [] LogLevel.Information }, IncludeScopes true }, new LogFileOptions { Path $Logs/{todayDate}/app-warn.log, MaxFileSize 1000000, MinLevel new Dictionarystring, LogLevel { [] LogLevel.Warning }, IncludeScopes true }, new LogFileOptions { Path $Logs/{todayDate}/app-error.log, MaxFileSize 1000000, MinLevel new Dictionarystring, LogLevel { [] LogLevel.Error }, IncludeScopes true } }; }); // 全局日志级别控制 loggingBuilder.SetMinimumLevel(LogLevel.Debug); // 过滤系统低级日志避免刷屏 loggingBuilder.AddFilter(Microsoft, LogLevel.Warning); loggingBuilder.AddFilter(System, LogLevel.Warning); }) .ConfigureServices((context, services) { // 2.注册所有原始业务流程瞬态多线程安全 services.AddTransientRawMaterialPurchaseFlow(); services.AddTransientDesignDrawingFlow(); services.AddTransientProcessingProductionFlow(); services.AddTransientQualityInspectionFlow(); services.AddTransientPackagingFlow(); services.AddTransientLogisticsFlow(); services.AddTransientFinanceFlow(); services.AddTransientMarketingPromotionFlow(); services.AddTransientBusinessFlow(); services.AddTransientPersonnelAdminFlow(); services.AddTransientItFlow(); services.AddTransientTrainingFlow(); // 3.【装饰器模式注入】按真实珠宝业务顺序批量包装日志装饰器 // 业务正向流程采购→设计→生产→质检→包装→物流→财务→营销→业务→人事→IT→培训 services.AddTransientIBusinessFlow(sp WrapDecorator(sp.GetRequiredServiceRawMaterialPurchaseFlow(), sp)); services.AddTransientIBusinessFlow(sp WrapDecorator(sp.GetRequiredServiceDesignDrawingFlow(), sp)); services.AddTransientIBusinessFlow(sp WrapDecorator(sp.GetRequiredServiceProcessingProductionFlow(), sp)); services.AddTransientIBusinessFlow(sp WrapDecorator(sp.GetRequiredServiceQualityInspectionFlow(), sp)); services.AddTransientIBusinessFlow(sp WrapDecorator(sp.GetRequiredServicePackagingFlow(), sp)); services.AddTransientIBusinessFlow(sp WrapDecorator(sp.GetRequiredServiceLogisticsFlow(), sp)); services.AddTransientIBusinessFlow(sp WrapDecorator(sp.GetRequiredServiceFinanceFlow(), sp)); services.AddTransientIBusinessFlow(sp WrapDecorator(sp.GetRequiredServiceMarketingPromotionFlow(), sp)); services.AddTransientIBusinessFlow(sp WrapDecorator(sp.GetRequiredServiceBusinessFlow(), sp)); services.AddTransientIBusinessFlow(sp WrapDecorator(sp.GetRequiredServicePersonnelAdminFlow(), sp)); services.AddTransientIBusinessFlow(sp WrapDecorator(sp.GetRequiredServiceItFlow(), sp)); services.AddTransientIBusinessFlow(sp WrapDecorator(sp.GetRequiredServiceTrainingFlow(), sp)); // 4.注册调度器 services.AddTransientWorkflowScheduler(); }) .Build(); // 5.执行全流程 using var scope host.Services.CreateScope(); var provider scope.ServiceProvider; var logger provider.GetRequiredServiceILoggerDecoratorBll(); try { var scheduler provider.GetRequiredServiceWorkflowScheduler(); await scheduler.RunEntireWorkflowAsync(); } catch (Exception ex) { logger.LogCritical(ex, 珠宝全业务流程调度发生致命异常); } finally { // 优雅停机刷新日志缓冲区防止日志丢失 await host.StopAsync(); } } /// summary /// 统一包装方法将任意业务流程包装为【日志装饰器流程】 /// 纯原生DI实现无第三方框架依赖 /// /summary private static IBusinessFlow WrapDecorator(IBusinessFlow flow, IServiceProvider sp) { var logger sp.GetRequiredServiceILoggerLoggingBusinessFlowDecorator(); return new LoggingBusinessFlowDecorator(flow, logger); } } }输出本项目展示了一个采用装饰器模式(Decorator Pattern)实现的珠宝行业业务流程管理系统。系统包含12个核心业务流程如原料采购、设计制图、加工生产等每个流程实现IBusinessFlow接口。通过LoggingBusinessFlowDecorator装饰器为各流程动态添加日志功能实现业务逻辑与日志记录的分离。WorkflowScheduler负责按顺序执行所有业务流程支持取消令牌和异常处理。系统采用.NET依赖注入框架结合文件日志和控制台日志实现了灵活的业务流程组合与扩展。代码结构清晰体现了装饰器模式在不修改原有类的情况下动态扩展对象功能的优势。

相关新闻

Spring Boot RESTful API测试类编写实战指南

Spring Boot RESTful API测试类编写实战指南

1. Spring Boot RESTful Demo测试类实战指南 在Java后端开发领域,Spring Boot已经成为构建现代化Web应用的事实标准。最近在帮团队新人排查一个接口问题时,发现很多开发者虽然能快速搭建RESTful服务,但对测试类的编写往往停留在表面。今天我就…

2026/10/9 4:24:01 阅读更多 →
【YOLO26多模态创新改进】全网独家复现创新 | TGRS 2025 | 引入MROD-YOLO的 MJRNet 多模态联合表征网络模块,对可见光与红外信息的早期深度融合、充分发挥多模态互补优势

【YOLO26多模态创新改进】全网独家复现创新 | TGRS 2025 | 引入MROD-YOLO的 MJRNet 多模态联合表征网络模块,对可见光与红外信息的早期深度融合、充分发挥多模态互补优势

一、本文介绍 🔥本文给大家介绍使用 MJRNet 多模态联合表征网络模块改进 YOLO26 多模态目标检测模型,其核心作用是在网络前端实现高质量的多模态联合表征学习,通过对可见光与红外信息的早期深度融合,为后续检测提供信息充分且对齐良好的输入特征。MJRNet 利用全局上下文注…

2026/10/16 7:53:50 阅读更多 →
助睿浏览器市场与用户画像分析-数据分析

助睿浏览器市场与用户画像分析-数据分析

浏览器市场与用户画像分析-数据加工1 实验目的本实验基于“用户-日-浏览器-小时”明细表,完成数据大屏所需的各项统计表加工,包括:浏览器市场格局统计(覆盖率、使用时长)浏览器周活跃趋势统计浏览器使用频率分布统计用…

2026/10/17 14:07:17 阅读更多 →

最新新闻

微信小程序实现MBTI+霍兰德双职业测评全链路

微信小程序实现MBTI+霍兰德双职业测评全链路

简介:本资源是一套完整的微信小程序实战项目,面向前端初学者与心理学应用开发爱好者,提供MBTI职业性格测试与霍兰德职业兴趣测试的双模测评功能实现方案。项目基于原生微信小程序框架开发,涵盖从题目交互、答案采集、维度计分到结…

2026/10/18 3:01:06 阅读更多 →
消息队列多线程消费如何精准保序?四套生产级方案详解

消息队列多线程消费如何精准保序?四套生产级方案详解

1. 这不是“能不能”而是“在哪一层保证”的问题你看到这个标题的第一反应,很可能是:“Kafka 不是天生乱序的吗?RocketMQ 不是靠队列锁保序的吗?多线程一上,顺序不就崩了?”——这恰恰说明你已经踩进了绝大…

2026/10/18 3:01:06 阅读更多 →
TCP与UDP深度剖析:从三次握手到抓包实战与选型

TCP与UDP深度剖析:从三次握手到抓包实战与选型

1. 为什么又要聊TCP和UDP:从一场面试谈起TCP和UDP,这两个名字在网络技术讨论中出现频率绝对排得进前五。我面试过不少做客户端和后端开发的候选人,简历上写着熟悉网络编程、做过高并发项目,但一问到这两个协议的本质区别&#xff…

2026/10/18 3:01:06 阅读更多 →
AE二次开发:C#实现所见即所得的地图输出

AE二次开发:C#实现所见即所得的地图输出

1. 从“截图”到“出图”:为什么要在AE里做地图输出做GIS开发的人都有一个共同的痛点:ArcGIS Engine(简称AE)自带的导出功能,要么太死板,要么太慢,要么出来的图根本没法直接用在报告里。尤其是当…

2026/10/18 3:01:06 阅读更多 →
DeepSeek 架构深度解析:MLA、MoE 与 FP8 的工程实践指南

DeepSeek 架构深度解析:MLA、MoE 与 FP8 的工程实践指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/18 3:01:06 阅读更多 →
Java后端网络面试题:从TCP握手到云原生调试的全链路解析

Java后端网络面试题:从TCP握手到云原生调试的全链路解析

1. 这不是一份“背了就能过”的题库,而是一张网络协议世界的导航图你手头这份标着“2021Java后端面试题整理”的文档,标题里那个“计算机网络相关面试题解”,表面看是求职路上的应试材料,但实际它是一把钥匙——一把打开后端系统底…

2026/10/18 3:00:06 阅读更多 →

日新闻

基于GMM的语音识别系统原理与MATLAB实现详解

基于GMM的语音识别系统原理与MATLAB实现详解

说到基于高斯混合模型(GMM)的语音识别系统,很多人第一反应就是一堆数学公式,觉得门槛很高。但如果你真的在MATLAB里把它落地跑通,会发现核心其实就是三件事:把声音变成特征向量,用GMM给每个类别…

2026/10/18 0:00:55 阅读更多 →
数字图像处理入门:反白、灰度化、调色板修改与导出txt实践

数字图像处理入门:反白、灰度化、调色板修改与导出txt实践

数字图像处理这四个字听起来挺唬人,但落到具体操作上,无非就是让计算机按你的想法“摆弄”像素。我在一个模拟项目X里用了一套特别经典的基础处理流程:对图像做反白、改调色板、彩色转灰度,最后把像素数据导出成txt文件。单看每一…

2026/10/18 0:00:55 阅读更多 →
机器人大脑技术盘点:具身智能的感知、决策与数据闭环

机器人大脑技术盘点:具身智能的感知、决策与数据闭环

如果你的信息流最近也天天刷到“机器人大脑”这个词,你会发现一个很有意思的现象:每个人说的“大脑”根本不是同一个东西。有人指的是大语言模型,有人指的是运动控制系统,还有人指的是能理解物理世界的端到端模型。在2026年这个时…

2026/10/18 0:00:55 阅读更多 →

周新闻

基于GMM的语音识别系统原理与MATLAB实现详解

基于GMM的语音识别系统原理与MATLAB实现详解

说到基于高斯混合模型(GMM)的语音识别系统,很多人第一反应就是一堆数学公式,觉得门槛很高。但如果你真的在MATLAB里把它落地跑通,会发现核心其实就是三件事:把声音变成特征向量,用GMM给每个类别…

2026/10/18 0:00:55 阅读更多 →
数字图像处理入门:反白、灰度化、调色板修改与导出txt实践

数字图像处理入门:反白、灰度化、调色板修改与导出txt实践

数字图像处理这四个字听起来挺唬人,但落到具体操作上,无非就是让计算机按你的想法“摆弄”像素。我在一个模拟项目X里用了一套特别经典的基础处理流程:对图像做反白、改调色板、彩色转灰度,最后把像素数据导出成txt文件。单看每一…

2026/10/18 0:00:55 阅读更多 →
机器人大脑技术盘点:具身智能的感知、决策与数据闭环

机器人大脑技术盘点:具身智能的感知、决策与数据闭环

如果你的信息流最近也天天刷到“机器人大脑”这个词,你会发现一个很有意思的现象:每个人说的“大脑”根本不是同一个东西。有人指的是大语言模型,有人指的是运动控制系统,还有人指的是能理解物理世界的端到端模型。在2026年这个时…

2026/10/18 0:00:55 阅读更多 →

月新闻

我发现了一个新思路:用 Remotion + Claude Code 像写代码一样自动化生成短视频

我发现了一个新思路:用 Remotion + Claude Code 像写代码一样自动化生成短视频

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/18 0:55:02 阅读更多 →
Windows下 Codex 中 Chrome 和 Computer Use 插件不可用问题排查及解决参考方式:TaoToken 统一 Key 配置与验证

Windows下 Codex 中 Chrome 和 Computer Use 插件不可用问题排查及解决参考方式:TaoToken 统一 Key 配置与验证

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/17 17:22:31 阅读更多 →
黑夜航拍船只数据集训练YOLOV5模型全流程解析

黑夜航拍船只数据集训练YOLOV5模型全流程解析

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/16 14:23:36 阅读更多 →