reactiveui/ReactiveUI — pull request #229 by niik (2013-03-30 22:37:57+00:00)
Title: Support property changes in derived collections

### What does this do?

Suppose you have a simple container class with two properties, Visible and Value. Both properties raise change notification events. Say that you'd like to have a derived collection where only the visible items are included, you'd do something like this.

```c#
var items = new ReactiveCollection(...) { ChangeTrackingEnabled = true };
var visibleItems = items.CreateDerivedCollection(x => x, x => x.IsVisible);

items[0].Visible = false; // This won't update the derived collection.

```
The problem is that the derived collections doesn't support item change notifications propagated through the source collection so you have to provide the derived collection with a reset signal.

```c#
var rst = items.ItemChanged.Where(x=> x.PropertyName == "IsVisible");
var visibleItems = items.CreateDerivedCollection(x => x, x => x.IsVisible, signalReset: rst);
```

This works but it will force the derived collection to completely reset every time an item raises a notification event for the IsVisible property.

The PR aims to add support for updating derived collections when items in the source collection changes (provided it has change tracking enabled) and have the first scenario just work(TM) without a complete reset.

### What has changed?

Changes to source items can result in items being added to or removed from the derived collection as well as items changing places (due to new sort conditions).

In order to make this possible I've moved all of the synchronization logic into the RDC class itself and the class has been split into two parts. The RDC class is exposed to callers of CreateDerivedCollection (for backwards compatibility and sanity) and RDC which contains the magic ingredient TSource (the type of the source collection items).

In order to support all scenarios of value and reference types, orderers and no orderers filters and what not RDC now maintains a map between the item indices and their corresponding indices in the source collection allowing it to track and map changes in the origin collection to their projected counterparts regardless of type and value/reference type changes.

Also supports items existing in multiple places in the source collection whether or not the selector is an identity function or if they're mapped to value types.

### Breaking changes
This PR is a breaking change (and thus opened against rxui5-master) for the following reasons:
* RDC constructor no longer accepts an IDisposable.
* RDC is now explicitly read only (modifying a derived collection makes no sense and now it's enforced. All modifying methods throws and the IsReadOnly property is set to true.

The behavior of ```ReactiveCollectionMixins.CreateDerivedCollection``` is maintained and all code using it to create derived collection will continue to work the same.

### TODO:
- [ ] ```ReactiveCollectionMixins.CreateCollection``` is currently broken. I don't think it will be hard to fix it but I want to get some feedback on this change first.
- [ ] One possible performance optimization would be to maintain an inverse map of source indices to destination indices which would allow for quicker lookups. Needs to be measured and weighed against increase complexity. Could also enable binary search for reverse lookup.
- [ ] Another possible perf gain is to use binary search for ```positionForNewItem```.