using Demo.Features; using Demo.Primitives; namespace Demo.Models; public abstract class Chip : IMetadata { public abstract Guid SignId { get; } /// /// 属性 /// public MetadataPropertySet Properties { get; } public string Name { get; set; } public Version Version { get; set; } = new Version(0, 0, 0); /// /// 功能 /// public virtual FeatureWrapper 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 = new FeatureWrapper(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(); } }