本文整理汇总了C#中System.ComponentModel.Model.ToReactivePropertyAsSynchronized方法的典型用法代码示例。如果您正苦于以下问题:C# Model.ToReactivePropertyAsSynchronized方法的具体用法?C# Model.ToReactivePropertyAsSynchronized怎么用?C# Model.ToReactivePropertyAsSynchronized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.Model
的用法示例。
在下文中一共展示了Model.ToReactivePropertyAsSynchronized方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToReactivePropertyAsSynchronizedConvertBackWhenHasErrorsFalse
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);
}
示例2: ToReactivePropertyAsSynchronized
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");
}
示例3: ToReactivePropertyAsSynchronizedConvert
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");
}