ViewModelBase - Property/UserProperty implement new interfaces IProperty/IUserProperty respectively

This commit is contained in:
John Colvin committed 2019-03-28 11:52:31 -05:00
1 parent fa95ac6bfd
commit 085f309e1f
1 file changed
+12 -2
+12 -2
View File
@@ -22,6 +22,16 @@ namespace mbts.ui.shell {
void clear_error(string property);
}
interface IProperty<T> : IObservable<(T oldval, T newval)> {
event PropertyChange<T> Changing, Changed;
T Value { get; set; }
}
interface IUserProperty<T> : IProperty<T> {
bool setter_called { get; }
void bypass_setter(T value);
}
public delegate void PropertyChange<T>(T oldval, T newval);
static class ValidationViewModelExtensions {
@@ -159,7 +169,7 @@ namespace mbts.ui.shell {
protected DelegatePropertyAutoWrapper<TModel, TView> backing<TModel, TView>(string name, Func<TModel> get_model, Func<TModel, TView> convert) =>
new DelegatePropertyAutoWrapper<TModel, TView>(this, name, get_model, convert, EqualityComparer<TModel>.Default);
protected class Property<T> : IObservable<(T oldval,T newval)> {
protected class Property<T> : IProperty<T> {
readonly string _propname;
readonly IEqualityComparer<T> _comparer;
readonly ViewModelBase _owner;
@@ -300,7 +310,7 @@ namespace mbts.ui.shell {
/// A thin wrapper around Property&lt;T&gt; that trips a 'setter_called' flag when the value is set through value-property-setter (i.e., through User interaction).
/// <para/>Note: This is class is particularly useful when a default/settings-based value arrives late, and the viewmodel must decide whether or not to override the current value.
/// </summary>
protected class UserProperty<T> : IObservable<(T oldval, T newval)> {
protected class UserProperty<T> : IUserProperty<T> {
readonly Property<T> _prop_model;
public UserProperty(Property<T> prop_model) =>