Ejemplo n.º 1
0
        protected void RegisterCollection <TWrapper, TModel>(
            ChangeTrackingCollections <TWrapper> wrapperCollection,
            List <TModel> modelCollection) where TWrapper : ModelWrapper <TModel>
        {
            wrapperCollection.CollectionChanged +=
                (s, e) =>
            {
                if (e.OldItems != null)
                {
                    foreach (var item in e.OldItems.Cast <TWrapper>())
                    {
                        modelCollection.Remove(item.Model);
                    }
                }

                if (e.NewItems != null)
                {
                    foreach (var item in e.NewItems.Cast <TWrapper>())
                    {
                        modelCollection.Add(item.Model);
                    }
                }
            };
            RegisterTrackingObject(wrapperCollection);
        }
Ejemplo n.º 2
0
 private void InitializeCollectionPropertes(Friend model)
 {
     if (model.Emails == null)
     {
         throw new ArgumentException("Emails can't be Null");
     }
     Emails = new ChangeTrackingCollections <FriendEmailWrapper>(
         model.Emails.Select(e => new FriendEmailWrapper(e)));
     RegisterCollection(Emails, model.Emails);
 }