Exemple #1
0
        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);
        }
Exemple #2
0
        public void Insert(Person p)
        {
            var target = new Person
            {
                ID = GenerateID(),
                Name = p.Name,
                Age = p.Age
            };

            DataStore.Add(target);
            p.ID = target.ID;
        }
Exemple #3
0
 public void Update(Person p)
 {
     var target = DataStore.Single(x => x.ID == p.ID);
     target.Name = p.Name;
     target.Age = p.Age;
 }
Exemple #4
0
 /// <summary>
 /// 変更対象を指定する
 /// </summary>
 /// <param name="id"></param>
 public void SetEditTarget(long id)
 {
     this.EditTarget = this.repository.Find(id);
 }
Exemple #5
0
 public PersonChanged(Person person)
 {
     this.Person = person;
 }