Minor tweaks to ValidatingModelBase

This commit is contained in:
Antony Male 2014-05-02 13:34:24 +01:00
parent aa259c378c
commit ef01444611
2 changed files with 10 additions and 1 deletions

View File

@ -16,6 +16,9 @@ namespace Stylet
/// </summary>
public class Screen : ValidatingModelBase, IScreen
{
public Screen() : base() { }
public Screen(IValidatorAdapter validator) : base(validator) { }
#region WeakEventManager
private Lazy<IWeakEventManager> lazyWeakEventManager = new Lazy<IWeakEventManager>(() => new WeakEventManager(), true);

View File

@ -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
/// </summary>
/// <param name="propertyName">Property to validate</param>
protected virtual async Task ValidatePropertyAsync(string propertyName)
protected virtual async Task ValidatePropertyAsync([CallerMemberName] string propertyName = null)
{
if (this.validator == null)
return;