using System; using System.Linq.Expressions; using System.Runtime.CompilerServices; using InABox.Core; namespace comal.timesheets { public abstract class DetailShell : Shell where TParent : IDetailModel where TEntity : Entity, IRemotable, IPersistent, new() { public TEntity Entity { get; private set; } protected override void RowChanged() { base.RowChanged(); Entity = Row.ToObject(); } protected override T Get([CallerMemberName] string property = null) { if (Entity != null) { return (T)CoreUtils.GetPropertyValue( Entity, CoreUtils.GetFullPropertyName(Columns[property], ".") ); } return base.Get(property); } protected override void Set(T value, bool notify = true, [CallerMemberName] string property = null) { if (Entity == null) Entity = Row.ToObject(); CoreUtils.SetPropertyValue( Entity, CoreUtils.GetFullPropertyName(Columns[property], "."), value ); base.Set(value,notify,property); } } }