using System.Collections.Generic; using System.Linq; using InABox.Core; namespace Comal.Classes { [UserTracking(typeof(Quote))] public class KitFormula : Entity, IRemotable, IPersistent, ILicense { [EditorSequence(1)] [UniqueCodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)] public string Code { get; set; } [EditorSequence(2)] [TextBoxEditor] public string Description { get; set; } [EditorSequence(3)] [ExpressionEditor(null, typeof(KitFormulaExpressionGenerator))] public virtual string Formula { get; set; } private class KitFormulaExpressionGenerator : IExpressionModelGenerator { public List GetVariables(object?[] items) { var dimensionUnits = items.Select(x => x as QuoteCostSheetItem).Where(x => x != null).Cast(); var variables = new List(); var props = CoreUtils.PropertyList(typeof(QuoteCostSheetItem), x => true, true); foreach (var prop in props.Keys) variables.Add(prop); return variables; } } public override string ToString() { return string.Format("{0}: {1}", Code, Description); } } }