public PersonViewModel(Person model) { this.Model = model; // ModelのNameプロパティをRxProp化 this.Name = model.ToReactivePropertyAsSynchronized( x => x.Name, ignoreValidationErrorValue: true) .SetValidateAttribute(() => this.Name) .AddTo(this.CompositeDisposable); // ModelのAgeプロパティをRxProp化 this.Age = model.ToReactivePropertyAsSynchronized( x => x.Age, convert: x => x.ToString(), convertBack: x => int.Parse(x), ignoreValidationErrorValue: true) .SetValidateAttribute(() => this.Age) .AddTo(this.CompositeDisposable); // いずれかのプロパティの値がFalseならFalse this.HasErrors = new[] { this.Name.ObserveHasError, this.Age.ObserveHasError } .CombineLatest(x => x.Any(y => y)) .ToReactiveProperty() .AddTo(this.CompositeDisposable); }
public void Insert(Person p) { var target = new Person { ID = GenerateID(), Name = p.Name, Age = p.Age }; DataStore.Add(target); p.ID = target.ID; }
public void Update(Person p) { var target = DataStore.Single(x => x.ID == p.ID); target.Name = p.Name; target.Age = p.Age; }
/// <summary> /// 変更対象を指定する /// </summary> /// <param name="id"></param> public void SetEditTarget(long id) { this.EditTarget = this.repository.Find(id); }
public PersonChanged(Person person) { this.Person = person; }