Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 6bd8ca0

Browse files
committed
Merge pull request #111 from github/feature/pr/tracking-list
Changes-tracking collection for list views
2 parents dc10a39 + f13cac6 commit 6bd8ca0

21 files changed

+3403
-48
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,5 @@ AkavacheSqliteLinkerOverride.cs
234234
NuGetBuild
235235
WiX.Toolset.DummyFile.txt
236236
nunit-UnitTests.xml
237+
nunit-TrackingCollectionTests.xml
237238
GitHubVS.sln.DotSettings

GitHubVS.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CredentialManagement", "src
102102
EndProject
103103
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReactiveUI.Testing_Net45", "submodules\reactiveui\ReactiveUI.Testing\ReactiveUI.Testing_Net45.csproj", "{DD99FD0F-82F6-4C30-930E-4A1D0DF01D65}"
104104
EndProject
105+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrackingCollectionTests", "src\TrackingCollectionTests\TrackingCollectionTests.csproj", "{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}"
106+
EndProject
105107
Global
106108
GlobalSection(SolutionConfigurationPlatforms) = preSolution
107109
Debug|Any CPU = Debug|Any CPU
@@ -401,6 +403,18 @@ Global
401403
{DD99FD0F-82F6-4C30-930E-4A1D0DF01D65}.Release|Any CPU.Build.0 = Release|Any CPU
402404
{DD99FD0F-82F6-4C30-930E-4A1D0DF01D65}.Release|x86.ActiveCfg = Release|Any CPU
403405
{DD99FD0F-82F6-4C30-930E-4A1D0DF01D65}.Release|x86.Build.0 = Release|Any CPU
406+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
407+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
408+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}.Debug|x86.ActiveCfg = Debug|Any CPU
409+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}.Debug|x86.Build.0 = Debug|Any CPU
410+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}.Publish|Any CPU.ActiveCfg = Release|Any CPU
411+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}.Publish|Any CPU.Build.0 = Release|Any CPU
412+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}.Publish|x86.ActiveCfg = Release|Any CPU
413+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}.Publish|x86.Build.0 = Release|Any CPU
414+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
415+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}.Release|Any CPU.Build.0 = Release|Any CPU
416+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}.Release|x86.ActiveCfg = Release|Any CPU
417+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8}.Release|x86.Build.0 = Release|Any CPU
404418
EndGlobalSection
405419
GlobalSection(SolutionProperties) = preSolution
406420
HideSolutionNode = FALSE
@@ -427,5 +441,6 @@ Global
427441
{252CE1C2-027A-4445-A3C2-E4D6C80A935A} = {1E7F7253-A6AF-43C4-A955-37BEDDA01AF9}
428442
{0EC8DBA1-D745-4EE5-993A-6026440EC3BF} = {1E7F7253-A6AF-43C4-A955-37BEDDA01AF9}
429443
{DD99FD0F-82F6-4C30-930E-4A1D0DF01D65} = {1E7F7253-A6AF-43C4-A955-37BEDDA01AB9}
444+
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8} = {8A7DA2E7-262B-4581-807A-1C45CE79CDFD}
430445
EndGlobalSection
431446
EndGlobal

script

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.Specialized;
4+
5+
namespace GitHub.Collections
6+
{
7+
/// <summary>
8+
/// TrackingCollection is a specialization of ObservableCollection that gets items from
9+
/// an observable sequence and updates its contents in such a way that two updates to
10+
/// the same object (as defined by an Equals call) will result in one object on
11+
/// the list being updated (as opposed to having two different instances of the object
12+
/// added to the list).
13+
/// It is always sorted, either via the supplied comparer or using the default comparer
14+
/// for T
15+
/// </summary>
16+
/// <typeparam name="T"></typeparam>
17+
public interface ITrackingCollection<T> : IDisposable, IList<T> where T : ICopyable<T>
18+
{
19+
/// <summary>
20+
/// Sets up an observable as source for the collection.
21+
/// </summary>
22+
/// <param name="obs"></param>
23+
/// <returns>An observable that will return all the items that are
24+
/// fed via the original observer, for further processing by user code
25+
/// if desired</returns>
26+
IObservable<T> Listen(IObservable<T> obs);
27+
IDisposable Subscribe();
28+
IDisposable Subscribe(Action<T> onNext, Action onCompleted);
29+
/// <summary>
30+
/// Set a new comparer for the existing data. This will cause the
31+
/// collection to be resorted and refiltered.
32+
/// </summary>
33+
/// <param name="theComparer">The comparer method for sorting, or null if not sorting</param>
34+
void SetComparer(Func<T, T, int> comparer);
35+
/// <summary>
36+
/// Set a new filter. This will cause the collection to be filtered
37+
/// </summary>
38+
/// <param name="theFilter">The new filter, or null to not have any filtering</param>
39+
void SetFilter(Func<T, int, IList<T>, bool> filter);
40+
void AddItem(T item);
41+
T RemoveItem(T item);
42+
event NotifyCollectionChangedEventHandler CollectionChanged;
43+
}
44+
}

0 commit comments

Comments
 (0)