Example #1
0
        public void TestCollections()
        {
            var numbers = new EditableCollection <int>();
            var results = new EditableCollection <int>();

            using (results.SyncWith(numbers, x => x))
            {
                var viewableResults = results.AsViewableCollection();

                // when doing more than one change:
                // use beginupdate/endupdate to reduce syncing events
                numbers.BeginUpdate();
                try
                {
                    numbers.Add(4);
                    numbers.Add(7);
                }
                finally
                {
                    numbers.EndUpdate();
                }

                // Magically results (x) are already added to the Results list
                CollectionAssert.AreEqual(numbers, viewableResults);

                // You can't add a result to the public Results list
                // Results.Add(17);

                // again: change source collection:
                numbers.Add(8);

                // synced results collection is already updated.
                CollectionAssert.AreEqual(numbers, viewableResults);
            }
        }
        public FilteredParentProvider(ModelMapper mapper)
        {
            var defaultParentProvider = new DefaultParentProvider(mapper);
            var children = defaultParentProvider.Childs;

            if (children != null)
            {
                var collection = new EditableCollection <object>();
                FSyncer = collection.SyncWith(children, CreateTargetItem, DestroyTargetItem, FilterPredicate);

                Childs = collection.AsViewableCollection();
            }
        }