コード例 #1
0
 private void ChangeStateRegister(FootballClub entity, IFootballClubConRepository repository)
 {
     entity.PropertyChanged += (sender, e) =>
     {
         if (e.PropertyName != "State")
         {
             entity.State = repository.GetState(entity);
         }
     };
 }
コード例 #2
0
        private void ListenerChangeState(ObservableCollection <FootballClub> data, IFootballClubConRepository repository)
        {
            data.ToList().ForEach(a => ChangeStateRegister(a, repository));

            data.CollectionChanged += (sender, e) =>
            {
                if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                {
                    var entity = e.NewItems[0] as FootballClub;

                    entity.State = "Added";
                }
            };
        }
コード例 #3
0
        //public MainViewModel(IConGenericRepository<FootballClub> repository)
        public MainViewModel(IFootballClubConRepository repository)
        {
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real"
            ////}

            _repository = repository;

            Data = _repository.All();

            ListenerChangeState(Data, _repository);
        }