Beispiel #1
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;
        }
Beispiel #2
0
        public PersonViewModel(Person model)
        {
            this.Model = model;

            this.Name = model.ToReactivePropertyAsSynchronized(
                x => x.Name,
                ignoreValidationErrorValue: true)
                .SetValidateAttribute(() => this.Name);

            this.Age = model.ToReactivePropertyAsSynchronized(
                x => x.Age,
                convert: x => x.ToString(),
                convertBack: x => int.Parse(x),
                ignoreValidationErrorValue: true)
                .SetValidateAttribute(() => this.Age);

            this.HasErrors = new[]
                {
                    this.Name.ObserveHasError,
                    this.Age.ObserveHasError
                }
                .CombineLatest(x => x.Any(y => y))
                .ToReactiveProperty();
        }
Beispiel #3
0
 public void Update(Person p)
 {
     var target = DataStore.Single(x => x.ID == p.ID);
     target.Name = p.Name;
     target.Age = p.Age;
 }
Beispiel #4
0
 public PersonChanged(Person person)
 {
     this.Person = person;
 }
Beispiel #5
0
 /// <summary>
 /// 変更対象を指定する
 /// </summary>
 /// <param name="id"></param>
 public void SetEditTarget(long id)
 {
     this.EditTarget = this.repository.Find(id);
 }