From ef01444611448ae0faab23e622d42b09f1de7ea5 Mon Sep 17 00:00:00 2001 From: Antony Male Date: Fri, 2 May 2014 13:34:24 +0100 Subject: [PATCH] Minor tweaks to ValidatingModelBase --- Stylet/Screen.cs | 3 +++ Stylet/ValidatingModelBase.cs | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Stylet/Screen.cs b/Stylet/Screen.cs index 0b36e6e..71fcdff 100644 --- a/Stylet/Screen.cs +++ b/Stylet/Screen.cs @@ -16,6 +16,9 @@ namespace Stylet /// public class Screen : ValidatingModelBase, IScreen { + public Screen() : base() { } + public Screen(IValidatorAdapter validator) : base(validator) { } + #region WeakEventManager private Lazy lazyWeakEventManager = new Lazy(() => new WeakEventManager(), true); diff --git a/Stylet/ValidatingModelBase.cs b/Stylet/ValidatingModelBase.cs index 7374968..6af9797 100644 --- a/Stylet/ValidatingModelBase.cs +++ b/Stylet/ValidatingModelBase.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Linq.Expressions; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; @@ -45,6 +46,11 @@ namespace Stylet this.autoValidate = true; } + public ValidatingModelBase(IValidatorAdapter validator) : this() + { + this.validator = validator; + } + private bool ErrorsEqual(string[] e1, string[] e2) { if (e1 == null && e2 == null) @@ -96,7 +102,7 @@ namespace Stylet /// Validate a single property, by name. If you override this, you MUST fire ErrorsChange and call OnValidationStateChanged() if appropriate /// /// Property to validate - protected virtual async Task ValidatePropertyAsync(string propertyName) + protected virtual async Task ValidatePropertyAsync([CallerMemberName] string propertyName = null) { if (this.validator == null) return;