ChipDemo/Core/Features/DefaultFeature.cs

27 lines
606 B
C#
Raw Normal View History

2023-04-07 22:10:35 +08:00
using Demo.Models;
namespace Demo.Features;
/// <summary>
/// 默认的功能类,做委托容器用
/// </summary>
/// <typeparam name="TMetadata"></typeparam>
2023-04-08 08:35:57 +08:00
public sealed class DefaultFeature : Feature
2023-04-07 22:10:35 +08:00
{
2023-04-09 16:22:54 +08:00
public DefaultFeature(string name,
FeatureFunction? executeFunction = null,
2023-04-07 22:10:35 +08:00
int order = 1)
{
_executeFunction = executeFunction;
Name = name;
Order = order;
}
2023-04-08 08:35:57 +08:00
private readonly FeatureFunction? _executeFunction;
2023-04-09 16:22:54 +08:00
2023-04-08 08:35:57 +08:00
public override void Execute(IMetadata metadata)
2023-04-07 22:10:35 +08:00
{
_executeFunction?.Invoke(this, metadata);
}
2023-04-09 16:22:54 +08:00
2023-04-07 22:10:35 +08:00
}