public static ValueChangedSimple <ViewT> BindWrite <WidgetT, ViewT, DomainT>(this IReadWriteValueView <WidgetT, ViewT> view, IReadWriteValue <DomainT> domain, Func <ViewT, DomainT> convertToDomain) { ValueChangedSimple <ViewT> handler = async(newValue, userChange) => { var value = RunConvertingExceptionToFailure(convertToDomain, newValue); Logger.Debug(typeof(ValueViewExtensions), "BindWrite handler called with value after conversion={0}", value); if (value.Success) { view.SetErrors(new HashSet <string>(), userChange); view.IsValidating = true; //await Task.Delay(5000); //testing only try { await domain.DoChange(value.Result, userChange); } finally { view.IsValidating = false; } } else { view.SetErrors(new HashSet <string> { value.ErrorMessage }, userChange); } }; view.Changed += handler; return(handler); }
public async Task Init(string label, string message = null, string title = null) { if (title != null) { Title = title; } _view.Input.Label = label; await _msg.DoChange(message, false, this, false); _input.Reset(false, this); }
public async Task Init(string message = null, string label = null, string title = null) { if (message != null) { await _msg.DoChange(message, false, this, false); } if (label != null) { _inputLabelChanger(label); } if (title != null) { Title = title; } _input.Reset(false, this); }
public static void AddValidatorAndRevalidate <T>(this IReadWriteValue <T> self, Validate <T> validator) { self.Validate += validator; self.DoChange(self.Value, false, self); }
public static async Task <Unit> Revalidate <T>(this IReadWriteValue <T> self, bool isUserChange = false, object sender = null) { return(await self.DoChange(self.Value, isUserChange, sender)); }
/// <summary>shorthand for DoChange() that is: programmatic AND is allowed to store invalid values</summary> public static Task <Unit> DoProgrammaticChange <T>(this IReadWriteValue <T> self, T newValue) { return(self.DoChange(newValue, false, null, false)); }
public async Task Init(string message, string title = null) { Title = title ?? I18n.Translate("Confirmation"); await _message.DoChange(message, false, this, false); }