2023-04-07 22:10:35 +08:00
|
|
|
using Demo.Features;
|
|
|
|
using Demo.Primitives;
|
|
|
|
|
|
|
|
namespace Demo.Models;
|
|
|
|
|
|
|
|
public abstract class Chip : IMetadata
|
|
|
|
{
|
2023-04-09 16:22:54 +08:00
|
|
|
public abstract string SignId { get; }
|
2023-04-07 22:10:35 +08:00
|
|
|
/// <summary>
|
|
|
|
/// 属性
|
|
|
|
/// </summary>
|
|
|
|
public MetadataPropertySet Properties { get; }
|
|
|
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
public Version Version { get; set; } = new Version(0, 0, 0);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 功能
|
|
|
|
/// </summary>
|
2023-04-09 16:22:54 +08:00
|
|
|
public IFeatureWrapper Features { get; }
|
2023-04-07 22:10:35 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 公式
|
|
|
|
/// </summary>
|
|
|
|
public FormulaExecutor Formula { get; protected set; }
|
|
|
|
|
|
|
|
protected Chip(Chip? @base = null, bool needInherit = true)
|
|
|
|
{
|
|
|
|
if (needInherit)
|
|
|
|
{
|
|
|
|
Properties = @base?.Properties ?? new MetadataPropertySet();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Properties = new MetadataPropertySet();
|
|
|
|
}
|
2023-04-09 16:22:54 +08:00
|
|
|
|
|
|
|
Features = FeatureContainer.Instance.BuildWrapper(this);
|
2023-04-07 22:10:35 +08:00
|
|
|
Formula = new FormulaExecutor(null, null);
|
|
|
|
Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
public MetadataPropertySet.MetadataProperty? this[string name]
|
|
|
|
{
|
|
|
|
get => Properties.GetValue(name);
|
|
|
|
set => Properties.SetValue(name, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Chip SetProperty(string name, object? value)
|
|
|
|
{
|
|
|
|
Properties.SetValue(name, value);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public TValue? GetProperty<TValue>(string name)
|
|
|
|
{
|
|
|
|
return Properties.GetValue(name).Cast<TValue>();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 初始化
|
|
|
|
/// </summary>
|
|
|
|
protected virtual void Initialize()
|
|
|
|
{
|
|
|
|
// var properties = this.GetType().GetProperties();
|
|
|
|
}
|
|
|
|
}
|