public void ToReactivePropertyAsSynchronizedConvertBackWhenHasErrorsFalse() { var model = new Model() { Age = 30 }; var prop = model.ToReactivePropertyAsSynchronized( x => x.Age, // property selector x => "Age:" + x, // convert x => int.Parse(x.Replace("Age:", "")), // convertBack ignoreValidationErrorValue: true) .SetValidateNotifyError((string x) => { int result; // no use return int.TryParse(x.Replace("Age:", ""), out result) ? null : "error"; }); prop.Value.Is("Age:30"); prop.Value = "Age:50"; model.Age.Is(50); model.Age = 80; prop.Value.Is("Age:80"); // ignore validation error. prop.Value = "xxxx"; model.Age.Is(80); prop.Value = "Age:10"; model.Age.Is(10); }
public void ToReactivePropertyAsSynchronized() { var model = new Model() { Name = "homuhomu" }; var prop = model.ToReactivePropertyAsSynchronized(x => x.Name); prop.Value.Is("homuhomu"); prop.Value = "madomado"; model.Name.Is("madomado"); model.Name = "mamimami"; prop.Value.Is("mamimami"); }
public void ToReactivePropertyAsSynchronizedConvert() { var model = new Model() { Age = 30 }; var prop = model.ToReactivePropertyAsSynchronized( x => x.Age, // property selector x => "Age:" + x, // convert x => int.Parse(x.Replace("Age:", ""))); // convertBack prop.Value.Is("Age:30"); prop.Value = "Age:50"; model.Age.Is(50); model.Age = 80; prop.Value.Is("Age:80"); }