using Demo.Features;
using Demo.Primitives;
namespace Demo.Models;
public abstract class Chip : IMetadata
{
public abstract string SignId { get; }
///
/// 属性
///
public MetadataPropertySet Properties { get; }
public string Name { get; set; }
public Version Version { get; set; } = new Version(0, 0, 0);
///
/// 功能
///
public IFeatureWrapper Features { get; }
///
/// 公式
///
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();
}
Features = FeatureContainer.Instance.BuildWrapper(this);
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(string name)
{
return Properties.GetValue(name).Cast();
}
///
/// 初始化
///
protected virtual void Initialize()
{
// var properties = this.GetType().GetProperties();
}
}