using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Controls; namespace Demos.Warden.TagTextEditing { public class TagElement : TagBaseElement { protected T _model; public delegate string GetValueMethod(T model); protected GetValueMethod GetActualValue = null; public void SetModel(T model) { this._model = model; } public void SetGetActualValueMethod(GetValueMethod method) { this.GetActualValue = method; } public override bool IsInitializedProperly() { if (this.TagTitle != null && this.GetActualValue != null || this._model != null) { return true; } else return false; } public TagElement() { } public override string getActualValue() { if (!this.IsInitializedProperly()) { throw new NotInitializedProperlyException(); } return this.GetActualValue(this._model); } public void InitializeState(string tagTitleText, GetValueMethod method) { if (tagTitleText == null || method == null) { throw new ArgumentNullException(); } this.TagTitle = tagTitleText; this.Text = this.TagTitle; this.GetActualValue = method; } public void InitializeState(string tagTitleText, GetValueMethod method, T model) { if (model == null) { throw new ArgumentNullException(); } this._model = model; } } }