diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 055abef0a..b406a16d1 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -1,8 +1,6 @@ name: Build on: - push: - branches: [ main ] pull_request: branches: [ main ] @@ -16,53 +14,37 @@ jobs: outputs: nbgv: ${{ steps.nbgv.outputs.SemVer2 }} steps: - - name: Get Current Visual Studio Information - shell: bash - run: | - dotnet tool update -g dotnet-vs - echo "## About RELEASE ##" - vs where release - - - name: Update Visual Studio Latest Release - shell: bash - run: | - echo "## Update RELEASE ##" - vs update release Enterprise - vs modify release Enterprise +mobile +desktop +uwp +web - echo "## About RELEASE Updated ##" - vs where release - echo "##vso[task.prependpath]$(vs where release --prop=InstallationPath)\MSBuild\Current\Bin" - + - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 lfs: true - - name: Install .NET 6 & .NET 7 + - name: Setup .NET 6/7 uses: actions/setup-dotnet@v3 with: dotnet-version: | 6.0.x 7.0.x + 8.0.x - name: NBGV id: nbgv uses: dotnet/nbgv@master with: setAllVars: true - - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v1.3.1 - with: - vs-prerelease: true - name: NuGet Restore - run: msbuild /t:restore /v:minimal /m + run: dotnet restore DynamicData.sln working-directory: src - name: Build - run: msbuild /t:build,pack /maxcpucount /p:NoPackageAnalysis=true /verbosity:minimal /p:Configuration=${{ env.configuration }} + run: dotnet build --no-restore --configuration Release DynamicData.sln + working-directory: src + + - name: Pack + run: dotnet pack --no-restore --configuration Release DynamicData.sln working-directory: src - name: Run Unit Tests and Generate Coverage diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a6f8d344a..074c80149 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,57 +16,34 @@ jobs: outputs: nbgv: ${{ steps.nbgv.outputs.SemVer2 }} steps: - - name: Get Current Visual Studio Information - shell: bash - run: | - dotnet tool update -g dotnet-vs - echo "## About RELEASE ##" - vs where release - - - name: Update Visual Studio Latest Release - shell: bash - run: | - echo "## Update RELEASE ##" - vs update release Enterprise - vs modify release Enterprise +mobile +desktop +uwp +web - echo "## About RELEASE Updated ##" - vs where release - echo "##vso[task.prependpath]$(vs where release --prop=InstallationPath)\MSBuild\Current\Bin" - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Install .NET 6 & .NET 7 + - name: Setup .NET 6/7 uses: actions/setup-dotnet@v3 with: dotnet-version: | 6.0.x 7.0.x + 8.0.x - name: NBGV id: nbgv uses: dotnet/nbgv@master with: setAllVars: true - - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v1.3.1 - with: - vs-prerelease: true - name: NuGet Restore - run: msbuild /t:restore /v:minimal /m + run: dotnet restore DynamicData.sln working-directory: src - name: Build - run: msbuild /t:build,pack /maxcpucount /p:NoPackageAnalysis=true /verbosity:minimal /p:Configuration=${{ env.configuration }} + run: dotnet pack --no-restore --configuration Release DynamicData.sln working-directory: src - - uses: nuget/setup-nuget@v1 - name: Setup NuGet - - name: Changelog uses: glennawatson/ChangeLog@v1 id: changelog diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 92072e553..33f3ac460 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -3,7 +3,7 @@ true - $(NoWarn);1591;1701;1702;1705;VSX1000 + $(NoWarn);1591;1701;1702;1705;VSX1000;SA1010 AnyCPU $(MSBuildProjectName.Contains('Tests')) $(MSBuildProjectName.Contains('Benchmarks')) @@ -65,7 +65,7 @@ - + diff --git a/src/Directory.build.targets b/src/Directory.build.targets index 945cf9815..c03d9f4f1 100644 --- a/src/Directory.build.targets +++ b/src/Directory.build.targets @@ -30,4 +30,8 @@ $(DefineConstants);NETSTANDARD;PORTABLE;P_LINQ;SUPPORTS_BINDINGLIST + + + $(DefineConstants);NETSTANDARD;PORTABLE;P_LINQ;SUPPORTS_BINDINGLIST + diff --git a/src/DynamicData.Tests/API/ApiApprovalTests.DynamicDataTests.DotNet6_0.verified.txt b/src/DynamicData.Tests/API/ApiApprovalTests.DynamicDataTests.DotNet6_0.verified.txt index 951dd27af..89770e31d 100644 --- a/src/DynamicData.Tests/API/ApiApprovalTests.DynamicDataTests.DotNet6_0.verified.txt +++ b/src/DynamicData.Tests/API/ApiApprovalTests.DynamicDataTests.DotNet6_0.verified.txt @@ -134,12 +134,12 @@ namespace DynamicData.Aggregation } public static class StdDevEx { - public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal fallbackValue) { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal fallbackValue) { } public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, double fallbackValue = 0) { } public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, int fallbackValue = 0) { } public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, long fallbackValue = 0) { } public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, float fallbackValue = 0) { } - public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, decimal fallbackValue) + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, decimal fallbackValue) where T : notnull { } public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, double fallbackValue) where T : notnull { } @@ -149,7 +149,7 @@ namespace DynamicData.Aggregation where T : notnull { } public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, float fallbackValue = 0) where T : notnull { } - public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, decimal fallbackValue) + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, decimal fallbackValue) where TObject : notnull where TKey : notnull { } public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, double fallbackValue) @@ -504,7 +504,6 @@ namespace DynamicData.Cache.Internal { public KeySelectorException() { } public KeySelectorException(string message) { } - protected KeySelectorException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public KeySelectorException(string message, System.Exception innerException) { } } [System.Diagnostics.DebuggerDisplay("LockFreeObservableCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Ite" + @@ -1034,7 +1033,6 @@ namespace DynamicData { public MissingKeyException() { } public MissingKeyException(string message) { } - protected MissingKeyException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public MissingKeyException(string message, System.Exception innerException) { } } public class Node : System.IDisposable, System.IEquatable> @@ -2244,7 +2242,6 @@ namespace DynamicData { public SortException() { } public SortException(string message) { } - protected SortException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public SortException(string message, System.Exception innerException) { } } [System.Flags] @@ -2348,7 +2345,6 @@ namespace DynamicData { public UnspecifiedIndexException() { } public UnspecifiedIndexException(string message) { } - protected UnspecifiedIndexException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { } public UnspecifiedIndexException(string message, System.Exception innerException) { } } public class VirtualRequest : DynamicData.IVirtualRequest, System.IEquatable diff --git a/src/DynamicData.Tests/API/ApiApprovalTests.DynamicDataTests.DotNet7_0.verified.txt b/src/DynamicData.Tests/API/ApiApprovalTests.DynamicDataTests.DotNet7_0.verified.txt new file mode 100644 index 000000000..14f45e1de --- /dev/null +++ b/src/DynamicData.Tests/API/ApiApprovalTests.DynamicDataTests.DotNet7_0.verified.txt @@ -0,0 +1,2727 @@ +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("DynamicData.Profile")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("DynamicData.ReactiveUI")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("DynamicData.Tests")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v7.0", FrameworkDisplayName=".NET 7.0")] +namespace DynamicData.Aggregation +{ + public readonly struct AggregateItem : System.IEquatable> + { + public AggregateItem(DynamicData.Aggregation.AggregateType type, TObject item) { } + public TObject Item { get; } + public DynamicData.Aggregation.AggregateType Type { get; } + public bool Equals(DynamicData.Aggregation.AggregateItem other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public static bool operator !=(DynamicData.Aggregation.AggregateItem left, DynamicData.Aggregation.AggregateItem right) { } + public static bool operator ==(DynamicData.Aggregation.AggregateItem left, DynamicData.Aggregation.AggregateItem right) { } + } + public enum AggregateType + { + Add = 0, + Remove = 1, + } + public static class AggregationEx + { + public static System.IObservable> ForAggregation(this System.IObservable> source) + where TObject : notnull { } + public static System.IObservable> ForAggregation(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable InvalidateWhen(this System.IObservable source, System.IObservable invalidate) { } + public static System.IObservable InvalidateWhen(this System.IObservable source, System.IObservable invalidate) { } + } + public static class AvgEx + { + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal emptyValue) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, double emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, int emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, long emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, float emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal emptyValue) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, double emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, float emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, int emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, long emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal emptyValue) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, double emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, int emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, long emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, float emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal emptyValue) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, double emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, float emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, int emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, long emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal emptyValue) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, double emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, int emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, long emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, float emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal emptyValue) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, double emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, float emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, int emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, long emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + } + public static class CountEx + { + public static System.IObservable Count(this System.IObservable> source) { } + public static System.IObservable Count(this System.IObservable> source) + where TObject : notnull { } + public static System.IObservable Count(this System.IObservable> source) + where TObject : notnull { } + public static System.IObservable Count(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable IsEmpty(this System.IObservable> source) + where TObject : notnull { } + public static System.IObservable IsEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable IsNotEmpty(this System.IObservable> source) + where TObject : notnull { } + public static System.IObservable IsNotEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + } + public interface IAggregateChangeSet : System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable { } + public static class MaxEx + { + public static System.IObservable Maximum(this System.IObservable> source, System.Func valueSelector, TResult emptyValue = default) + where TObject : notnull + where TResult : struct, System.IComparable { } + public static System.IObservable Maximum(this System.IObservable> source, System.Func valueSelector, TResult emptyValue = default) + where TObject : notnull + where TKey : notnull + where TResult : struct, System.IComparable { } + public static System.IObservable Minimum(this System.IObservable> source, System.Func valueSelector, TResult emptyValue = default) + where TObject : notnull + where TResult : struct, System.IComparable { } + public static System.IObservable Minimum(this System.IObservable> source, System.Func valueSelector, TResult emptyValue = default) + where TObject : notnull + where TKey : notnull + where TResult : struct, System.IComparable { } + } + public static class StdDevEx + { + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal fallbackValue) { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, double fallbackValue = 0) { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, int fallbackValue = 0) { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, long fallbackValue = 0) { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, float fallbackValue = 0) { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, decimal fallbackValue) + where T : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, double fallbackValue) + where T : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, int fallbackValue) + where T : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, long fallbackValue) + where T : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, float fallbackValue = 0) + where T : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, decimal fallbackValue) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, double fallbackValue) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, int fallbackValue) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, long fallbackValue) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, float fallbackValue = 0) + where TObject : notnull + where TKey : notnull { } + } + public static class SumEx + { + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + } +} +namespace DynamicData.Alias +{ + public static class ObservableCacheAlias + { + public static System.IObservable> Select(this System.IObservable> source, System.Func transformFactory, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Select(this System.IObservable> source, System.Func transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Select(this System.IObservable> source, System.Func transformFactory, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Select(this System.IObservable> source, System.Func transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> SelectMany(this System.IObservable> source, System.Func> manySelector, System.Func keySelector) + where TDestination : notnull + where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { } + public static System.IObservable> SelectSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> SelectSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> SelectSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> SelectSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable, TKey>> SelectTree(this System.IObservable> source, System.Func pivotOn) + where TObject : class + where TKey : notnull { } + public static System.IObservable> Where(this System.IObservable> source, System.Func filter) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Where(this System.IObservable> source, System.IObservable> predicateChanged) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Where(this System.IObservable> source, System.IObservable reapplyFilter) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Where(this System.IObservable> source, System.IObservable> predicateChanged, System.IObservable reapplyFilter) + where TObject : notnull + where TKey : notnull { } + } + public static class ObservableListAlias + { + public static System.IObservable> Select(this System.IObservable> source, System.Func transformFactory) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> SelectMany(this System.IObservable> source, System.Func> manySelector) + where TDestination : notnull + where TSource : notnull { } + public static System.IObservable> Where(this System.IObservable> source, System.Func predicate) + where T : notnull { } + public static System.IObservable> Where(this System.IObservable> source, System.IObservable> predicate) + where T : notnull { } + } +} +namespace DynamicData.Binding +{ + public abstract class AbstractNotifyPropertyChanged : System.ComponentModel.INotifyPropertyChanged + { + protected AbstractNotifyPropertyChanged() { } + public event System.ComponentModel.PropertyChangedEventHandler? PropertyChanged; + protected virtual void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) { } + protected virtual void SetAndRaise(ref T backingField, T newValue, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) { } + protected virtual void SetAndRaise(ref T backingField, T newValue, System.Collections.Generic.IEqualityComparer? comparer, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) { } + [System.Obsolete("This never worked properly in the first place")] + public System.IDisposable SuspendNotifications(bool invokePropertyChangeEventWhenDisposed = true) { } + } + public class BindingListAdaptor : DynamicData.IChangeSetAdaptor + where T : notnull + { + public BindingListAdaptor(System.ComponentModel.BindingList list, int refreshThreshold = 25) { } + public void Adapt(DynamicData.IChangeSet changes) { } + } + public class BindingListAdaptor : DynamicData.IChangeSetAdaptor + where TObject : notnull + where TKey : notnull + { + public BindingListAdaptor(System.ComponentModel.BindingList list, int refreshThreshold = 25) { } + public void Adapt(DynamicData.IChangeSet changes) { } + } + public static class BindingListEx + { + public static System.IObservable> ObserveCollectionChanges(this System.ComponentModel.IBindingList source) { } + public static System.IObservable> ToObservableChangeSet(this System.ComponentModel.BindingList source) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this TCollection source) + where TCollection : System.ComponentModel.IBindingList, System.Collections.Generic.IEnumerable + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.ComponentModel.BindingList source, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + } + public interface IEvaluateAware + { + void Evaluate(); + } + public interface IIndexAware + { + int Index { get; set; } + } + public interface INotifyCollectionChangedSuspender + { + System.IDisposable SuspendCount(); + System.IDisposable SuspendNotifications(); + } + public interface IObservableCollectionAdaptor + where TObject : notnull + where TKey : notnull + { + void Adapt(DynamicData.IChangeSet changes, DynamicData.Binding.IObservableCollection collection); + } + public interface IObservableCollection : DynamicData.Binding.INotifyCollectionChangedSuspender, System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged + { + void Load(System.Collections.Generic.IEnumerable items); + void Move(int oldIndex, int newIndex); + } + public static class IObservableListEx + { + public static System.IObservable> BindToObservableList(this System.IObservable> source, out DynamicData.IObservableList observableList) + where TObject : notnull { } + public static System.IObservable> BindToObservableList(this System.IObservable> source, out DynamicData.IObservableList observableList) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BindToObservableList(this System.IObservable> source, out DynamicData.IObservableList observableList) + where TObject : notnull + where TKey : notnull { } + } + public interface ISortedObservableCollectionAdaptor + where TObject : notnull + where TKey : notnull + { + void Adapt(DynamicData.ISortedChangeSet changes, DynamicData.Binding.IObservableCollection collection); + } + public static class NotifyPropertyChangedEx + { + public static System.IObservable WhenAnyPropertyChanged(this TObject source, params string[] propertiesToMonitor) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenChanged(this TObject source, System.Linq.Expressions.Expression> p1, System.Func resultSelector, System.Func? p1Fallback = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenChanged(this TObject source, System.Linq.Expressions.Expression> p1, System.Linq.Expressions.Expression> p2, System.Func resultSelector, System.Func? p1Fallback = null, System.Func? p2Fallback = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenChanged(this TObject source, System.Linq.Expressions.Expression> p1, System.Linq.Expressions.Expression> p2, System.Linq.Expressions.Expression> p3, System.Func resultSelector, System.Func? p1Fallback = null, System.Func? p2Fallback = null, System.Func? p3Fallback = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenChanged(this TObject source, System.Linq.Expressions.Expression> p1, System.Linq.Expressions.Expression> p2, System.Linq.Expressions.Expression> p3, System.Linq.Expressions.Expression> p4, System.Func resultSelector, System.Func? p1Fallback = null, System.Func? p2Fallback = null, System.Func? p3Fallback = null, System.Func? p4Fallback = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenChanged(this TObject source, System.Linq.Expressions.Expression> p1, System.Linq.Expressions.Expression> p2, System.Linq.Expressions.Expression> p3, System.Linq.Expressions.Expression> p4, System.Linq.Expressions.Expression> p5, System.Func resultSelector, System.Func? p1Fallback = null, System.Func? p2Fallback = null, System.Func? p3Fallback = null, System.Func? p4Fallback = null, System.Func? p5Fallback = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenChanged(this TObject source, System.Linq.Expressions.Expression> p1, System.Linq.Expressions.Expression> p2, System.Linq.Expressions.Expression> p3, System.Linq.Expressions.Expression> p4, System.Linq.Expressions.Expression> p5, System.Linq.Expressions.Expression> p6, System.Func resultSelector, System.Func? p1Fallback = null, System.Func? p2Fallback = null, System.Func? p3Fallback = null, System.Func? p4Fallback = null, System.Func? p5Fallback = null, System.Func? p6Fallback = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable> WhenPropertyChanged(this TObject source, System.Linq.Expressions.Expression> propertyAccessor, bool notifyOnInitialValue = true, System.Func? fallbackValue = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenValueChanged(this TObject source, System.Linq.Expressions.Expression> propertyAccessor, bool notifyOnInitialValue = true, System.Func? fallbackValue = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + } + public class ObservableCollectionAdaptor : DynamicData.IChangeSetAdaptor + where T : notnull + { + public ObservableCollectionAdaptor(DynamicData.Binding.IObservableCollection collection, int refreshThreshold = 25) { } + public void Adapt(DynamicData.IChangeSet changes) { } + } + public class ObservableCollectionAdaptor : DynamicData.Binding.IObservableCollectionAdaptor + where TObject : notnull + where TKey : notnull + { + public ObservableCollectionAdaptor(int refreshThreshold = 25, bool useReplaceForUpdates = false) { } + public void Adapt(DynamicData.IChangeSet changes, DynamicData.Binding.IObservableCollection collection) { } + } + public static class ObservableCollectionEx + { + public static System.IObservable> ObserveCollectionChanges(this System.Collections.Specialized.INotifyCollectionChanged source) { } + public static System.IObservable> ToObservableChangeSet(this System.Collections.ObjectModel.ObservableCollection source) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.Collections.ObjectModel.ReadOnlyObservableCollection source) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this TCollection source) + where TCollection : System.Collections.Specialized.INotifyCollectionChanged, System.Collections.Generic.IEnumerable + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.Collections.ObjectModel.ObservableCollection source, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.Collections.ObjectModel.ReadOnlyObservableCollection source, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + } + public class ObservableCollectionExtended : System.Collections.ObjectModel.ObservableCollection, DynamicData.Binding.INotifyCollectionChangedSuspender, DynamicData.Binding.IObservableCollection, DynamicData.IExtendedList, System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged + { + public ObservableCollectionExtended() { } + public ObservableCollectionExtended(System.Collections.Generic.IEnumerable collection) { } + public ObservableCollectionExtended(System.Collections.Generic.List list) { } + public void AddRange(System.Collections.Generic.IEnumerable collection) { } + public void InsertRange(System.Collections.Generic.IEnumerable collection, int index) { } + public void Load(System.Collections.Generic.IEnumerable items) { } + protected override void OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { } + protected override void OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e) { } + public void RemoveRange(int index, int count) { } + public System.IDisposable SuspendCount() { } + public System.IDisposable SuspendNotifications() { } + } + public sealed class PropertyValue : System.IEquatable> + { + public PropertyValue(TObject sender, TValue value) { } + public TObject Sender { get; } + public TValue Value { get; } + public bool Equals(DynamicData.Binding.PropertyValue? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Binding.PropertyValue? left, DynamicData.Binding.PropertyValue? right) { } + public static bool operator ==(DynamicData.Binding.PropertyValue? left, DynamicData.Binding.PropertyValue? right) { } + } + public enum SortDirection + { + Ascending = 0, + Descending = 1, + } + public class SortExpressionComparer : System.Collections.Generic.List>, System.Collections.Generic.IComparer + { + public SortExpressionComparer() { } + public int Compare(T? x, T? y) { } + public DynamicData.Binding.SortExpressionComparer ThenByAscending(System.Func expression) { } + public DynamicData.Binding.SortExpressionComparer ThenByDescending(System.Func expression) { } + public static DynamicData.Binding.SortExpressionComparer Ascending(System.Func expression) { } + public static DynamicData.Binding.SortExpressionComparer Descending(System.Func expression) { } + } + public class SortExpression + { + public SortExpression(System.Func expression, DynamicData.Binding.SortDirection direction = 0) { } + public DynamicData.Binding.SortDirection Direction { get; } + public System.Func Expression { get; } + } + public class SortedBindingListAdaptor : DynamicData.ISortedChangeSetAdaptor + where TObject : notnull + where TKey : notnull + { + public SortedBindingListAdaptor(System.ComponentModel.BindingList list, int refreshThreshold = 25) { } + public void Adapt(DynamicData.ISortedChangeSet changes) { } + } + public class SortedObservableCollectionAdaptor : DynamicData.Binding.ISortedObservableCollectionAdaptor + where TObject : notnull + where TKey : notnull + { + public SortedObservableCollectionAdaptor(int refreshThreshold = 25, bool useReplaceForUpdates = true) { } + public void Adapt(DynamicData.ISortedChangeSet changes, DynamicData.Binding.IObservableCollection collection) { } + } +} +namespace DynamicData.Cache.Internal +{ + public enum CombineOperator + { + And = 0, + Or = 1, + Xor = 2, + Except = 3, + } + [System.Serializable] + public class KeySelectorException : System.Exception + { + public KeySelectorException() { } + public KeySelectorException(string message) { } + public KeySelectorException(string message, System.Exception innerException) { } + } + [System.Diagnostics.DebuggerDisplay("LockFreeObservableCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Ite" + + "ms)")] + public sealed class LockFreeObservableCache : DynamicData.IConnectableCache, DynamicData.IObservableCache, System.IDisposable + where TObject : notnull + where TKey : notnull + { + public LockFreeObservableCache() { } + public LockFreeObservableCache(System.IObservable> source) { } + public int Count { get; } + public System.IObservable CountChanged { get; } + public System.Collections.Generic.IEnumerable Items { get; } + public System.Collections.Generic.IEnumerable> KeyValues { get; } + public System.Collections.Generic.IEnumerable Keys { get; } + public System.IObservable> Connect(System.Func? predicate = null, bool suppressEmptyChangeSets = true) { } + public void Dispose() { } + public void Edit(System.Action> editAction) { } + public DynamicData.Kernel.Optional Lookup(TKey key) { } + public System.IObservable> Preview(System.Func? predicate = null) { } + public System.IObservable> Watch(TKey key) { } + } +} +namespace DynamicData +{ + public sealed class ChangeAwareCache : DynamicData.ICache, DynamicData.IQuery + where TObject : notnull + where TKey : notnull + { + public ChangeAwareCache() { } + public ChangeAwareCache(System.Collections.Generic.Dictionary data) { } + public ChangeAwareCache(int capacity) { } + public int Count { get; } + public System.Collections.Generic.IEnumerable Items { get; } + public System.Collections.Generic.IEnumerable> KeyValues { get; } + public System.Collections.Generic.IEnumerable Keys { get; } + public void Add(TObject item, TKey key) { } + public void AddOrUpdate(TObject item, TKey key) { } + public DynamicData.ChangeSet CaptureChanges() { } + public void Clear() { } + public void Clone(DynamicData.IChangeSet changes) { } + public DynamicData.Kernel.Optional Lookup(TKey key) { } + public void Refresh() { } + public void Refresh(System.Collections.Generic.IEnumerable keys) { } + public void Refresh(TKey key) { } + public void Remove(System.Collections.Generic.IEnumerable keys) { } + public void Remove(TKey key) { } + } + public class ChangeAwareList : DynamicData.IExtendedList, System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.IEnumerable + where T : notnull + { + public ChangeAwareList(System.Collections.Generic.IEnumerable items) { } + public ChangeAwareList(int capacity = -1) { } + public ChangeAwareList(DynamicData.ChangeAwareList list, bool copyChanges) { } + public int Capacity { get; set; } + public int Count { get; } + public bool IsReadOnly { get; } + public T this[int index] { get; set; } + public void Add(T item) { } + public void AddRange(System.Collections.Generic.IEnumerable collection) { } + public DynamicData.IChangeSet CaptureChanges() { } + public virtual void Clear() { } + public virtual bool Contains(T item) { } + public void CopyTo(T[] array, int arrayIndex) { } + public System.Collections.Generic.IEnumerator GetEnumerator() { } + public int IndexOf(T item) { } + public int IndexOf(T item, System.Collections.Generic.IEqualityComparer equalityComparer) { } + public void Insert(int index, T item) { } + protected virtual void InsertItem(int index, T item) { } + public void InsertRange(System.Collections.Generic.IEnumerable collection, int index) { } + public virtual void Move(int original, int destination) { } + public virtual void Move(T item, int destination) { } + protected virtual void OnInsertItems(int startIndex, System.Collections.Generic.IEnumerable items) { } + protected virtual void OnRemoveItems(int startIndex, System.Collections.Generic.IEnumerable items) { } + protected virtual void OnSetItem(int index, T newItem, T oldItem) { } + public bool Refresh(T item) { } + public void Refresh(T item, int index) { } + public void RefreshAt(int index) { } + public bool Remove(T item) { } + public void RemoveAt(int index) { } + protected void RemoveItem(int index) { } + protected virtual void RemoveItem(int index, T item) { } + public void RemoveRange(int index, int count) { } + protected virtual void SetItem(int index, T item) { } + } + public enum ChangeReason + { + Add = 0, + Update = 1, + Remove = 2, + Refresh = 3, + Moved = 4, + } + public static class ChangeSetEx + { + public static System.Collections.Generic.IEnumerable> Flatten(this DynamicData.IChangeSet source) + where T : notnull { } + public static DynamicData.ChangeType GetChangeType(this DynamicData.ListChangeReason source) { } + public static DynamicData.IChangeSet Transform(this DynamicData.IChangeSet source, System.Func transformer) + where TSource : notnull + where TDestination : notnull { } + public static System.Collections.Generic.IEnumerable> YieldWithoutIndex(this System.Collections.Generic.IEnumerable> source) + where T : notnull { } + } + public class ChangeSet : System.Collections.Generic.List>, DynamicData.IChangeSet, DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where T : notnull + { + public static readonly DynamicData.IChangeSet Empty; + public ChangeSet() { } + public ChangeSet(System.Collections.Generic.IEnumerable> items) { } + public int Adds { get; } + public int Moves { get; } + public int Refreshes { get; } + public int Removes { get; } + public int Replaced { get; } + public int TotalChanges { get; } + public override string ToString() { } + } + public class ChangeSet : System.Collections.Generic.List>, DynamicData.IChangeSet, DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + { + public static readonly DynamicData.ChangeSet Empty; + public ChangeSet() { } + public ChangeSet(System.Collections.Generic.IEnumerable> collection) { } + public ChangeSet(int capacity) { } + public int Adds { get; } + public int Moves { get; } + public int Refreshes { get; } + public int Removes { get; } + public int Updates { get; } + public override string ToString() { } + } + public enum ChangeType + { + Item = 0, + Range = 1, + } + public sealed class Change : System.IEquatable> + where T : notnull + { + public Change(DynamicData.ListChangeReason reason, System.Collections.Generic.IEnumerable items, int index = -1) { } + public Change(DynamicData.ListChangeReason reason, T current, int index = -1) { } + public Change(T current, int currentIndex, int previousIndex) { } + public Change(DynamicData.ListChangeReason reason, T current, DynamicData.Kernel.Optional previous, int currentIndex = -1, int previousIndex = -1) { } + public DynamicData.ItemChange Item { get; } + public DynamicData.RangeChange Range { get; } + public DynamicData.ListChangeReason Reason { get; } + public DynamicData.ChangeType Type { get; } + public bool Equals(DynamicData.Change? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Change left, DynamicData.Change right) { } + public static bool operator ==(DynamicData.Change left, DynamicData.Change right) { } + } + public readonly struct Change : System.IEquatable> + where TObject : notnull + where TKey : notnull + { + public Change(DynamicData.ChangeReason reason, TKey key, TObject current, int index = -1) { } + public Change(TKey key, TObject current, int currentIndex, int previousIndex) { } + public Change(DynamicData.ChangeReason reason, TKey key, TObject current, DynamicData.Kernel.Optional previous, int currentIndex = -1, int previousIndex = -1) { } + public TObject Current { get; } + public int CurrentIndex { get; } + public TKey Key { get; } + public DynamicData.Kernel.Optional Previous { get; } + public int PreviousIndex { get; } + public DynamicData.ChangeReason Reason { get; } + public bool Equals(DynamicData.Change other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Change left, DynamicData.Change right) { } + public static bool operator ==(DynamicData.Change left, DynamicData.Change right) { } + } + public static class EnumerableEx + { + public static System.IObservable> AsObservableChangeSet(this System.Collections.Generic.IEnumerable source, bool completable = false) + where TObject : notnull { } + public static System.IObservable> AsObservableChangeSet(this System.Collections.Generic.IEnumerable source, System.Func keySelector, bool completable = false) + where TObject : notnull + where TKey : notnull { } + } + public interface ICacheUpdater : DynamicData.IQuery + where TObject : notnull + where TKey : notnull + { + void AddOrUpdate(System.Collections.Generic.IEnumerable> keyValuePairs); + void AddOrUpdate(System.Collections.Generic.KeyValuePair item); + void AddOrUpdate(TObject item, TKey key); + void Clear(); + void Clone(DynamicData.IChangeSet changes); + [System.Obsolete("Use Refresh: Same thing but better semantics")] + void Evaluate(); + [System.Obsolete("Use Refresh: Same thing but better semantics")] + void Evaluate(System.Collections.Generic.IEnumerable keys); + [System.Obsolete("Use Refresh: Same thing but better semantics")] + void Evaluate(TKey key); + TKey GetKey(TObject item); + System.Collections.Generic.IEnumerable> GetKeyValues(System.Collections.Generic.IEnumerable items); + void Refresh(); + void Refresh(System.Collections.Generic.IEnumerable keys); + void Refresh(TKey key); + void Remove(System.Collections.Generic.IEnumerable> items); + void Remove(System.Collections.Generic.IEnumerable keys); + void Remove(System.Collections.Generic.KeyValuePair item); + void Remove(TKey key); + void RemoveKey(TKey key); + void RemoveKeys(System.Collections.Generic.IEnumerable key); + [System.Obsolete("Use Clone()")] + void Update(DynamicData.IChangeSet changes); + } + public interface ICache : DynamicData.IQuery + where TObject : notnull + where TKey : notnull + { + void AddOrUpdate(TObject item, TKey key); + void Clear(); + void Clone(DynamicData.IChangeSet changes); + void Refresh(); + void Refresh(System.Collections.Generic.IEnumerable keys); + void Refresh(TKey key); + void Remove(System.Collections.Generic.IEnumerable keys); + void Remove(TKey key); + } + public interface IChangeSet + { + int Adds { get; } + int Capacity { get; set; } + int Count { get; } + int Moves { get; } + int Refreshes { get; } + int Removes { get; } + } + public interface IChangeSetAdaptor + where T : notnull + { + void Adapt(DynamicData.IChangeSet change); + } + public interface IChangeSetAdaptor + where TObject : notnull + where TKey : notnull + { + void Adapt(DynamicData.IChangeSet change); + } + public interface IChangeSet : DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TObject : notnull + { + int Replaced { get; } + int TotalChanges { get; } + } + public interface IChangeSet : DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + { + int Updates { get; } + } + public interface IConnectableCache + where TObject : notnull + where TKey : notnull + { + System.IObservable CountChanged { get; } + System.IObservable> Connect(System.Func? predicate = null, bool suppressEmptyChangeSets = true); + System.IObservable> Preview(System.Func? predicate = null); + System.IObservable> Watch(TKey key); + } + public interface IDistinctChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where T : notnull { } + public interface IExtendedList : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.IEnumerable + { + void AddRange(System.Collections.Generic.IEnumerable collection); + void InsertRange(System.Collections.Generic.IEnumerable collection, int index); + void Move(int original, int destination); + void RemoveRange(int index, int count); + } + public interface IGroupChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, TGroupKey>, System.Collections.Generic.IEnumerable, TGroupKey>>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public interface IGroup + where TObject : notnull + { + TGroup GroupKey { get; } + DynamicData.IObservableList List { get; } + } + public interface IGroup : DynamicData.IKey + where TObject : notnull + where TKey : notnull + { + DynamicData.IObservableCache Cache { get; } + } + public interface IGrouping + where TObject : notnull + { + int Count { get; } + System.Collections.Generic.IEnumerable Items { get; } + TGroupKey Key { get; } + System.Collections.Generic.IEnumerable> KeyValues { get; } + System.Collections.Generic.IEnumerable Keys { get; } + DynamicData.Kernel.Optional Lookup(TKey key); + } + public interface IImmutableGroupChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, TGroupKey>, System.Collections.Generic.IEnumerable, TGroupKey>>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public interface IIntermediateCache : DynamicData.IConnectableCache, DynamicData.IObservableCache, System.IDisposable + where TObject : notnull + where TKey : notnull + { + void Edit(System.Action> updateAction); + } + public interface IKeyValueCollection : System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + { + System.Collections.Generic.IComparer> Comparer { get; } + int Count { get; } + System.Collections.Generic.KeyValuePair this[int index] { get; } + DynamicData.SortOptimisations Optimisations { get; } + DynamicData.SortReason SortReason { get; } + } + public interface IKeyValue : DynamicData.IKey + { + TObject Value { get; } + } + public interface IKey + { + T Key { get; } + } + public interface IObservableCache : DynamicData.IConnectableCache, System.IDisposable + where TObject : notnull + where TKey : notnull + { + int Count { get; } + System.Collections.Generic.IEnumerable Items { get; } + System.Collections.Generic.IEnumerable> KeyValues { get; } + System.Collections.Generic.IEnumerable Keys { get; } + DynamicData.Kernel.Optional Lookup(TKey key); + } + public interface IObservableList : System.IDisposable + where T : notnull + { + int Count { get; } + System.IObservable CountChanged { get; } + System.Collections.Generic.IEnumerable Items { get; } + System.IObservable> Connect(System.Func? predicate = null); + System.IObservable> Preview(System.Func? predicate = null); + } + public interface IPageChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where T : notnull + { + DynamicData.Operators.IPageResponse Response { get; } + } + public interface IPageRequest + { + int Page { get; } + int Size { get; } + } + public interface IPagedChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, DynamicData.ISortedChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + { + DynamicData.Operators.IPageResponse Response { get; } + } + public interface IQuery + where TObject : notnull + { + int Count { get; } + System.Collections.Generic.IEnumerable Items { get; } + System.Collections.Generic.IEnumerable> KeyValues { get; } + System.Collections.Generic.IEnumerable Keys { get; } + DynamicData.Kernel.Optional Lookup(TKey key); + } + public interface ISortedChangeSetAdaptor + where TObject : notnull + where TKey : notnull + { + void Adapt(DynamicData.ISortedChangeSet change); + } + public interface ISortedChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + { + DynamicData.IKeyValueCollection SortedItems { get; } + } + public interface ISourceCache : DynamicData.IConnectableCache, DynamicData.IObservableCache, System.IDisposable + where TObject : notnull + where TKey : notnull + { + System.Func KeySelector { get; } + void Edit(System.Action> updateAction); + } + public interface ISourceList : DynamicData.IObservableList, System.IDisposable + where T : notnull + { + void Edit(System.Action> updateAction); + } + public interface ISourceUpdater : DynamicData.ICacheUpdater, DynamicData.IQuery + where TObject : notnull + where TKey : notnull + { + void AddOrUpdate(System.Collections.Generic.IEnumerable items); + void AddOrUpdate(TObject item); + void AddOrUpdate(System.Collections.Generic.IEnumerable items, System.Collections.Generic.IEqualityComparer comparer); + void AddOrUpdate(TObject item, System.Collections.Generic.IEqualityComparer comparer); + [System.Obsolete("Use Refresh: Same thing but better semantics")] + void Evaluate(System.Collections.Generic.IEnumerable items); + [System.Obsolete("Use Refresh: Same thing but better semantics")] + void Evaluate(TObject item); + void Load(System.Collections.Generic.IEnumerable items); + void Refresh(System.Collections.Generic.IEnumerable items); + void Refresh(TObject item); + void Remove(System.Collections.Generic.IEnumerable items); + void Remove(TObject item); + } + public interface IVirtualChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where T : notnull + { + DynamicData.IVirtualResponse Response { get; } + } + public interface IVirtualChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, DynamicData.ISortedChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + { + DynamicData.IVirtualResponse Response { get; } + } + public interface IVirtualRequest + { + int Size { get; } + int StartIndex { get; } + } + public interface IVirtualResponse + { + int Size { get; } + int StartIndex { get; } + int TotalSize { get; } + } + public sealed class IndexedItem : System.IEquatable> + { + public IndexedItem(TObject value, TKey key, int index) { } + public int Index { get; } + public TKey Key { get; } + public TObject Value { get; } + public bool Equals(DynamicData.IndexedItem? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + } + [System.Diagnostics.DebuggerDisplay("IntermediateCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Items)")] + public sealed class IntermediateCache : DynamicData.IConnectableCache, DynamicData.IIntermediateCache, DynamicData.IObservableCache, System.IDisposable + where TObject : notnull + where TKey : notnull + { + public IntermediateCache() { } + public IntermediateCache(System.IObservable> source) { } + public int Count { get; } + public System.IObservable CountChanged { get; } + public System.Collections.Generic.IEnumerable Items { get; } + public System.Collections.Generic.IEnumerable> KeyValues { get; } + public System.Collections.Generic.IEnumerable Keys { get; } + public System.IObservable> Connect(System.Func? predicate = null, bool suppressEmptyChangeSets = true) { } + public void Dispose() { } + public void Edit(System.Action> updateAction) { } + public DynamicData.Kernel.Optional Lookup(TKey key) { } + public System.IObservable> Preview(System.Func? predicate = null) { } + public System.IObservable> Watch(TKey key) { } + } + public readonly struct ItemChange : System.IEquatable> + where T : notnull + { + public static readonly DynamicData.ItemChange Empty; + public ItemChange(DynamicData.ListChangeReason reason, T current, int currentIndex) { } + public ItemChange(DynamicData.ListChangeReason reason, T current, DynamicData.Kernel.Optional previous, int currentIndex = -1, int previousIndex = -1) { } + public T Current { get; } + public int CurrentIndex { get; } + public DynamicData.Kernel.Optional Previous { get; } + public int PreviousIndex { get; } + public DynamicData.ListChangeReason Reason { get; } + public bool Equals(DynamicData.ItemChange other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.ItemChange left, DynamicData.ItemChange right) { } + public static bool operator ==(DynamicData.ItemChange left, DynamicData.ItemChange right) { } + } + public enum ListChangeReason + { + Add = 0, + AddRange = 1, + Replace = 2, + Remove = 3, + RemoveRange = 4, + Refresh = 5, + Moved = 6, + Clear = 7, + } + public static class ListEx + { + public static void Add(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable items) { } + public static void AddOrInsertRange(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable items, int index) { } + public static void AddRange(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable items) { } + public static void AddRange(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable items, int index) { } + public static int BinarySearch(this System.Collections.Generic.IList list, TItem value) { } + public static int BinarySearch(this System.Collections.Generic.IList list, TItem value, System.Collections.Generic.IComparer comparer) { } + public static int BinarySearch(this System.Collections.Generic.IList list, TSearch value, System.Func comparer) { } + public static void Clone(this System.Collections.Generic.IList source, DynamicData.IChangeSet changes) + where T : notnull { } + public static void Clone(this System.Collections.Generic.IList source, DynamicData.IChangeSet changes, System.Collections.Generic.IEqualityComparer? equalityComparer) + where T : notnull { } + public static void Clone(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable> changes, System.Collections.Generic.IEqualityComparer? equalityComparer) + where T : notnull { } + public static int IndexOf(this System.Collections.Generic.IEnumerable source, T item) { } + public static int IndexOf(this System.Collections.Generic.IEnumerable source, T item, System.Collections.Generic.IEqualityComparer equalityComparer) { } + public static DynamicData.Kernel.Optional> IndexOfOptional(this System.Collections.Generic.IEnumerable source, T item, System.Collections.Generic.IEqualityComparer? equalityComparer = null) { } + public static void Remove(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable items) { } + public static void RemoveMany(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable itemsToRemove) { } + public static void Replace(this System.Collections.Generic.IList source, T original, T replaceWith) { } + public static void Replace(this System.Collections.Generic.IList source, T original, T replaceWith, System.Collections.Generic.IEqualityComparer comparer) { } + public static void ReplaceOrAdd(this System.Collections.Generic.IList source, T original, T replaceWith) { } + } + public enum ListFilterPolicy + { + ClearAndReplace = 0, + CalculateDiff = 1, + } + [System.Serializable] + public class MissingKeyException : System.Exception + { + public MissingKeyException() { } + public MissingKeyException(string message) { } + public MissingKeyException(string message, System.Exception innerException) { } + } + public class Node : System.IDisposable, System.IEquatable> + where TObject : class + where TKey : notnull + { + public Node(TObject item, TKey key) { } + public Node(TObject item, TKey key, DynamicData.Kernel.Optional> parent) { } + public DynamicData.IObservableCache, TKey> Children { get; } + public int Depth { get; } + public bool IsRoot { get; } + public TObject Item { get; } + public TKey Key { get; } + public DynamicData.Kernel.Optional> Parent { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + public bool Equals(DynamicData.Node? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Node left, DynamicData.Node right) { } + public static bool operator ==(DynamicData.Node? left, DynamicData.Node? right) { } + } + public static class ObservableCacheEx + { + public static System.IObservable> Adapt(this System.IObservable> source, DynamicData.IChangeSetAdaptor adaptor) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Adapt(this System.IObservable> source, DynamicData.ISortedChangeSetAdaptor adaptor) + where TObject : notnull + where TKey : notnull { } + public static void AddOrUpdate(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable items) + where TObject : notnull + where TKey : notnull { } + public static void AddOrUpdate(this DynamicData.ISourceCache source, TObject item) + where TObject : notnull + where TKey : notnull { } + public static void AddOrUpdate(this DynamicData.IIntermediateCache source, TObject item, TKey key) + where TObject : notnull + where TKey : notnull { } + public static void AddOrUpdate(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable items, System.Collections.Generic.IEqualityComparer equalityComparer) + where TObject : notnull + where TKey : notnull { } + public static void AddOrUpdate(this DynamicData.ISourceCache source, TObject item, System.Collections.Generic.IEqualityComparer equalityComparer) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> And(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> And(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> And(this DynamicData.IObservableList>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> And(this System.Collections.Generic.ICollection>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> And(this System.IObservable> source, params System.IObservable>[] others) + where TObject : notnull + where TKey : notnull { } + public static DynamicData.IObservableCache AsObservableCache(this DynamicData.IObservableCache source) + where TObject : notnull + where TKey : notnull { } + public static DynamicData.IObservableCache AsObservableCache(this System.IObservable> source, bool applyLocking = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> AutoRefresh(this System.IObservable> source, System.TimeSpan? changeSetBuffer = default, System.TimeSpan? propertyChangeThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull { } + public static System.IObservable> AutoRefresh(this System.IObservable> source, System.Linq.Expressions.Expression> propertyAccessor, System.TimeSpan? changeSetBuffer = default, System.TimeSpan? propertyChangeThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull { } + public static System.IObservable> AutoRefreshOnObservable(this System.IObservable> source, System.Func> reevaluator, System.TimeSpan? changeSetBuffer = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> AutoRefreshOnObservable(this System.IObservable> source, System.Func> reevaluator, System.TimeSpan? changeSetBuffer = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Batch(this System.IObservable> source, System.TimeSpan timeSpan, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BatchIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BatchIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, bool initialPauseState = false, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BatchIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, System.TimeSpan? timeOut = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BatchIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, bool initialPauseState = false, System.IObservable? timer = null, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BatchIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, bool initialPauseState = false, System.TimeSpan? timeOut = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, DynamicData.Binding.IObservableCollection destination) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, DynamicData.Binding.IObservableCollection destination, DynamicData.Binding.IObservableCollectionAdaptor updater) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, DynamicData.Binding.IObservableCollection destination, int refreshThreshold = 25) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, System.ComponentModel.BindingList bindingList, int resetThreshold = 25) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, DynamicData.Binding.IObservableCollection destination, DynamicData.Binding.ISortedObservableCollectionAdaptor updater) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, System.ComponentModel.BindingList bindingList, int resetThreshold = 25) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, out System.Collections.ObjectModel.ReadOnlyObservableCollection readOnlyObservableCollection, int resetThreshold = 25, bool useReplaceForUpdates = false, DynamicData.Binding.IObservableCollectionAdaptor? adaptor = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, out System.Collections.ObjectModel.ReadOnlyObservableCollection readOnlyObservableCollection, int resetThreshold = 25, bool useReplaceForUpdates = true, DynamicData.Binding.ISortedObservableCollectionAdaptor? adaptor = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BufferInitial(this System.IObservable> source, System.TimeSpan initialBuffer, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Cast(this System.IObservable> source, System.Func converter) + where TSource : notnull + where TKey : notnull + where TDestination : notnull { } + public static System.IObservable> ChangeKey(this System.IObservable> source, System.Func keySelector) + where TObject : notnull + where TSourceKey : notnull + where TDestinationKey : notnull { } + public static System.IObservable> ChangeKey(this System.IObservable> source, System.Func keySelector) + where TObject : notnull + where TSourceKey : notnull + where TDestinationKey : notnull { } + public static void Clear(this DynamicData.Cache.Internal.LockFreeObservableCache source) + where TObject : notnull + where TKey : notnull { } + public static void Clear(this DynamicData.IIntermediateCache source) + where TObject : notnull + where TKey : notnull { } + public static void Clear(this DynamicData.ISourceCache source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Clone(this System.IObservable> source, System.Collections.Generic.ICollection target) + where TObject : notnull + where TKey : notnull { } + [System.Obsolete("This was an experiment that did not work. Use Transform instead")] + public static System.IObservable> Convert(this System.IObservable> source, System.Func conversionFactory) + where TObject : notnull + where TKey : notnull + where TDestination : notnull { } + public static System.IObservable> DeferUntilLoaded(this DynamicData.IObservableCache source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> DeferUntilLoaded(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> DisposeMany(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> DistinctValues(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull + where TValue : notnull { } + public static void EditDiff(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable allItems, System.Collections.Generic.IEqualityComparer equalityComparer) + where TObject : notnull + where TKey : notnull { } + public static void EditDiff(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable allItems, System.Func areItemsEqual) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> EditDiff(this System.IObservable> source, System.Func keySelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> EditDiff(this System.IObservable> source, System.Func keySelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> EnsureUniqueKeys(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + [System.Obsolete("Use Refresh: Same thing but better semantics")] + public static void Evaluate(this DynamicData.ISourceCache source) + where TObject : notnull + where TKey : notnull { } + [System.Obsolete("Use Refresh: Same thing but better semantics")] + public static void Evaluate(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable items) + where TObject : notnull + where TKey : notnull { } + [System.Obsolete("Use Refresh: Same thing but better semantics")] + public static void Evaluate(this DynamicData.ISourceCache source, TObject item) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Except(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Except(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Except(this DynamicData.IObservableList>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Except(this System.Collections.Generic.ICollection>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Except(this System.IObservable> source, params System.IObservable>[] others) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ExpireAfter(this System.IObservable> source, System.Func timeSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable>> ExpireAfter(this DynamicData.ISourceCache source, System.Func timeSelector, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable>> ExpireAfter(this DynamicData.ISourceCache source, System.Func timeSelector, System.TimeSpan? interval = default) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ExpireAfter(this System.IObservable> source, System.Func timeSelector, System.Reactive.Concurrency.IScheduler scheduler) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ExpireAfter(this System.IObservable> source, System.Func timeSelector, System.TimeSpan? pollingInterval) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable>> ExpireAfter(this DynamicData.ISourceCache source, System.Func timeSelector, System.TimeSpan? pollingInterval, System.Reactive.Concurrency.IScheduler? scheduler) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ExpireAfter(this System.IObservable> source, System.Func timeSelector, System.TimeSpan? pollingInterval, System.Reactive.Concurrency.IScheduler scheduler) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Filter(this System.IObservable> source, System.Func filter, bool suppressEmptyChangeSets = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Filter(this System.IObservable> source, System.IObservable> predicateChanged, bool suppressEmptyChangeSets = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Filter(this System.IObservable> source, System.IObservable reapplyFilter, bool suppressEmptyChangeSets = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Filter(this System.IObservable> source, System.IObservable> predicateChanged, System.IObservable reapplyFilter, bool suppressEmptyChangeSets = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> FilterOnObservable(this System.IObservable> source, System.Func> filterFactory, System.TimeSpan? buffer = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> FilterOnObservable(this System.IObservable> source, System.Func> filterFactory, System.TimeSpan? buffer = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + [System.Obsolete("Use AutoRefresh(), followed by Filter() instead")] + public static System.IObservable> FilterOnProperty(this System.IObservable> source, System.Linq.Expressions.Expression> propertySelector, System.Func predicate, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull { } + [System.Obsolete("This can cause unhandled exception issues so do not use")] + public static System.IObservable FinallySafe(this System.IObservable source, System.Action finallyAction) { } + public static System.IObservable> Flatten(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> FlattenBufferResult(this System.IObservable>> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ForEachChange(this System.IObservable> source, System.Action> action) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> FullJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, DynamicData.Kernel.Optional, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> FullJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, DynamicData.Kernel.Optional, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> FullJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, DynamicData.IGrouping, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> FullJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, DynamicData.IGrouping, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> Group(this System.IObservable> source, System.Func groupSelectorKey) + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> Group(this System.IObservable> source, System.Func groupSelector, System.IObservable> resultGroupSource) + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> Group(this System.IObservable> source, System.Func groupSelectorKey, System.IObservable regrouper) + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> GroupOnProperty(this System.IObservable> source, System.Linq.Expressions.Expression> propertySelector, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> GroupOnPropertyWithImmutableState(this System.IObservable> source, System.Linq.Expressions.Expression> propertySelector, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> GroupWithImmutableState(this System.IObservable> source, System.Func groupSelectorKey, System.IObservable? regrouper = null) + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> IgnoreSameReferenceUpdate(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> IgnoreUpdateWhen(this System.IObservable> source, System.Func ignoreFunction) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> IncludeUpdateWhen(this System.IObservable> source, System.Func includeFunction) + where TObject : notnull + where TKey : notnull { } + [return: System.Runtime.CompilerServices.TupleElementNames(new string[] { + "leftKey", + "rightKey"})] + public static System.IObservable>> InnerJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + [return: System.Runtime.CompilerServices.TupleElementNames(new string[] { + "leftKey", + "rightKey"})] + public static System.IObservable>> InnerJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, [System.Runtime.CompilerServices.TupleElementNames(new string[] { + "leftKey", + "rightKey"})] System.Func, TLeft, TRight, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> InnerJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> InnerJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> InvokeEvaluate(this System.IObservable> source) + where TObject : DynamicData.Binding.IEvaluateAware + where TKey : notnull { } + public static System.IObservable> LeftJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> LeftJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> LeftJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> LeftJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> LimitSizeTo(this System.IObservable> source, int size) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable>> LimitSizeTo(this DynamicData.ISourceCache source, int sizeLimit, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable>> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable>> source, System.Collections.Generic.IComparer comparer) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable>> source, System.Collections.Generic.IEqualityComparer equalityComparer) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.Collections.Generic.IEnumerable>> source, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable>> source, System.Collections.Generic.IEqualityComparer equalityComparer, System.Collections.Generic.IComparer comparer) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.Collections.Generic.IEnumerable>> source, System.Collections.Generic.IComparer comparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.Collections.Generic.IEnumerable>> source, System.Collections.Generic.IEqualityComparer equalityComparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.Collections.Generic.IEnumerable>> others, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.IObservable> other, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.Collections.Generic.IEnumerable>> source, System.Collections.Generic.IEqualityComparer equalityComparer, System.Collections.Generic.IComparer comparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.Collections.Generic.IEnumerable>> others, System.Collections.Generic.IComparer comparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.Collections.Generic.IEnumerable>> others, System.Collections.Generic.IEqualityComparer equalityComparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.IObservable> other, System.Collections.Generic.IComparer comparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.IObservable> other, System.Collections.Generic.IEqualityComparer equalityComparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.Collections.Generic.IEnumerable>> others, System.Collections.Generic.IEqualityComparer equalityComparer, System.Collections.Generic.IComparer comparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.IObservable> other, System.Collections.Generic.IEqualityComparer equalityComparer, System.Collections.Generic.IComparer comparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable MergeMany(this System.IObservable> source, System.Func> observableSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable MergeMany(this System.IObservable> source, System.Func> observableSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer comparer) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer comparer) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, System.Collections.Generic.IComparer childComparer) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null, System.Collections.Generic.IComparer? comparer = null) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, System.Collections.Generic.IComparer childComparer) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null, System.Collections.Generic.IComparer? comparer = null) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, bool resortOnSourceRefresh, System.Collections.Generic.IComparer childComparer) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, System.Collections.Generic.IEqualityComparer? equalityComparer = null, System.Collections.Generic.IComparer? childComparer = null) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, bool resortOnSourceRefresh, System.Collections.Generic.IComparer childComparer) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, System.Collections.Generic.IEqualityComparer? equalityComparer = null, System.Collections.Generic.IComparer? childComparer = null) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, bool resortOnSourceRefresh, System.Collections.Generic.IEqualityComparer? equalityComparer = null, System.Collections.Generic.IComparer? childComparer = null) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, bool resortOnSourceRefresh, System.Collections.Generic.IEqualityComparer? equalityComparer = null, System.Collections.Generic.IComparer? childComparer = null) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyItems(this System.IObservable> source, System.Func> observableSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeManyItems(this System.IObservable> source, System.Func> observableSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable MonitorStatus(this System.IObservable source) { } + public static System.IObservable> NotEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> OnItemAdded(this System.IObservable> source, System.Action addAction) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> OnItemRefreshed(this System.IObservable> source, System.Action refreshAction) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> OnItemRemoved(this System.IObservable> source, System.Action removeAction, bool invokeOnUnsubscribe = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> OnItemUpdated(this System.IObservable> source, System.Action updateAction) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Or(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Or(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Or(this DynamicData.IObservableList>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Or(this System.Collections.Generic.ICollection>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Or(this System.IObservable> source, params System.IObservable>[] others) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Page(this System.IObservable> source, System.IObservable pageRequests) + where TObject : notnull + where TKey : notnull { } + public static System.IDisposable PopulateFrom(this DynamicData.ISourceCache source, System.IObservable> observable) + where TObject : notnull + where TKey : notnull { } + public static System.IDisposable PopulateFrom(this DynamicData.ISourceCache source, System.IObservable observable) + where TObject : notnull + where TKey : notnull { } + public static System.IDisposable PopulateInto(this System.IObservable> source, DynamicData.Cache.Internal.LockFreeObservableCache destination) + where TObject : notnull + where TKey : notnull { } + public static System.IDisposable PopulateInto(this System.IObservable> source, DynamicData.IIntermediateCache destination) + where TObject : notnull + where TKey : notnull { } + public static System.IDisposable PopulateInto(this System.IObservable> source, DynamicData.ISourceCache destination) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> QueryWhenChanged(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable QueryWhenChanged(this System.IObservable> source, System.Func, TDestination> resultSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> QueryWhenChanged(this System.IObservable> source, System.Func> itemChangedTrigger) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> RefCount(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static void Refresh(this DynamicData.ISourceCache source) + where TObject : notnull + where TKey : notnull { } + public static void Refresh(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable items) + where TObject : notnull + where TKey : notnull { } + public static void Refresh(this DynamicData.ISourceCache source, TObject item) + where TObject : notnull + where TKey : notnull { } + public static void Remove(this DynamicData.IIntermediateCache source, System.Collections.Generic.IEnumerable keys) + where TObject : notnull + where TKey : notnull { } + public static void Remove(this DynamicData.IIntermediateCache source, TKey key) + where TObject : notnull + where TKey : notnull { } + public static void Remove(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable keys) + where TObject : notnull + where TKey : notnull { } + public static void Remove(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable items) + where TObject : notnull + where TKey : notnull { } + public static void Remove(this DynamicData.ISourceCache source, TKey key) + where TObject : notnull + where TKey : notnull { } + public static void Remove(this DynamicData.ISourceCache source, TObject item) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> RemoveKey(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static void RemoveKey(this DynamicData.ISourceCache source, TKey key) + where TObject : notnull + where TKey : notnull { } + public static void RemoveKeys(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable keys) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> RightJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TRight, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> RightJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TRight, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> RightJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, DynamicData.IGrouping, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> RightJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, DynamicData.IGrouping, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> SkipInitial(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Sort(this System.IObservable> source, System.Collections.Generic.IComparer comparer, DynamicData.SortOptimisations sortOptimisations = 0, int resetThreshold = 100) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Sort(this System.IObservable> source, System.IObservable> comparerObservable, DynamicData.SortOptimisations sortOptimisations = 0, int resetThreshold = 100) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Sort(this System.IObservable> source, System.Collections.Generic.IComparer comparer, System.IObservable resorter, DynamicData.SortOptimisations sortOptimisations = 0, int resetThreshold = 100) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Sort(this System.IObservable> source, System.IObservable> comparerObservable, System.IObservable resorter, DynamicData.SortOptimisations sortOptimisations = 0, int resetThreshold = 100) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> SortBy(this System.IObservable> source, System.Func expression, DynamicData.Binding.SortDirection sortOrder = 0, DynamicData.SortOptimisations sortOptimisations = 0, int resetThreshold = 100) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> StartWithItem(this System.IObservable> source, TObject item) + where TObject : DynamicData.IKey + where TKey : notnull { } + public static System.IObservable> StartWithItem(this System.IObservable> source, TObject item, TKey key) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> SubscribeMany(this System.IObservable> source, System.Func subscriptionFactory) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> SubscribeMany(this System.IObservable> source, System.Func subscriptionFactory) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> SuppressRefresh(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Switch(this System.IObservable> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Switch(this System.IObservable>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToCollection(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable> source, System.Func keySelector, System.Func? expireAfter = null, int limitSizeTo = -1, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable source, System.Func keySelector, System.Func? expireAfter = null, int limitSizeTo = -1, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToObservableOptional(this System.IObservable> source, TKey key, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToObservableOptional(this System.IObservable> source, TKey key, bool initialOptionalWhenMissing, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToSortedCollection(this System.IObservable> source, System.Collections.Generic.IComparer comparer) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToSortedCollection(this System.IObservable> source, System.Func sort, DynamicData.Binding.SortDirection sortOrder = 0) + where TObject : notnull + where TKey : notnull + where TSortKey : notnull { } + public static System.IObservable> Top(this System.IObservable> source, int size) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Top(this System.IObservable> source, System.Collections.Generic.IComparer comparer, int size) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, bool transformOnRefresh) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, bool transformOnRefresh) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func, TKey, TDestination> transformFactory, bool transformOnRefresh) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func, TKey, TDestination> transformFactory, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func, TKey, TDestination> transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func> transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func> transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func, TKey, System.Threading.Tasks.Task> transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Func keySelector) + where TDestination : notnull + where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Func keySelector) + where TDestination : notnull + where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Func keySelector) + where TDestination : notnull + where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Func keySelector) + where TDestination : notnull + where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func, TKey, TDestination> transformFactory, System.Action> errorHandler, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func, TKey, TDestination> transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafeAsync(this System.IObservable> source, System.Func> transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafeAsync(this System.IObservable> source, System.Func> transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafeAsync(this System.IObservable> source, System.Func, TKey, System.Threading.Tasks.Task> transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable, TKey>> TransformToTree(this System.IObservable> source, System.Func pivotOn, System.IObservable, bool>>? predicateChanged = null) + where TObject : class + where TKey : notnull { } + public static System.IObservable> TransformWithInlineUpdate(this System.IObservable> source, System.Func transformFactory, System.Action updateAction) + where TDestination : class + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformWithInlineUpdate(this System.IObservable> source, System.Func transformFactory, System.Action updateAction, System.Action> errorHandler) + where TDestination : class + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TreatMovesAsRemoveAdd(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable TrueForAll(this System.IObservable> source, System.Func> observableSelector, System.Func equalityCondition) + where TObject : notnull + where TKey : notnull + where TValue : notnull { } + public static System.IObservable TrueForAll(this System.IObservable> source, System.Func> observableSelector, System.Func equalityCondition) + where TObject : notnull + where TKey : notnull + where TValue : notnull { } + public static System.IObservable TrueForAny(this System.IObservable> source, System.Func> observableSelector, System.Func equalityCondition) + where TObject : notnull + where TKey : notnull + where TValue : notnull { } + public static System.IObservable TrueForAny(this System.IObservable> source, System.Func> observableSelector, System.Func equalityCondition) + where TObject : notnull + where TKey : notnull + where TValue : notnull { } + public static System.IObservable> UpdateIndex(this System.IObservable> source) + where TObject : DynamicData.Binding.IIndexAware + where TKey : notnull { } + public static System.IObservable> Virtualise(this System.IObservable> source, System.IObservable virtualRequests) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Watch(this System.IObservable> source, TKey key) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable WatchValue(this DynamicData.IObservableCache source, TKey key) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable WatchValue(this System.IObservable> source, TKey key) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable WhenAnyPropertyChanged(this System.IObservable> source, params string[] propertiesToMonitor) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull { } + public static System.IObservable> WhenPropertyChanged(this System.IObservable> source, System.Linq.Expressions.Expression> propertyAccessor, bool notifyOnInitialValue = true) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull { } + public static System.IObservable WhenValueChanged(this System.IObservable> source, System.Linq.Expressions.Expression> propertyAccessor, bool notifyOnInitialValue = true) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull { } + public static System.IObservable> WhereReasonsAre(this System.IObservable> source, params DynamicData.ChangeReason[] reasons) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> WhereReasonsAreNot(this System.IObservable> source, params DynamicData.ChangeReason[] reasons) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Xor(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Xor(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Xor(this DynamicData.IObservableList>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Xor(this System.Collections.Generic.ICollection>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Xor(this System.IObservable> source, params System.IObservable>[] others) + where TObject : notnull + where TKey : notnull { } + } + public static class ObservableChangeSet + { + public static System.IObservable> Create(System.Func, System.Action> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.IDisposable> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.Tasks.Task> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.Tasks.Task> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.Tasks.Task> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Action> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.IDisposable> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.Tasks.Task> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.Tasks.Task> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.Tasks.Task> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + } + public static class ObservableListEx + { + public static System.IObservable> Adapt(this System.IObservable> source, DynamicData.IChangeSetAdaptor adaptor) + where T : notnull { } + public static System.IObservable> AddKey(this System.IObservable> source, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> And(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> And(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> And(this DynamicData.IObservableList>> sources) + where T : notnull { } + public static System.IObservable> And(this System.Collections.Generic.ICollection>> sources) + where T : notnull { } + public static System.IObservable> And(this System.IObservable> source, params System.IObservable>[] others) + where T : notnull { } + public static DynamicData.IObservableList AsObservableList(this DynamicData.ISourceList source) + where T : notnull { } + public static DynamicData.IObservableList AsObservableList(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> AutoRefresh(this System.IObservable> source, System.TimeSpan? changeSetBuffer = default, System.TimeSpan? propertyChangeThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable> AutoRefresh(this System.IObservable> source, System.Linq.Expressions.Expression> propertyAccessor, System.TimeSpan? changeSetBuffer = default, System.TimeSpan? propertyChangeThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable> AutoRefreshOnObservable(this System.IObservable> source, System.Func> reevaluator, System.TimeSpan? changeSetBuffer = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, DynamicData.Binding.IObservableCollection targetCollection, int resetThreshold = 25) + where T : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, out System.Collections.ObjectModel.ReadOnlyObservableCollection readOnlyObservableCollection, int resetThreshold = 25) + where T : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, System.ComponentModel.BindingList bindingList, int resetThreshold = 25) + where T : notnull { } + public static System.IObservable> BufferIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> BufferIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, bool initialPauseState, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> BufferIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, System.TimeSpan? timeOut, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> BufferIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, bool initialPauseState, System.TimeSpan? timeOut, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> BufferInitial(this System.IObservable> source, System.TimeSpan initialBuffer, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull { } + public static System.IObservable> Cast(this System.IObservable> source) + where TDestination : notnull { } + public static System.IObservable> Cast(this System.IObservable> source, System.Func conversionFactory) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> CastToObject(this System.IObservable> source) + where T : class { } + public static System.IObservable> Clone(this System.IObservable> source, System.Collections.Generic.IList target) + where T : notnull { } + [System.Obsolete("Prefer Cast as it is does the same thing but is semantically correct")] + public static System.IObservable> Convert(this System.IObservable> source, System.Func conversionFactory) + where TObject : notnull + where TDestination : notnull { } + public static System.IObservable> DeferUntilLoaded(this DynamicData.IObservableList source) + where T : notnull { } + public static System.IObservable> DeferUntilLoaded(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> DisposeMany(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> DistinctValues(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TValue : notnull { } + public static System.IObservable> Except(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> Except(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> Except(this DynamicData.IObservableList>> sources) + where T : notnull { } + public static System.IObservable> Except(this System.Collections.Generic.ICollection>> sources) + where T : notnull { } + public static System.IObservable> Except(this System.IObservable> source, params System.IObservable>[] others) + where T : notnull { } + public static System.IObservable> ExpireAfter(this DynamicData.ISourceList source, System.Func timeSelector, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ExpireAfter(this DynamicData.ISourceList source, System.Func timeSelector, System.TimeSpan? pollingInterval = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> Filter(this System.IObservable> source, System.Func predicate) + where T : notnull { } + public static System.IObservable> Filter(this System.IObservable> source, System.IObservable> predicate, DynamicData.ListFilterPolicy filterPolicy = 1) + where T : notnull { } + public static System.IObservable> FilterOnObservable(this System.IObservable> source, System.Func> objectFilterObservable, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull { } + [System.Obsolete("Use AutoRefresh(), followed by Filter() instead")] + public static System.IObservable> FilterOnProperty(this System.IObservable> source, System.Linq.Expressions.Expression> propertySelector, System.Func predicate, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable> FlattenBufferResult(this System.IObservable>> source) + where T : notnull { } + public static System.IObservable> ForEachChange(this System.IObservable> source, System.Action> action) + where TObject : notnull { } + public static System.IObservable> ForEachItemChange(this System.IObservable> source, System.Action> action) + where TObject : notnull { } + public static System.IObservable>> GroupOn(this System.IObservable> source, System.Func groupSelector, System.IObservable? regrouper = null) + where TObject : notnull + where TGroup : notnull { } + public static System.IObservable>> GroupOnProperty(this System.IObservable> source, System.Linq.Expressions.Expression> propertySelector, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TGroup : notnull { } + public static System.IObservable>> GroupOnPropertyWithImmutableState(this System.IObservable> source, System.Linq.Expressions.Expression> propertySelector, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TGroup : notnull { } + public static System.IObservable>> GroupWithImmutableState(this System.IObservable> source, System.Func groupSelectorKey, System.IObservable? regrouper = null) + where TObject : notnull + where TGroupKey : notnull { } + public static System.IObservable> LimitSizeTo(this DynamicData.ISourceList source, int sizeLimit, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable MergeMany(this System.IObservable> source, System.Func> observableSelector) + where T : notnull { } + public static System.IObservable> NotEmpty(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> OnItemAdded(this System.IObservable> source, System.Action addAction) + where T : notnull { } + public static System.IObservable> OnItemRefreshed(this System.IObservable> source, System.Action refreshAction) + where TObject : notnull { } + public static System.IObservable> OnItemRemoved(this System.IObservable> source, System.Action removeAction, bool invokeOnUnsubscribe = true) + where T : notnull { } + public static System.IObservable> Or(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> Or(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> Or(this DynamicData.IObservableList>> sources) + where T : notnull { } + public static System.IObservable> Or(this System.Collections.Generic.ICollection>> sources) + where T : notnull { } + public static System.IObservable> Or(this System.IObservable> source, params System.IObservable>[] others) + where T : notnull { } + public static System.IObservable> Page(this System.IObservable> source, System.IObservable requests) + where T : notnull { } + public static System.IDisposable PopulateInto(this System.IObservable> source, DynamicData.ISourceList destination) + where T : notnull { } + public static System.IObservable> QueryWhenChanged(this System.IObservable> source) + where T : notnull { } + public static System.IObservable QueryWhenChanged(this System.IObservable> source, System.Func, TDestination> resultSelector) + where TObject : notnull { } + public static System.IObservable> RefCount(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> RemoveIndex(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> Reverse(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> SkipInitial(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> Sort(this System.IObservable> source, System.IObservable> comparerChanged, DynamicData.SortOptions options = 0, System.IObservable? resort = null, int resetThreshold = 50) + where T : notnull { } + public static System.IObservable> Sort(this System.IObservable> source, System.Collections.Generic.IComparer comparer, DynamicData.SortOptions options = 0, System.IObservable? resort = null, System.IObservable>? comparerChanged = null, int resetThreshold = 50) + where T : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> SubscribeMany(this System.IObservable> source, System.Func subscriptionFactory) + where T : notnull { } + public static System.IObservable> SuppressRefresh(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> Switch(this System.IObservable> sources) + where T : notnull { } + public static System.IObservable> Switch(this System.IObservable>> sources) + where T : notnull { } + public static System.IObservable> ToCollection(this System.IObservable> source) + where TObject : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable> source, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable source, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable> source, System.Func expireAfter, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable> source, int limitSizeTo, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable source, System.Func expireAfter, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable source, int limitSizeTo, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable> source, System.Func? expireAfter, int limitSizeTo, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable source, System.Func? expireAfter, int limitSizeTo, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToSortedCollection(this System.IObservable> source, System.Collections.Generic.IComparer comparer) + where TObject : notnull { } + public static System.IObservable> ToSortedCollection(this System.IObservable> source, System.Func sort, DynamicData.Binding.SortDirection sortOrder = 0) + where TObject : notnull { } + public static System.IObservable> Top(this System.IObservable> source, int numberOfItems) + where T : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func, TDestination> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func, int, TDestination> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func, System.Threading.Tasks.Task> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func, int, System.Threading.Tasks.Task> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TDestination : notnull + where TSource : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TDestination : notnull + where TSource : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TDestination : notnull + where TSource : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TDestination : notnull + where TSource : notnull { } + public static System.IObservable> Virtualise(this System.IObservable> source, System.IObservable requests) + where T : notnull { } + public static System.IObservable WhenAnyPropertyChanged(this System.IObservable> source, params string[] propertiesToMonitor) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable> WhenPropertyChanged(this System.IObservable> source, System.Linq.Expressions.Expression> propertyAccessor, bool notifyOnInitialValue = true) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenValueChanged(this System.IObservable> source, System.Linq.Expressions.Expression> propertyAccessor, bool notifyOnInitialValue = true) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable> WhereReasonsAre(this System.IObservable> source, params DynamicData.ListChangeReason[] reasons) + where T : notnull { } + public static System.IObservable> WhereReasonsAreNot(this System.IObservable> source, params DynamicData.ListChangeReason[] reasons) + where T : notnull { } + public static System.IObservable> Xor(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> Xor(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> Xor(this DynamicData.IObservableList>> sources) + where T : notnull { } + public static System.IObservable> Xor(this System.Collections.Generic.ICollection>> sources) + where T : notnull { } + public static System.IObservable> Xor(this System.IObservable> source, params System.IObservable>[] others) + where T : notnull { } + } + public static class ObsoleteEx { } + public sealed class PageRequest : DynamicData.IPageRequest, System.IEquatable + { + public static readonly DynamicData.IPageRequest Default; + public static readonly DynamicData.IPageRequest Empty; + public PageRequest() { } + public PageRequest(int page, int size) { } + public System.Collections.Generic.IEqualityComparer DefaultComparer { get; } + public int Page { get; } + public int Size { get; } + public bool Equals(DynamicData.IPageRequest? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + } + public sealed class RangeChange : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + public RangeChange(System.Collections.Generic.IEnumerable items, int index = -1) { } + public int Count { get; } + public int Index { get; } + public static DynamicData.RangeChange Empty { get; } + public void Add(T item) { } + public System.Collections.Generic.IEnumerator GetEnumerator() { } + public void Insert(int index, T item) { } + public void SetStartingIndex(int index) { } + public override string ToString() { } + } + [System.Serializable] + public class SortException : System.Exception + { + public SortException() { } + public SortException(string message) { } + public SortException(string message, System.Exception innerException) { } + } + [System.Flags] + public enum SortOptimisations + { + None = 0, + ComparesImmutableValuesOnly = 1, + IgnoreEvaluates = 2, + [System.Obsolete("This is no longer being used. Use one of the other options instead.")] + InsertAtEndThenSort = 3, + } + public enum SortOptions + { + None = 0, + UseBinarySearch = 1, + } + public enum SortReason + { + InitialLoad = 0, + ComparerChanged = 1, + DataChanged = 2, + Reorder = 3, + Reset = 4, + } + public static class SourceCacheEx + { + public static System.IObservable> Cast(this DynamicData.IObservableCache source, System.Func converter) + where TSource : notnull + where TKey : notnull + where TDestination : notnull { } + } + [System.Diagnostics.DebuggerDisplay("SourceCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Items)")] + public sealed class SourceCache : DynamicData.IConnectableCache, DynamicData.IObservableCache, DynamicData.ISourceCache, System.IDisposable + where TObject : notnull + where TKey : notnull + { + public SourceCache(System.Func keySelector) { } + public int Count { get; } + public System.IObservable CountChanged { get; } + public System.Collections.Generic.IEnumerable Items { get; } + public System.Func KeySelector { get; } + public System.Collections.Generic.IEnumerable> KeyValues { get; } + public System.Collections.Generic.IEnumerable Keys { get; } + public System.IObservable> Connect(System.Func? predicate = null, bool suppressEmptyChangeSets = true) { } + public void Dispose() { } + public void Edit(System.Action> updateAction) { } + public DynamicData.Kernel.Optional Lookup(TKey key) { } + public System.IObservable> Preview(System.Func? predicate = null) { } + public System.IObservable> Watch(TKey key) { } + } + public static class SourceListEditConvenienceEx + { + public static void Add(this DynamicData.ISourceList source, T item) + where T : notnull { } + public static void AddRange(this DynamicData.ISourceList source, System.Collections.Generic.IEnumerable items) + where T : notnull { } + public static void Clear(this DynamicData.ISourceList source) + where T : notnull { } + public static void EditDiff(this DynamicData.ISourceList source, System.Collections.Generic.IEnumerable allItems, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where T : notnull { } + public static void Insert(this DynamicData.ISourceList source, int index, T item) + where T : notnull { } + public static void InsertRange(this DynamicData.ISourceList source, System.Collections.Generic.IEnumerable items, int index) + where T : notnull { } + public static void Move(this DynamicData.ISourceList source, int original, int destination) + where T : notnull { } + public static bool Remove(this DynamicData.ISourceList source, T item) + where T : notnull { } + public static void RemoveAt(this DynamicData.ISourceList source, int index) + where T : notnull { } + public static void RemoveMany(this DynamicData.ISourceList source, System.Collections.Generic.IEnumerable itemsToRemove) + where T : notnull { } + public static void RemoveRange(this DynamicData.ISourceList source, int index, int count) + where T : notnull { } + public static void Replace(this DynamicData.ISourceList source, T original, T destination) + where T : notnull { } + public static void ReplaceAt(this DynamicData.ISourceList source, int index, T item) + where T : notnull { } + } + public static class SourceListEx + { + public static System.IObservable> Cast(this DynamicData.ISourceList source, System.Func conversionFactory) + where TSource : notnull + where TDestination : notnull { } + } + [System.Diagnostics.DebuggerDisplay("SourceList<{typeof(T).Name}> ({Count} Items)")] + public sealed class SourceList : DynamicData.IObservableList, DynamicData.ISourceList, System.IDisposable + where T : notnull + { + public SourceList(System.IObservable>? source = null) { } + public int Count { get; } + public System.IObservable CountChanged { get; } + public System.Collections.Generic.IEnumerable Items { get; } + public System.IObservable> Connect(System.Func? predicate = null) { } + public void Dispose() { } + public void Edit(System.Action> updateAction) { } + public System.IObservable> Preview(System.Func? predicate = null) { } + } + [System.Serializable] + public class UnspecifiedIndexException : System.Exception + { + public UnspecifiedIndexException() { } + public UnspecifiedIndexException(string message) { } + public UnspecifiedIndexException(string message, System.Exception innerException) { } + } + public class VirtualRequest : DynamicData.IVirtualRequest, System.IEquatable + { + public static readonly DynamicData.VirtualRequest Default; + public VirtualRequest() { } + public VirtualRequest(int startIndex, int size) { } + public int Size { get; } + public int StartIndex { get; } + public static System.Collections.Generic.IEqualityComparer StartIndexSizeComparer { get; } + public bool Equals(DynamicData.IVirtualRequest? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + } +} +namespace DynamicData.Diagnostics +{ + public class ChangeStatistics : System.IEquatable + { + public ChangeStatistics() { } + public ChangeStatistics(int index, int adds, int updates, int removes, int refreshes, int moves, int count) { } + public int Adds { get; } + public int Count { get; } + public int Index { get; } + public System.DateTime LastUpdated { get; } + public int Moves { get; } + public int Refreshes { get; } + public int Removes { get; } + public int Updates { get; } + public bool Equals(DynamicData.Diagnostics.ChangeStatistics? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Diagnostics.ChangeStatistics left, DynamicData.Diagnostics.ChangeStatistics right) { } + public static bool operator ==(DynamicData.Diagnostics.ChangeStatistics left, DynamicData.Diagnostics.ChangeStatistics right) { } + } + public class ChangeSummary + { + public static readonly DynamicData.Diagnostics.ChangeSummary Empty; + public ChangeSummary(int index, DynamicData.Diagnostics.ChangeStatistics latest, DynamicData.Diagnostics.ChangeStatistics overall) { } + public DynamicData.Diagnostics.ChangeStatistics Latest { get; } + public DynamicData.Diagnostics.ChangeStatistics Overall { get; } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + } + public static class DiagnosticOperators + { + public static System.IObservable CollectUpdateStats(this System.IObservable> source) + where TSource : notnull { } + public static System.IObservable CollectUpdateStats(this System.IObservable> source) + where TSource : notnull + where TKey : notnull { } + } +} +namespace DynamicData.Experimental +{ + public static class ExperimentalEx + { + public static DynamicData.Experimental.IWatcher AsWatcher(this System.IObservable> source, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + } + public interface IWatcher : System.IDisposable + where TObject : notnull + where TKey : notnull + { + System.IObservable> Watch(TKey key); + } +} +namespace DynamicData.Kernel +{ + public enum ConnectionStatus + { + Pending = 0, + Loaded = 1, + Errored = 2, + Completed = 3, + } + public static class EnumerableEx + { + public static T[] AsArray(this System.Collections.Generic.IEnumerable source) { } + public static System.Collections.Generic.List AsList(this System.Collections.Generic.IEnumerable source) { } + public static System.Collections.Generic.IEnumerable Duplicates(this System.Collections.Generic.IEnumerable source, System.Func valueSelector) { } + public static System.Collections.Generic.IEnumerable> IndexOfMany(this System.Collections.Generic.IEnumerable source, System.Collections.Generic.IEnumerable itemsToFind) { } + public static System.Collections.Generic.IEnumerable IndexOfMany(this System.Collections.Generic.IEnumerable source, System.Collections.Generic.IEnumerable itemsToFind, System.Func resultSelector) { } + } + public sealed class Error : DynamicData.IKeyValue, DynamicData.IKey, System.IEquatable> + where TKey : notnull + { + public Error(System.Exception? exception, TObject value, TKey key) { } + public System.Exception? Exception { get; } + public TKey Key { get; } + public TObject Value { get; } + public bool Equals(DynamicData.Kernel.Error? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Kernel.Error left, DynamicData.Kernel.Error right) { } + public static bool operator ==(DynamicData.Kernel.Error left, DynamicData.Kernel.Error right) { } + } + public static class InternalEx + { + public static System.IObservable RetryWithBackOff(this System.IObservable source, System.Func backOffStrategy) + where TException : System.Exception { } + public static System.IDisposable ScheduleRecurringAction(this System.Reactive.Concurrency.IScheduler scheduler, System.Func interval, System.Action action) { } + public static System.IDisposable ScheduleRecurringAction(this System.Reactive.Concurrency.IScheduler scheduler, System.TimeSpan interval, System.Action action) { } + } + public readonly struct ItemWithIndex : System.IEquatable> + { + public ItemWithIndex(T item, int index) { } + public int Index { get; } + public T Item { get; } + public bool Equals(DynamicData.Kernel.ItemWithIndex other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Kernel.ItemWithIndex left, DynamicData.Kernel.ItemWithIndex right) { } + public static bool operator ==(DynamicData.Kernel.ItemWithIndex left, DynamicData.Kernel.ItemWithIndex right) { } + } + public readonly struct ItemWithValue : System.IEquatable> + { + public ItemWithValue(TObject item, TValue value) { } + public TObject Item { get; } + public TValue Value { get; } + public bool Equals(DynamicData.Kernel.ItemWithValue other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Kernel.ItemWithValue left, DynamicData.Kernel.ItemWithValue right) { } + public static bool operator ==(DynamicData.Kernel.ItemWithValue left, DynamicData.Kernel.ItemWithValue right) { } + } + public sealed class OptionElse + { + public void Else(System.Action action) { } + } + public static class OptionExtensions + { + public static DynamicData.Kernel.Optional Convert(this DynamicData.Kernel.Optional source, System.Func> converter) + where TSource : notnull + where TDestination : notnull { } + public static DynamicData.Kernel.Optional Convert(this DynamicData.Kernel.Optional source, System.Func converter) + where TSource : notnull + where TDestination : notnull { } + public static TDestination? ConvertOr(this DynamicData.Kernel.Optional source, System.Func converter, System.Func fallbackConverter) + where TSource : notnull { } + public static DynamicData.Kernel.Optional FirstOrOptional(this System.Collections.Generic.IEnumerable source, System.Func selector) + where T : notnull { } + public static DynamicData.Kernel.OptionElse IfHasValue(this DynamicData.Kernel.Optional source, System.Action action) + where T : notnull { } + public static DynamicData.Kernel.OptionElse IfHasValue(this DynamicData.Kernel.Optional? source, System.Action action) + where T : notnull { } + public static DynamicData.Kernel.Optional Lookup(this System.Collections.Generic.IDictionary source, TKey key) + where TValue : notnull { } + public static DynamicData.Kernel.Optional OrElse(this DynamicData.Kernel.Optional source, System.Func> fallbackOperation) + where T : notnull { } + public static bool RemoveIfContained(this System.Collections.Generic.IDictionary source, TKey key) { } + public static System.Collections.Generic.IEnumerable SelectValues(this System.Collections.Generic.IEnumerable> source) + where T : notnull { } + public static T ValueOr(this DynamicData.Kernel.Optional source, System.Func valueSelector) + where T : notnull { } + public static T ValueOr(this T? source, T defaultValue) + where T : struct { } + public static T? ValueOrDefault(this DynamicData.Kernel.Optional source) + where T : notnull { } + public static T ValueOrThrow(this DynamicData.Kernel.Optional source, System.Func exceptionGenerator) + where T : notnull { } + } + public static class OptionObservableExtensions + { + public static System.IObservable> Convert(this System.IObservable> source, System.Func> converter) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> Convert(this System.IObservable> source, System.Func converter) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable ConvertOr(this System.IObservable> source, System.Func converter, System.Func fallbackConverter) + where TSource : notnull { } + public static System.IObservable> OnHasNoValue(this System.IObservable> source, System.Action action, System.Action? elseAction = null) + where T : notnull { } + public static System.IObservable> OnHasValue(this System.IObservable> source, System.Action action, System.Action? elseAction = null) + where T : notnull { } + public static System.IObservable> OrElse(this System.IObservable> source, System.Func> fallbackOperation) + where T : notnull { } + public static System.IObservable SelectValues(this System.IObservable> source) + where T : notnull { } + public static System.IObservable ValueOr(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable ValueOrDefault(this System.IObservable> source) + where T : notnull { } + public static System.IObservable ValueOrThrow(this System.IObservable> source, System.Func exceptionGenerator) + where T : notnull { } + } + public static class Optional + { + public static DynamicData.Kernel.Optional None() + where T : notnull { } + public static DynamicData.Kernel.Optional Some(T? value) + where T : notnull { } + } + public readonly struct Optional : System.IEquatable> + where T : notnull + { + public bool HasValue { get; } + public T Value { get; } + public static DynamicData.Kernel.Optional None { get; } + public bool Equals(DynamicData.Kernel.Optional other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string? ToString() { } + public static DynamicData.Kernel.Optional Create(T? value) { } + public static T? FromOptional(DynamicData.Kernel.Optional value) { } + public static DynamicData.Kernel.Optional ToOptional(T? value) { } + public static T? op_Explicit(DynamicData.Kernel.Optional value) { } + public static DynamicData.Kernel.Optional op_Implicit(T? value) { } + public static bool operator !=(DynamicData.Kernel.Optional left, DynamicData.Kernel.Optional right) { } + public static bool operator ==(DynamicData.Kernel.Optional left, DynamicData.Kernel.Optional right) { } + } +} +namespace DynamicData.List +{ + public interface IGrouping + { + int Count { get; } + System.Collections.Generic.IEnumerable Items { get; } + TGroupKey Key { get; } + } +} +namespace DynamicData.Operators +{ + public interface IPageResponse + { + int Page { get; } + int PageSize { get; } + int Pages { get; } + int TotalSize { get; } + } +} +namespace DynamicData.PLinq +{ + public static class ParallelOperators + { + public static System.IObservable> Filter(this System.IObservable> source, System.Func filter, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> SubscribeMany(this System.IObservable> source, System.Func subscriptionFactory, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> SubscribeMany(this System.IObservable> source, System.Func subscriptionFactory, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + } + public enum ParallelType + { + None = 0, + Parallelise = 1, + Ordered = 2, + } + public class ParallelisationOptions + { + public static readonly DynamicData.PLinq.ParallelisationOptions Default; + public static readonly DynamicData.PLinq.ParallelisationOptions None; + public ParallelisationOptions(DynamicData.PLinq.ParallelType type = 0, int threshold = 0, int maxDegreeOfParallelisation = 0) { } + public int MaxDegreeOfParallelisation { get; } + public int Threshold { get; } + public DynamicData.PLinq.ParallelType Type { get; } + } +} +namespace DynamicData.Tests +{ + public class ChangeSetAggregator : System.IDisposable + where TObject : notnull + { + public ChangeSetAggregator(System.IObservable> source) { } + public DynamicData.IObservableList Data { get; } + public System.Exception? Exception { get; set; } + public System.Collections.Generic.IList> Messages { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } + public class ChangeSetAggregator : System.IDisposable + where TObject : notnull + where TKey : notnull + { + public ChangeSetAggregator(System.IObservable> source) { } + public bool Completed { get; } + public DynamicData.IObservableCache Data { get; } + public System.Exception? Error { get; } + public System.Collections.Generic.IList> Messages { get; } + public DynamicData.Diagnostics.ChangeSummary Summary { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } + public class DistinctChangeSetAggregator : System.IDisposable + where TValue : notnull + { + public DistinctChangeSetAggregator(System.IObservable> source) { } + public DynamicData.IObservableCache Data { get; } + public System.Exception? Error { get; } + public System.Collections.Generic.IList> Messages { get; } + public DynamicData.Diagnostics.ChangeSummary Summary { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } + public static class ListTextEx + { + public static DynamicData.Tests.ChangeSetAggregator AsAggregator(this System.IObservable> source) + where T : notnull { } + } + public class PagedChangeSetAggregator : System.IDisposable + where TObject : notnull + where TKey : notnull + { + public PagedChangeSetAggregator(System.IObservable> source) { } + public DynamicData.IObservableCache Data { get; } + public System.Exception? Error { get; } + public System.Collections.Generic.IList> Messages { get; } + public DynamicData.Diagnostics.ChangeSummary Summary { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } + public class SortedChangeSetAggregator : System.IDisposable + where TObject : notnull + where TKey : notnull + { + public SortedChangeSetAggregator(System.IObservable> source) { } + public DynamicData.IObservableCache Data { get; } + public System.Exception? Error { get; } + public System.Collections.Generic.IList> Messages { get; } + public DynamicData.Diagnostics.ChangeSummary Summary { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } + public static class TestEx + { + public static DynamicData.Tests.DistinctChangeSetAggregator AsAggregator(this System.IObservable> source) + where TValue : notnull { } + public static DynamicData.Tests.ChangeSetAggregator AsAggregator(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static DynamicData.Tests.PagedChangeSetAggregator AsAggregator(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static DynamicData.Tests.SortedChangeSetAggregator AsAggregator(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static DynamicData.Tests.VirtualChangeSetAggregator AsAggregator(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + } + public class VirtualChangeSetAggregator : System.IDisposable + where TObject : notnull + where TKey : notnull + { + public VirtualChangeSetAggregator(System.IObservable> source) { } + public DynamicData.IObservableCache Data { get; } + public System.Exception? Error { get; } + public System.Collections.Generic.IList> Messages { get; } + public DynamicData.Diagnostics.ChangeSummary Summary { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } +} \ No newline at end of file diff --git a/src/DynamicData.Tests/API/ApiApprovalTests.DynamicDataTests.DotNet8_0.verified.txt b/src/DynamicData.Tests/API/ApiApprovalTests.DynamicDataTests.DotNet8_0.verified.txt new file mode 100644 index 000000000..d750fe8b1 --- /dev/null +++ b/src/DynamicData.Tests/API/ApiApprovalTests.DynamicDataTests.DotNet8_0.verified.txt @@ -0,0 +1,2727 @@ +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("DynamicData.Profile")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("DynamicData.ReactiveUI")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("DynamicData.Tests")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName=".NET 8.0")] +namespace DynamicData.Aggregation +{ + public readonly struct AggregateItem : System.IEquatable> + { + public AggregateItem(DynamicData.Aggregation.AggregateType type, TObject item) { } + public TObject Item { get; } + public DynamicData.Aggregation.AggregateType Type { get; } + public bool Equals(DynamicData.Aggregation.AggregateItem other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public static bool operator !=(DynamicData.Aggregation.AggregateItem left, DynamicData.Aggregation.AggregateItem right) { } + public static bool operator ==(DynamicData.Aggregation.AggregateItem left, DynamicData.Aggregation.AggregateItem right) { } + } + public enum AggregateType + { + Add = 0, + Remove = 1, + } + public static class AggregationEx + { + public static System.IObservable> ForAggregation(this System.IObservable> source) + where TObject : notnull { } + public static System.IObservable> ForAggregation(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable InvalidateWhen(this System.IObservable source, System.IObservable invalidate) { } + public static System.IObservable InvalidateWhen(this System.IObservable source, System.IObservable invalidate) { } + } + public static class AvgEx + { + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal emptyValue) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, double emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, int emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, long emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, float emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal emptyValue) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, double emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, float emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, int emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, long emptyValue = 0) { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal emptyValue) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, double emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, int emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, long emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, float emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal emptyValue) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, double emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, float emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, int emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, long emptyValue = 0) + where T : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal emptyValue) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, double emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, int emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, long emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, float emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal emptyValue) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, double emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, float emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, int emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Avg(this System.IObservable> source, System.Func valueSelector, long emptyValue = 0) + where TObject : notnull + where TKey : notnull { } + } + public static class CountEx + { + public static System.IObservable Count(this System.IObservable> source) { } + public static System.IObservable Count(this System.IObservable> source) + where TObject : notnull { } + public static System.IObservable Count(this System.IObservable> source) + where TObject : notnull { } + public static System.IObservable Count(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable IsEmpty(this System.IObservable> source) + where TObject : notnull { } + public static System.IObservable IsEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable IsNotEmpty(this System.IObservable> source) + where TObject : notnull { } + public static System.IObservable IsNotEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + } + public interface IAggregateChangeSet : System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable { } + public static class MaxEx + { + public static System.IObservable Maximum(this System.IObservable> source, System.Func valueSelector, TResult emptyValue = default) + where TObject : notnull + where TResult : struct, System.IComparable { } + public static System.IObservable Maximum(this System.IObservable> source, System.Func valueSelector, TResult emptyValue = default) + where TObject : notnull + where TKey : notnull + where TResult : struct, System.IComparable { } + public static System.IObservable Minimum(this System.IObservable> source, System.Func valueSelector, TResult emptyValue = default) + where TObject : notnull + where TResult : struct, System.IComparable { } + public static System.IObservable Minimum(this System.IObservable> source, System.Func valueSelector, TResult emptyValue = default) + where TObject : notnull + where TKey : notnull + where TResult : struct, System.IComparable { } + } + public static class StdDevEx + { + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, [System.Runtime.CompilerServices.DecimalConstant(0, 0, 0u, 0u, 0u)] decimal fallbackValue) { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, double fallbackValue = 0) { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, int fallbackValue = 0) { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, long fallbackValue = 0) { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, float fallbackValue = 0) { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, decimal fallbackValue) + where T : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, double fallbackValue) + where T : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, int fallbackValue) + where T : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, long fallbackValue) + where T : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, float fallbackValue = 0) + where T : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, decimal fallbackValue) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, double fallbackValue) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, int fallbackValue) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, long fallbackValue) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable StdDev(this System.IObservable> source, System.Func valueSelector, float fallbackValue = 0) + where TObject : notnull + where TKey : notnull { } + } + public static class SumEx + { + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable Sum(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull { } + } +} +namespace DynamicData.Alias +{ + public static class ObservableCacheAlias + { + public static System.IObservable> Select(this System.IObservable> source, System.Func transformFactory, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Select(this System.IObservable> source, System.Func transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Select(this System.IObservable> source, System.Func transformFactory, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Select(this System.IObservable> source, System.Func transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> SelectMany(this System.IObservable> source, System.Func> manySelector, System.Func keySelector) + where TDestination : notnull + where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { } + public static System.IObservable> SelectSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> SelectSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> SelectSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> SelectSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable, TKey>> SelectTree(this System.IObservable> source, System.Func pivotOn) + where TObject : class + where TKey : notnull { } + public static System.IObservable> Where(this System.IObservable> source, System.Func filter) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Where(this System.IObservable> source, System.IObservable> predicateChanged) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Where(this System.IObservable> source, System.IObservable reapplyFilter) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Where(this System.IObservable> source, System.IObservable> predicateChanged, System.IObservable reapplyFilter) + where TObject : notnull + where TKey : notnull { } + } + public static class ObservableListAlias + { + public static System.IObservable> Select(this System.IObservable> source, System.Func transformFactory) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> SelectMany(this System.IObservable> source, System.Func> manySelector) + where TDestination : notnull + where TSource : notnull { } + public static System.IObservable> Where(this System.IObservable> source, System.Func predicate) + where T : notnull { } + public static System.IObservable> Where(this System.IObservable> source, System.IObservable> predicate) + where T : notnull { } + } +} +namespace DynamicData.Binding +{ + public abstract class AbstractNotifyPropertyChanged : System.ComponentModel.INotifyPropertyChanged + { + protected AbstractNotifyPropertyChanged() { } + public event System.ComponentModel.PropertyChangedEventHandler? PropertyChanged; + protected virtual void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) { } + protected virtual void SetAndRaise(ref T backingField, T newValue, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) { } + protected virtual void SetAndRaise(ref T backingField, T newValue, System.Collections.Generic.IEqualityComparer? comparer, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) { } + [System.Obsolete("This never worked properly in the first place")] + public System.IDisposable SuspendNotifications(bool invokePropertyChangeEventWhenDisposed = true) { } + } + public class BindingListAdaptor : DynamicData.IChangeSetAdaptor + where T : notnull + { + public BindingListAdaptor(System.ComponentModel.BindingList list, int refreshThreshold = 25) { } + public void Adapt(DynamicData.IChangeSet changes) { } + } + public class BindingListAdaptor : DynamicData.IChangeSetAdaptor + where TObject : notnull + where TKey : notnull + { + public BindingListAdaptor(System.ComponentModel.BindingList list, int refreshThreshold = 25) { } + public void Adapt(DynamicData.IChangeSet changes) { } + } + public static class BindingListEx + { + public static System.IObservable> ObserveCollectionChanges(this System.ComponentModel.IBindingList source) { } + public static System.IObservable> ToObservableChangeSet(this System.ComponentModel.BindingList source) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this TCollection source) + where TCollection : System.ComponentModel.IBindingList, System.Collections.Generic.IEnumerable + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.ComponentModel.BindingList source, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + } + public interface IEvaluateAware + { + void Evaluate(); + } + public interface IIndexAware + { + int Index { get; set; } + } + public interface INotifyCollectionChangedSuspender + { + System.IDisposable SuspendCount(); + System.IDisposable SuspendNotifications(); + } + public interface IObservableCollectionAdaptor + where TObject : notnull + where TKey : notnull + { + void Adapt(DynamicData.IChangeSet changes, DynamicData.Binding.IObservableCollection collection); + } + public interface IObservableCollection : DynamicData.Binding.INotifyCollectionChangedSuspender, System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged + { + void Load(System.Collections.Generic.IEnumerable items); + void Move(int oldIndex, int newIndex); + } + public static class IObservableListEx + { + public static System.IObservable> BindToObservableList(this System.IObservable> source, out DynamicData.IObservableList observableList) + where TObject : notnull { } + public static System.IObservable> BindToObservableList(this System.IObservable> source, out DynamicData.IObservableList observableList) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BindToObservableList(this System.IObservable> source, out DynamicData.IObservableList observableList) + where TObject : notnull + where TKey : notnull { } + } + public interface ISortedObservableCollectionAdaptor + where TObject : notnull + where TKey : notnull + { + void Adapt(DynamicData.ISortedChangeSet changes, DynamicData.Binding.IObservableCollection collection); + } + public static class NotifyPropertyChangedEx + { + public static System.IObservable WhenAnyPropertyChanged(this TObject source, params string[] propertiesToMonitor) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenChanged(this TObject source, System.Linq.Expressions.Expression> p1, System.Func resultSelector, System.Func? p1Fallback = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenChanged(this TObject source, System.Linq.Expressions.Expression> p1, System.Linq.Expressions.Expression> p2, System.Func resultSelector, System.Func? p1Fallback = null, System.Func? p2Fallback = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenChanged(this TObject source, System.Linq.Expressions.Expression> p1, System.Linq.Expressions.Expression> p2, System.Linq.Expressions.Expression> p3, System.Func resultSelector, System.Func? p1Fallback = null, System.Func? p2Fallback = null, System.Func? p3Fallback = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenChanged(this TObject source, System.Linq.Expressions.Expression> p1, System.Linq.Expressions.Expression> p2, System.Linq.Expressions.Expression> p3, System.Linq.Expressions.Expression> p4, System.Func resultSelector, System.Func? p1Fallback = null, System.Func? p2Fallback = null, System.Func? p3Fallback = null, System.Func? p4Fallback = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenChanged(this TObject source, System.Linq.Expressions.Expression> p1, System.Linq.Expressions.Expression> p2, System.Linq.Expressions.Expression> p3, System.Linq.Expressions.Expression> p4, System.Linq.Expressions.Expression> p5, System.Func resultSelector, System.Func? p1Fallback = null, System.Func? p2Fallback = null, System.Func? p3Fallback = null, System.Func? p4Fallback = null, System.Func? p5Fallback = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenChanged(this TObject source, System.Linq.Expressions.Expression> p1, System.Linq.Expressions.Expression> p2, System.Linq.Expressions.Expression> p3, System.Linq.Expressions.Expression> p4, System.Linq.Expressions.Expression> p5, System.Linq.Expressions.Expression> p6, System.Func resultSelector, System.Func? p1Fallback = null, System.Func? p2Fallback = null, System.Func? p3Fallback = null, System.Func? p4Fallback = null, System.Func? p5Fallback = null, System.Func? p6Fallback = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable> WhenPropertyChanged(this TObject source, System.Linq.Expressions.Expression> propertyAccessor, bool notifyOnInitialValue = true, System.Func? fallbackValue = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenValueChanged(this TObject source, System.Linq.Expressions.Expression> propertyAccessor, bool notifyOnInitialValue = true, System.Func? fallbackValue = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + } + public class ObservableCollectionAdaptor : DynamicData.IChangeSetAdaptor + where T : notnull + { + public ObservableCollectionAdaptor(DynamicData.Binding.IObservableCollection collection, int refreshThreshold = 25) { } + public void Adapt(DynamicData.IChangeSet changes) { } + } + public class ObservableCollectionAdaptor : DynamicData.Binding.IObservableCollectionAdaptor + where TObject : notnull + where TKey : notnull + { + public ObservableCollectionAdaptor(int refreshThreshold = 25, bool useReplaceForUpdates = false) { } + public void Adapt(DynamicData.IChangeSet changes, DynamicData.Binding.IObservableCollection collection) { } + } + public static class ObservableCollectionEx + { + public static System.IObservable> ObserveCollectionChanges(this System.Collections.Specialized.INotifyCollectionChanged source) { } + public static System.IObservable> ToObservableChangeSet(this System.Collections.ObjectModel.ObservableCollection source) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.Collections.ObjectModel.ReadOnlyObservableCollection source) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this TCollection source) + where TCollection : System.Collections.Specialized.INotifyCollectionChanged, System.Collections.Generic.IEnumerable + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.Collections.ObjectModel.ObservableCollection source, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.Collections.ObjectModel.ReadOnlyObservableCollection source, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + } + public class ObservableCollectionExtended : System.Collections.ObjectModel.ObservableCollection, DynamicData.Binding.INotifyCollectionChangedSuspender, DynamicData.Binding.IObservableCollection, DynamicData.IExtendedList, System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged + { + public ObservableCollectionExtended() { } + public ObservableCollectionExtended(System.Collections.Generic.IEnumerable collection) { } + public ObservableCollectionExtended(System.Collections.Generic.List list) { } + public void AddRange(System.Collections.Generic.IEnumerable collection) { } + public void InsertRange(System.Collections.Generic.IEnumerable collection, int index) { } + public void Load(System.Collections.Generic.IEnumerable items) { } + protected override void OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { } + protected override void OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e) { } + public void RemoveRange(int index, int count) { } + public System.IDisposable SuspendCount() { } + public System.IDisposable SuspendNotifications() { } + } + public sealed class PropertyValue : System.IEquatable> + { + public PropertyValue(TObject sender, TValue value) { } + public TObject Sender { get; } + public TValue Value { get; } + public bool Equals(DynamicData.Binding.PropertyValue? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Binding.PropertyValue? left, DynamicData.Binding.PropertyValue? right) { } + public static bool operator ==(DynamicData.Binding.PropertyValue? left, DynamicData.Binding.PropertyValue? right) { } + } + public enum SortDirection + { + Ascending = 0, + Descending = 1, + } + public class SortExpressionComparer : System.Collections.Generic.List>, System.Collections.Generic.IComparer + { + public SortExpressionComparer() { } + public int Compare(T? x, T? y) { } + public DynamicData.Binding.SortExpressionComparer ThenByAscending(System.Func expression) { } + public DynamicData.Binding.SortExpressionComparer ThenByDescending(System.Func expression) { } + public static DynamicData.Binding.SortExpressionComparer Ascending(System.Func expression) { } + public static DynamicData.Binding.SortExpressionComparer Descending(System.Func expression) { } + } + public class SortExpression + { + public SortExpression(System.Func expression, DynamicData.Binding.SortDirection direction = 0) { } + public DynamicData.Binding.SortDirection Direction { get; } + public System.Func Expression { get; } + } + public class SortedBindingListAdaptor : DynamicData.ISortedChangeSetAdaptor + where TObject : notnull + where TKey : notnull + { + public SortedBindingListAdaptor(System.ComponentModel.BindingList list, int refreshThreshold = 25) { } + public void Adapt(DynamicData.ISortedChangeSet changes) { } + } + public class SortedObservableCollectionAdaptor : DynamicData.Binding.ISortedObservableCollectionAdaptor + where TObject : notnull + where TKey : notnull + { + public SortedObservableCollectionAdaptor(int refreshThreshold = 25, bool useReplaceForUpdates = true) { } + public void Adapt(DynamicData.ISortedChangeSet changes, DynamicData.Binding.IObservableCollection collection) { } + } +} +namespace DynamicData.Cache.Internal +{ + public enum CombineOperator + { + And = 0, + Or = 1, + Xor = 2, + Except = 3, + } + [System.Serializable] + public class KeySelectorException : System.Exception + { + public KeySelectorException() { } + public KeySelectorException(string message) { } + public KeySelectorException(string message, System.Exception innerException) { } + } + [System.Diagnostics.DebuggerDisplay("LockFreeObservableCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Ite" + + "ms)")] + public sealed class LockFreeObservableCache : DynamicData.IConnectableCache, DynamicData.IObservableCache, System.IDisposable + where TObject : notnull + where TKey : notnull + { + public LockFreeObservableCache() { } + public LockFreeObservableCache(System.IObservable> source) { } + public int Count { get; } + public System.IObservable CountChanged { get; } + public System.Collections.Generic.IEnumerable Items { get; } + public System.Collections.Generic.IEnumerable> KeyValues { get; } + public System.Collections.Generic.IEnumerable Keys { get; } + public System.IObservable> Connect(System.Func? predicate = null, bool suppressEmptyChangeSets = true) { } + public void Dispose() { } + public void Edit(System.Action> editAction) { } + public DynamicData.Kernel.Optional Lookup(TKey key) { } + public System.IObservable> Preview(System.Func? predicate = null) { } + public System.IObservable> Watch(TKey key) { } + } +} +namespace DynamicData +{ + public sealed class ChangeAwareCache : DynamicData.ICache, DynamicData.IQuery + where TObject : notnull + where TKey : notnull + { + public ChangeAwareCache() { } + public ChangeAwareCache(System.Collections.Generic.Dictionary data) { } + public ChangeAwareCache(int capacity) { } + public int Count { get; } + public System.Collections.Generic.IEnumerable Items { get; } + public System.Collections.Generic.IEnumerable> KeyValues { get; } + public System.Collections.Generic.IEnumerable Keys { get; } + public void Add(TObject item, TKey key) { } + public void AddOrUpdate(TObject item, TKey key) { } + public DynamicData.ChangeSet CaptureChanges() { } + public void Clear() { } + public void Clone(DynamicData.IChangeSet changes) { } + public DynamicData.Kernel.Optional Lookup(TKey key) { } + public void Refresh() { } + public void Refresh(System.Collections.Generic.IEnumerable keys) { } + public void Refresh(TKey key) { } + public void Remove(System.Collections.Generic.IEnumerable keys) { } + public void Remove(TKey key) { } + } + public class ChangeAwareList : DynamicData.IExtendedList, System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.IEnumerable + where T : notnull + { + public ChangeAwareList(System.Collections.Generic.IEnumerable items) { } + public ChangeAwareList(int capacity = -1) { } + public ChangeAwareList(DynamicData.ChangeAwareList list, bool copyChanges) { } + public int Capacity { get; set; } + public int Count { get; } + public bool IsReadOnly { get; } + public T this[int index] { get; set; } + public void Add(T item) { } + public void AddRange(System.Collections.Generic.IEnumerable collection) { } + public DynamicData.IChangeSet CaptureChanges() { } + public virtual void Clear() { } + public virtual bool Contains(T item) { } + public void CopyTo(T[] array, int arrayIndex) { } + public System.Collections.Generic.IEnumerator GetEnumerator() { } + public int IndexOf(T item) { } + public int IndexOf(T item, System.Collections.Generic.IEqualityComparer equalityComparer) { } + public void Insert(int index, T item) { } + protected virtual void InsertItem(int index, T item) { } + public void InsertRange(System.Collections.Generic.IEnumerable collection, int index) { } + public virtual void Move(int original, int destination) { } + public virtual void Move(T item, int destination) { } + protected virtual void OnInsertItems(int startIndex, System.Collections.Generic.IEnumerable items) { } + protected virtual void OnRemoveItems(int startIndex, System.Collections.Generic.IEnumerable items) { } + protected virtual void OnSetItem(int index, T newItem, T oldItem) { } + public bool Refresh(T item) { } + public void Refresh(T item, int index) { } + public void RefreshAt(int index) { } + public bool Remove(T item) { } + public void RemoveAt(int index) { } + protected void RemoveItem(int index) { } + protected virtual void RemoveItem(int index, T item) { } + public void RemoveRange(int index, int count) { } + protected virtual void SetItem(int index, T item) { } + } + public enum ChangeReason + { + Add = 0, + Update = 1, + Remove = 2, + Refresh = 3, + Moved = 4, + } + public static class ChangeSetEx + { + public static System.Collections.Generic.IEnumerable> Flatten(this DynamicData.IChangeSet source) + where T : notnull { } + public static DynamicData.ChangeType GetChangeType(this DynamicData.ListChangeReason source) { } + public static DynamicData.IChangeSet Transform(this DynamicData.IChangeSet source, System.Func transformer) + where TSource : notnull + where TDestination : notnull { } + public static System.Collections.Generic.IEnumerable> YieldWithoutIndex(this System.Collections.Generic.IEnumerable> source) + where T : notnull { } + } + public class ChangeSet : System.Collections.Generic.List>, DynamicData.IChangeSet, DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where T : notnull + { + public static readonly DynamicData.IChangeSet Empty; + public ChangeSet() { } + public ChangeSet(System.Collections.Generic.IEnumerable> items) { } + public int Adds { get; } + public int Moves { get; } + public int Refreshes { get; } + public int Removes { get; } + public int Replaced { get; } + public int TotalChanges { get; } + public override string ToString() { } + } + public class ChangeSet : System.Collections.Generic.List>, DynamicData.IChangeSet, DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + { + public static readonly DynamicData.ChangeSet Empty; + public ChangeSet() { } + public ChangeSet(System.Collections.Generic.IEnumerable> collection) { } + public ChangeSet(int capacity) { } + public int Adds { get; } + public int Moves { get; } + public int Refreshes { get; } + public int Removes { get; } + public int Updates { get; } + public override string ToString() { } + } + public enum ChangeType + { + Item = 0, + Range = 1, + } + public sealed class Change : System.IEquatable> + where T : notnull + { + public Change(DynamicData.ListChangeReason reason, System.Collections.Generic.IEnumerable items, int index = -1) { } + public Change(DynamicData.ListChangeReason reason, T current, int index = -1) { } + public Change(T current, int currentIndex, int previousIndex) { } + public Change(DynamicData.ListChangeReason reason, T current, DynamicData.Kernel.Optional previous, int currentIndex = -1, int previousIndex = -1) { } + public DynamicData.ItemChange Item { get; } + public DynamicData.RangeChange Range { get; } + public DynamicData.ListChangeReason Reason { get; } + public DynamicData.ChangeType Type { get; } + public bool Equals(DynamicData.Change? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Change left, DynamicData.Change right) { } + public static bool operator ==(DynamicData.Change left, DynamicData.Change right) { } + } + public readonly struct Change : System.IEquatable> + where TObject : notnull + where TKey : notnull + { + public Change(DynamicData.ChangeReason reason, TKey key, TObject current, int index = -1) { } + public Change(TKey key, TObject current, int currentIndex, int previousIndex) { } + public Change(DynamicData.ChangeReason reason, TKey key, TObject current, DynamicData.Kernel.Optional previous, int currentIndex = -1, int previousIndex = -1) { } + public TObject Current { get; } + public int CurrentIndex { get; } + public TKey Key { get; } + public DynamicData.Kernel.Optional Previous { get; } + public int PreviousIndex { get; } + public DynamicData.ChangeReason Reason { get; } + public bool Equals(DynamicData.Change other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Change left, DynamicData.Change right) { } + public static bool operator ==(DynamicData.Change left, DynamicData.Change right) { } + } + public static class EnumerableEx + { + public static System.IObservable> AsObservableChangeSet(this System.Collections.Generic.IEnumerable source, bool completable = false) + where TObject : notnull { } + public static System.IObservable> AsObservableChangeSet(this System.Collections.Generic.IEnumerable source, System.Func keySelector, bool completable = false) + where TObject : notnull + where TKey : notnull { } + } + public interface ICacheUpdater : DynamicData.IQuery + where TObject : notnull + where TKey : notnull + { + void AddOrUpdate(System.Collections.Generic.IEnumerable> keyValuePairs); + void AddOrUpdate(System.Collections.Generic.KeyValuePair item); + void AddOrUpdate(TObject item, TKey key); + void Clear(); + void Clone(DynamicData.IChangeSet changes); + [System.Obsolete("Use Refresh: Same thing but better semantics")] + void Evaluate(); + [System.Obsolete("Use Refresh: Same thing but better semantics")] + void Evaluate(System.Collections.Generic.IEnumerable keys); + [System.Obsolete("Use Refresh: Same thing but better semantics")] + void Evaluate(TKey key); + TKey GetKey(TObject item); + System.Collections.Generic.IEnumerable> GetKeyValues(System.Collections.Generic.IEnumerable items); + void Refresh(); + void Refresh(System.Collections.Generic.IEnumerable keys); + void Refresh(TKey key); + void Remove(System.Collections.Generic.IEnumerable> items); + void Remove(System.Collections.Generic.IEnumerable keys); + void Remove(System.Collections.Generic.KeyValuePair item); + void Remove(TKey key); + void RemoveKey(TKey key); + void RemoveKeys(System.Collections.Generic.IEnumerable key); + [System.Obsolete("Use Clone()")] + void Update(DynamicData.IChangeSet changes); + } + public interface ICache : DynamicData.IQuery + where TObject : notnull + where TKey : notnull + { + void AddOrUpdate(TObject item, TKey key); + void Clear(); + void Clone(DynamicData.IChangeSet changes); + void Refresh(); + void Refresh(System.Collections.Generic.IEnumerable keys); + void Refresh(TKey key); + void Remove(System.Collections.Generic.IEnumerable keys); + void Remove(TKey key); + } + public interface IChangeSet + { + int Adds { get; } + int Capacity { get; set; } + int Count { get; } + int Moves { get; } + int Refreshes { get; } + int Removes { get; } + } + public interface IChangeSetAdaptor + where T : notnull + { + void Adapt(DynamicData.IChangeSet change); + } + public interface IChangeSetAdaptor + where TObject : notnull + where TKey : notnull + { + void Adapt(DynamicData.IChangeSet change); + } + public interface IChangeSet : DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TObject : notnull + { + int Replaced { get; } + int TotalChanges { get; } + } + public interface IChangeSet : DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + { + int Updates { get; } + } + public interface IConnectableCache + where TObject : notnull + where TKey : notnull + { + System.IObservable CountChanged { get; } + System.IObservable> Connect(System.Func? predicate = null, bool suppressEmptyChangeSets = true); + System.IObservable> Preview(System.Func? predicate = null); + System.IObservable> Watch(TKey key); + } + public interface IDistinctChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where T : notnull { } + public interface IExtendedList : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.IEnumerable + { + void AddRange(System.Collections.Generic.IEnumerable collection); + void InsertRange(System.Collections.Generic.IEnumerable collection, int index); + void Move(int original, int destination); + void RemoveRange(int index, int count); + } + public interface IGroupChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, TGroupKey>, System.Collections.Generic.IEnumerable, TGroupKey>>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public interface IGroup + where TObject : notnull + { + TGroup GroupKey { get; } + DynamicData.IObservableList List { get; } + } + public interface IGroup : DynamicData.IKey + where TObject : notnull + where TKey : notnull + { + DynamicData.IObservableCache Cache { get; } + } + public interface IGrouping + where TObject : notnull + { + int Count { get; } + System.Collections.Generic.IEnumerable Items { get; } + TGroupKey Key { get; } + System.Collections.Generic.IEnumerable> KeyValues { get; } + System.Collections.Generic.IEnumerable Keys { get; } + DynamicData.Kernel.Optional Lookup(TKey key); + } + public interface IImmutableGroupChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, TGroupKey>, System.Collections.Generic.IEnumerable, TGroupKey>>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public interface IIntermediateCache : DynamicData.IConnectableCache, DynamicData.IObservableCache, System.IDisposable + where TObject : notnull + where TKey : notnull + { + void Edit(System.Action> updateAction); + } + public interface IKeyValueCollection : System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + { + System.Collections.Generic.IComparer> Comparer { get; } + int Count { get; } + System.Collections.Generic.KeyValuePair this[int index] { get; } + DynamicData.SortOptimisations Optimisations { get; } + DynamicData.SortReason SortReason { get; } + } + public interface IKeyValue : DynamicData.IKey + { + TObject Value { get; } + } + public interface IKey + { + T Key { get; } + } + public interface IObservableCache : DynamicData.IConnectableCache, System.IDisposable + where TObject : notnull + where TKey : notnull + { + int Count { get; } + System.Collections.Generic.IEnumerable Items { get; } + System.Collections.Generic.IEnumerable> KeyValues { get; } + System.Collections.Generic.IEnumerable Keys { get; } + DynamicData.Kernel.Optional Lookup(TKey key); + } + public interface IObservableList : System.IDisposable + where T : notnull + { + int Count { get; } + System.IObservable CountChanged { get; } + System.Collections.Generic.IEnumerable Items { get; } + System.IObservable> Connect(System.Func? predicate = null); + System.IObservable> Preview(System.Func? predicate = null); + } + public interface IPageChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where T : notnull + { + DynamicData.Operators.IPageResponse Response { get; } + } + public interface IPageRequest + { + int Page { get; } + int Size { get; } + } + public interface IPagedChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, DynamicData.ISortedChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + { + DynamicData.Operators.IPageResponse Response { get; } + } + public interface IQuery + where TObject : notnull + { + int Count { get; } + System.Collections.Generic.IEnumerable Items { get; } + System.Collections.Generic.IEnumerable> KeyValues { get; } + System.Collections.Generic.IEnumerable Keys { get; } + DynamicData.Kernel.Optional Lookup(TKey key); + } + public interface ISortedChangeSetAdaptor + where TObject : notnull + where TKey : notnull + { + void Adapt(DynamicData.ISortedChangeSet change); + } + public interface ISortedChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + { + DynamicData.IKeyValueCollection SortedItems { get; } + } + public interface ISourceCache : DynamicData.IConnectableCache, DynamicData.IObservableCache, System.IDisposable + where TObject : notnull + where TKey : notnull + { + System.Func KeySelector { get; } + void Edit(System.Action> updateAction); + } + public interface ISourceList : DynamicData.IObservableList, System.IDisposable + where T : notnull + { + void Edit(System.Action> updateAction); + } + public interface ISourceUpdater : DynamicData.ICacheUpdater, DynamicData.IQuery + where TObject : notnull + where TKey : notnull + { + void AddOrUpdate(System.Collections.Generic.IEnumerable items); + void AddOrUpdate(TObject item); + void AddOrUpdate(System.Collections.Generic.IEnumerable items, System.Collections.Generic.IEqualityComparer comparer); + void AddOrUpdate(TObject item, System.Collections.Generic.IEqualityComparer comparer); + [System.Obsolete("Use Refresh: Same thing but better semantics")] + void Evaluate(System.Collections.Generic.IEnumerable items); + [System.Obsolete("Use Refresh: Same thing but better semantics")] + void Evaluate(TObject item); + void Load(System.Collections.Generic.IEnumerable items); + void Refresh(System.Collections.Generic.IEnumerable items); + void Refresh(TObject item); + void Remove(System.Collections.Generic.IEnumerable items); + void Remove(TObject item); + } + public interface IVirtualChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where T : notnull + { + DynamicData.IVirtualResponse Response { get; } + } + public interface IVirtualChangeSet : DynamicData.IChangeSet, DynamicData.IChangeSet, DynamicData.ISortedChangeSet, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TObject : notnull + where TKey : notnull + { + DynamicData.IVirtualResponse Response { get; } + } + public interface IVirtualRequest + { + int Size { get; } + int StartIndex { get; } + } + public interface IVirtualResponse + { + int Size { get; } + int StartIndex { get; } + int TotalSize { get; } + } + public sealed class IndexedItem : System.IEquatable> + { + public IndexedItem(TObject value, TKey key, int index) { } + public int Index { get; } + public TKey Key { get; } + public TObject Value { get; } + public bool Equals(DynamicData.IndexedItem? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + } + [System.Diagnostics.DebuggerDisplay("IntermediateCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Items)")] + public sealed class IntermediateCache : DynamicData.IConnectableCache, DynamicData.IIntermediateCache, DynamicData.IObservableCache, System.IDisposable + where TObject : notnull + where TKey : notnull + { + public IntermediateCache() { } + public IntermediateCache(System.IObservable> source) { } + public int Count { get; } + public System.IObservable CountChanged { get; } + public System.Collections.Generic.IEnumerable Items { get; } + public System.Collections.Generic.IEnumerable> KeyValues { get; } + public System.Collections.Generic.IEnumerable Keys { get; } + public System.IObservable> Connect(System.Func? predicate = null, bool suppressEmptyChangeSets = true) { } + public void Dispose() { } + public void Edit(System.Action> updateAction) { } + public DynamicData.Kernel.Optional Lookup(TKey key) { } + public System.IObservable> Preview(System.Func? predicate = null) { } + public System.IObservable> Watch(TKey key) { } + } + public readonly struct ItemChange : System.IEquatable> + where T : notnull + { + public static readonly DynamicData.ItemChange Empty; + public ItemChange(DynamicData.ListChangeReason reason, T current, int currentIndex) { } + public ItemChange(DynamicData.ListChangeReason reason, T current, DynamicData.Kernel.Optional previous, int currentIndex = -1, int previousIndex = -1) { } + public T Current { get; } + public int CurrentIndex { get; } + public DynamicData.Kernel.Optional Previous { get; } + public int PreviousIndex { get; } + public DynamicData.ListChangeReason Reason { get; } + public bool Equals(DynamicData.ItemChange other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.ItemChange left, DynamicData.ItemChange right) { } + public static bool operator ==(DynamicData.ItemChange left, DynamicData.ItemChange right) { } + } + public enum ListChangeReason + { + Add = 0, + AddRange = 1, + Replace = 2, + Remove = 3, + RemoveRange = 4, + Refresh = 5, + Moved = 6, + Clear = 7, + } + public static class ListEx + { + public static void Add(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable items) { } + public static void AddOrInsertRange(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable items, int index) { } + public static void AddRange(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable items) { } + public static void AddRange(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable items, int index) { } + public static int BinarySearch(this System.Collections.Generic.IList list, TItem value) { } + public static int BinarySearch(this System.Collections.Generic.IList list, TItem value, System.Collections.Generic.IComparer comparer) { } + public static int BinarySearch(this System.Collections.Generic.IList list, TSearch value, System.Func comparer) { } + public static void Clone(this System.Collections.Generic.IList source, DynamicData.IChangeSet changes) + where T : notnull { } + public static void Clone(this System.Collections.Generic.IList source, DynamicData.IChangeSet changes, System.Collections.Generic.IEqualityComparer? equalityComparer) + where T : notnull { } + public static void Clone(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable> changes, System.Collections.Generic.IEqualityComparer? equalityComparer) + where T : notnull { } + public static int IndexOf(this System.Collections.Generic.IEnumerable source, T item) { } + public static int IndexOf(this System.Collections.Generic.IEnumerable source, T item, System.Collections.Generic.IEqualityComparer equalityComparer) { } + public static DynamicData.Kernel.Optional> IndexOfOptional(this System.Collections.Generic.IEnumerable source, T item, System.Collections.Generic.IEqualityComparer? equalityComparer = null) { } + public static void Remove(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable items) { } + public static void RemoveMany(this System.Collections.Generic.IList source, System.Collections.Generic.IEnumerable itemsToRemove) { } + public static void Replace(this System.Collections.Generic.IList source, T original, T replaceWith) { } + public static void Replace(this System.Collections.Generic.IList source, T original, T replaceWith, System.Collections.Generic.IEqualityComparer comparer) { } + public static void ReplaceOrAdd(this System.Collections.Generic.IList source, T original, T replaceWith) { } + } + public enum ListFilterPolicy + { + ClearAndReplace = 0, + CalculateDiff = 1, + } + [System.Serializable] + public class MissingKeyException : System.Exception + { + public MissingKeyException() { } + public MissingKeyException(string message) { } + public MissingKeyException(string message, System.Exception innerException) { } + } + public class Node : System.IDisposable, System.IEquatable> + where TObject : class + where TKey : notnull + { + public Node(TObject item, TKey key) { } + public Node(TObject item, TKey key, DynamicData.Kernel.Optional> parent) { } + public DynamicData.IObservableCache, TKey> Children { get; } + public int Depth { get; } + public bool IsRoot { get; } + public TObject Item { get; } + public TKey Key { get; } + public DynamicData.Kernel.Optional> Parent { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + public bool Equals(DynamicData.Node? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Node left, DynamicData.Node right) { } + public static bool operator ==(DynamicData.Node? left, DynamicData.Node? right) { } + } + public static class ObservableCacheEx + { + public static System.IObservable> Adapt(this System.IObservable> source, DynamicData.IChangeSetAdaptor adaptor) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Adapt(this System.IObservable> source, DynamicData.ISortedChangeSetAdaptor adaptor) + where TObject : notnull + where TKey : notnull { } + public static void AddOrUpdate(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable items) + where TObject : notnull + where TKey : notnull { } + public static void AddOrUpdate(this DynamicData.ISourceCache source, TObject item) + where TObject : notnull + where TKey : notnull { } + public static void AddOrUpdate(this DynamicData.IIntermediateCache source, TObject item, TKey key) + where TObject : notnull + where TKey : notnull { } + public static void AddOrUpdate(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable items, System.Collections.Generic.IEqualityComparer equalityComparer) + where TObject : notnull + where TKey : notnull { } + public static void AddOrUpdate(this DynamicData.ISourceCache source, TObject item, System.Collections.Generic.IEqualityComparer equalityComparer) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> And(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> And(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> And(this DynamicData.IObservableList>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> And(this System.Collections.Generic.ICollection>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> And(this System.IObservable> source, params System.IObservable>[] others) + where TObject : notnull + where TKey : notnull { } + public static DynamicData.IObservableCache AsObservableCache(this DynamicData.IObservableCache source) + where TObject : notnull + where TKey : notnull { } + public static DynamicData.IObservableCache AsObservableCache(this System.IObservable> source, bool applyLocking = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> AutoRefresh(this System.IObservable> source, System.TimeSpan? changeSetBuffer = default, System.TimeSpan? propertyChangeThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull { } + public static System.IObservable> AutoRefresh(this System.IObservable> source, System.Linq.Expressions.Expression> propertyAccessor, System.TimeSpan? changeSetBuffer = default, System.TimeSpan? propertyChangeThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull { } + public static System.IObservable> AutoRefreshOnObservable(this System.IObservable> source, System.Func> reevaluator, System.TimeSpan? changeSetBuffer = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> AutoRefreshOnObservable(this System.IObservable> source, System.Func> reevaluator, System.TimeSpan? changeSetBuffer = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Batch(this System.IObservable> source, System.TimeSpan timeSpan, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BatchIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BatchIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, bool initialPauseState = false, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BatchIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, System.TimeSpan? timeOut = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BatchIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, bool initialPauseState = false, System.IObservable? timer = null, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BatchIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, bool initialPauseState = false, System.TimeSpan? timeOut = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, DynamicData.Binding.IObservableCollection destination) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, DynamicData.Binding.IObservableCollection destination, DynamicData.Binding.IObservableCollectionAdaptor updater) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, DynamicData.Binding.IObservableCollection destination, int refreshThreshold = 25) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, System.ComponentModel.BindingList bindingList, int resetThreshold = 25) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, DynamicData.Binding.IObservableCollection destination, DynamicData.Binding.ISortedObservableCollectionAdaptor updater) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, System.ComponentModel.BindingList bindingList, int resetThreshold = 25) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, out System.Collections.ObjectModel.ReadOnlyObservableCollection readOnlyObservableCollection, int resetThreshold = 25, bool useReplaceForUpdates = false, DynamicData.Binding.IObservableCollectionAdaptor? adaptor = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, out System.Collections.ObjectModel.ReadOnlyObservableCollection readOnlyObservableCollection, int resetThreshold = 25, bool useReplaceForUpdates = true, DynamicData.Binding.ISortedObservableCollectionAdaptor? adaptor = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> BufferInitial(this System.IObservable> source, System.TimeSpan initialBuffer, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Cast(this System.IObservable> source, System.Func converter) + where TSource : notnull + where TKey : notnull + where TDestination : notnull { } + public static System.IObservable> ChangeKey(this System.IObservable> source, System.Func keySelector) + where TObject : notnull + where TSourceKey : notnull + where TDestinationKey : notnull { } + public static System.IObservable> ChangeKey(this System.IObservable> source, System.Func keySelector) + where TObject : notnull + where TSourceKey : notnull + where TDestinationKey : notnull { } + public static void Clear(this DynamicData.Cache.Internal.LockFreeObservableCache source) + where TObject : notnull + where TKey : notnull { } + public static void Clear(this DynamicData.IIntermediateCache source) + where TObject : notnull + where TKey : notnull { } + public static void Clear(this DynamicData.ISourceCache source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Clone(this System.IObservable> source, System.Collections.Generic.ICollection target) + where TObject : notnull + where TKey : notnull { } + [System.Obsolete("This was an experiment that did not work. Use Transform instead")] + public static System.IObservable> Convert(this System.IObservable> source, System.Func conversionFactory) + where TObject : notnull + where TKey : notnull + where TDestination : notnull { } + public static System.IObservable> DeferUntilLoaded(this DynamicData.IObservableCache source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> DeferUntilLoaded(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> DisposeMany(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> DistinctValues(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TKey : notnull + where TValue : notnull { } + public static void EditDiff(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable allItems, System.Collections.Generic.IEqualityComparer equalityComparer) + where TObject : notnull + where TKey : notnull { } + public static void EditDiff(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable allItems, System.Func areItemsEqual) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> EditDiff(this System.IObservable> source, System.Func keySelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> EditDiff(this System.IObservable> source, System.Func keySelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> EnsureUniqueKeys(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + [System.Obsolete("Use Refresh: Same thing but better semantics")] + public static void Evaluate(this DynamicData.ISourceCache source) + where TObject : notnull + where TKey : notnull { } + [System.Obsolete("Use Refresh: Same thing but better semantics")] + public static void Evaluate(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable items) + where TObject : notnull + where TKey : notnull { } + [System.Obsolete("Use Refresh: Same thing but better semantics")] + public static void Evaluate(this DynamicData.ISourceCache source, TObject item) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Except(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Except(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Except(this DynamicData.IObservableList>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Except(this System.Collections.Generic.ICollection>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Except(this System.IObservable> source, params System.IObservable>[] others) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ExpireAfter(this System.IObservable> source, System.Func timeSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable>> ExpireAfter(this DynamicData.ISourceCache source, System.Func timeSelector, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable>> ExpireAfter(this DynamicData.ISourceCache source, System.Func timeSelector, System.TimeSpan? interval = default) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ExpireAfter(this System.IObservable> source, System.Func timeSelector, System.Reactive.Concurrency.IScheduler scheduler) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ExpireAfter(this System.IObservable> source, System.Func timeSelector, System.TimeSpan? pollingInterval) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable>> ExpireAfter(this DynamicData.ISourceCache source, System.Func timeSelector, System.TimeSpan? pollingInterval, System.Reactive.Concurrency.IScheduler? scheduler) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ExpireAfter(this System.IObservable> source, System.Func timeSelector, System.TimeSpan? pollingInterval, System.Reactive.Concurrency.IScheduler scheduler) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Filter(this System.IObservable> source, System.Func filter, bool suppressEmptyChangeSets = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Filter(this System.IObservable> source, System.IObservable> predicateChanged, bool suppressEmptyChangeSets = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Filter(this System.IObservable> source, System.IObservable reapplyFilter, bool suppressEmptyChangeSets = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Filter(this System.IObservable> source, System.IObservable> predicateChanged, System.IObservable reapplyFilter, bool suppressEmptyChangeSets = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> FilterOnObservable(this System.IObservable> source, System.Func> filterFactory, System.TimeSpan? buffer = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> FilterOnObservable(this System.IObservable> source, System.Func> filterFactory, System.TimeSpan? buffer = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + [System.Obsolete("Use AutoRefresh(), followed by Filter() instead")] + public static System.IObservable> FilterOnProperty(this System.IObservable> source, System.Linq.Expressions.Expression> propertySelector, System.Func predicate, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull { } + [System.Obsolete("This can cause unhandled exception issues so do not use")] + public static System.IObservable FinallySafe(this System.IObservable source, System.Action finallyAction) { } + public static System.IObservable> Flatten(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> FlattenBufferResult(this System.IObservable>> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ForEachChange(this System.IObservable> source, System.Action> action) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> FullJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, DynamicData.Kernel.Optional, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> FullJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, DynamicData.Kernel.Optional, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> FullJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, DynamicData.IGrouping, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> FullJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, DynamicData.IGrouping, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> Group(this System.IObservable> source, System.Func groupSelectorKey) + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> Group(this System.IObservable> source, System.Func groupSelector, System.IObservable> resultGroupSource) + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> Group(this System.IObservable> source, System.Func groupSelectorKey, System.IObservable regrouper) + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> GroupOnProperty(this System.IObservable> source, System.Linq.Expressions.Expression> propertySelector, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> GroupOnPropertyWithImmutableState(this System.IObservable> source, System.Linq.Expressions.Expression> propertySelector, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> GroupWithImmutableState(this System.IObservable> source, System.Func groupSelectorKey, System.IObservable? regrouper = null) + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> IgnoreSameReferenceUpdate(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> IgnoreUpdateWhen(this System.IObservable> source, System.Func ignoreFunction) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> IncludeUpdateWhen(this System.IObservable> source, System.Func includeFunction) + where TObject : notnull + where TKey : notnull { } + [return: System.Runtime.CompilerServices.TupleElementNames(new string[] { + "leftKey", + "rightKey"})] + public static System.IObservable>> InnerJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + [return: System.Runtime.CompilerServices.TupleElementNames(new string[] { + "leftKey", + "rightKey"})] + public static System.IObservable>> InnerJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, [System.Runtime.CompilerServices.TupleElementNames(new string[] { + "leftKey", + "rightKey"})] System.Func, TLeft, TRight, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> InnerJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> InnerJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> InvokeEvaluate(this System.IObservable> source) + where TObject : DynamicData.Binding.IEvaluateAware + where TKey : notnull { } + public static System.IObservable> LeftJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> LeftJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> LeftJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> LeftJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> LimitSizeTo(this System.IObservable> source, int size) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable>> LimitSizeTo(this DynamicData.ISourceCache source, int sizeLimit, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable>> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable>> source, System.Collections.Generic.IComparer comparer) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable>> source, System.Collections.Generic.IEqualityComparer equalityComparer) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.Collections.Generic.IEnumerable>> source, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable>> source, System.Collections.Generic.IEqualityComparer equalityComparer, System.Collections.Generic.IComparer comparer) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.Collections.Generic.IEnumerable>> source, System.Collections.Generic.IComparer comparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.Collections.Generic.IEnumerable>> source, System.Collections.Generic.IEqualityComparer equalityComparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.Collections.Generic.IEnumerable>> others, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.IObservable> other, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.Collections.Generic.IEnumerable>> source, System.Collections.Generic.IEqualityComparer equalityComparer, System.Collections.Generic.IComparer comparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.Collections.Generic.IEnumerable>> others, System.Collections.Generic.IComparer comparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.Collections.Generic.IEnumerable>> others, System.Collections.Generic.IEqualityComparer equalityComparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.IObservable> other, System.Collections.Generic.IComparer comparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.IObservable> other, System.Collections.Generic.IEqualityComparer equalityComparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.Collections.Generic.IEnumerable>> others, System.Collections.Generic.IEqualityComparer equalityComparer, System.Collections.Generic.IComparer comparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeChangeSets(this System.IObservable> source, System.IObservable> other, System.Collections.Generic.IEqualityComparer equalityComparer, System.Collections.Generic.IComparer comparer, System.Reactive.Concurrency.IScheduler? scheduler = null, bool completable = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable MergeMany(this System.IObservable> source, System.Func> observableSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable MergeMany(this System.IObservable> source, System.Func> observableSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer comparer) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer comparer) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, System.Collections.Generic.IComparer childComparer) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null, System.Collections.Generic.IComparer? comparer = null) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, System.Collections.Generic.IComparer childComparer) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null, System.Collections.Generic.IComparer? comparer = null) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, bool resortOnSourceRefresh, System.Collections.Generic.IComparer childComparer) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, System.Collections.Generic.IEqualityComparer? equalityComparer = null, System.Collections.Generic.IComparer? childComparer = null) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, bool resortOnSourceRefresh, System.Collections.Generic.IComparer childComparer) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, System.Collections.Generic.IEqualityComparer? equalityComparer = null, System.Collections.Generic.IComparer? childComparer = null) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, bool resortOnSourceRefresh, System.Collections.Generic.IEqualityComparer? equalityComparer = null, System.Collections.Generic.IComparer? childComparer = null) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyChangeSets(this System.IObservable> source, System.Func>> observableSelector, System.Collections.Generic.IComparer sourceComparer, bool resortOnSourceRefresh, System.Collections.Generic.IEqualityComparer? equalityComparer = null, System.Collections.Generic.IComparer? childComparer = null) + where TObject : notnull + where TKey : notnull + where TDestination : notnull + where TDestinationKey : notnull { } + public static System.IObservable> MergeManyItems(this System.IObservable> source, System.Func> observableSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> MergeManyItems(this System.IObservable> source, System.Func> observableSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable MonitorStatus(this System.IObservable source) { } + public static System.IObservable> NotEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> OnItemAdded(this System.IObservable> source, System.Action addAction) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> OnItemRefreshed(this System.IObservable> source, System.Action refreshAction) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> OnItemRemoved(this System.IObservable> source, System.Action removeAction, bool invokeOnUnsubscribe = true) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> OnItemUpdated(this System.IObservable> source, System.Action updateAction) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Or(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Or(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Or(this DynamicData.IObservableList>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Or(this System.Collections.Generic.ICollection>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Or(this System.IObservable> source, params System.IObservable>[] others) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Page(this System.IObservable> source, System.IObservable pageRequests) + where TObject : notnull + where TKey : notnull { } + public static System.IDisposable PopulateFrom(this DynamicData.ISourceCache source, System.IObservable> observable) + where TObject : notnull + where TKey : notnull { } + public static System.IDisposable PopulateFrom(this DynamicData.ISourceCache source, System.IObservable observable) + where TObject : notnull + where TKey : notnull { } + public static System.IDisposable PopulateInto(this System.IObservable> source, DynamicData.Cache.Internal.LockFreeObservableCache destination) + where TObject : notnull + where TKey : notnull { } + public static System.IDisposable PopulateInto(this System.IObservable> source, DynamicData.IIntermediateCache destination) + where TObject : notnull + where TKey : notnull { } + public static System.IDisposable PopulateInto(this System.IObservable> source, DynamicData.ISourceCache destination) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> QueryWhenChanged(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable QueryWhenChanged(this System.IObservable> source, System.Func, TDestination> resultSelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> QueryWhenChanged(this System.IObservable> source, System.Func> itemChangedTrigger) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> RefCount(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static void Refresh(this DynamicData.ISourceCache source) + where TObject : notnull + where TKey : notnull { } + public static void Refresh(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable items) + where TObject : notnull + where TKey : notnull { } + public static void Refresh(this DynamicData.ISourceCache source, TObject item) + where TObject : notnull + where TKey : notnull { } + public static void Remove(this DynamicData.IIntermediateCache source, System.Collections.Generic.IEnumerable keys) + where TObject : notnull + where TKey : notnull { } + public static void Remove(this DynamicData.IIntermediateCache source, TKey key) + where TObject : notnull + where TKey : notnull { } + public static void Remove(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable keys) + where TObject : notnull + where TKey : notnull { } + public static void Remove(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable items) + where TObject : notnull + where TKey : notnull { } + public static void Remove(this DynamicData.ISourceCache source, TKey key) + where TObject : notnull + where TKey : notnull { } + public static void Remove(this DynamicData.ISourceCache source, TObject item) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> RemoveKey(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static void RemoveKey(this DynamicData.ISourceCache source, TKey key) + where TObject : notnull + where TKey : notnull { } + public static void RemoveKeys(this DynamicData.ISourceCache source, System.Collections.Generic.IEnumerable keys) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> RightJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TRight, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> RightJoin(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, TRight, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> RightJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, DynamicData.IGrouping, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> RightJoinMany(this System.IObservable> left, System.IObservable> right, System.Func rightKeySelector, System.Func, DynamicData.IGrouping, TDestination> resultSelector) + where TLeft : notnull + where TLeftKey : notnull + where TRight : notnull + where TRightKey : notnull + where TDestination : notnull { } + public static System.IObservable> SkipInitial(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Sort(this System.IObservable> source, System.Collections.Generic.IComparer comparer, DynamicData.SortOptimisations sortOptimisations = 0, int resetThreshold = 100) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Sort(this System.IObservable> source, System.IObservable> comparerObservable, DynamicData.SortOptimisations sortOptimisations = 0, int resetThreshold = 100) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Sort(this System.IObservable> source, System.Collections.Generic.IComparer comparer, System.IObservable resorter, DynamicData.SortOptimisations sortOptimisations = 0, int resetThreshold = 100) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Sort(this System.IObservable> source, System.IObservable> comparerObservable, System.IObservable resorter, DynamicData.SortOptimisations sortOptimisations = 0, int resetThreshold = 100) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> SortBy(this System.IObservable> source, System.Func expression, DynamicData.Binding.SortDirection sortOrder = 0, DynamicData.SortOptimisations sortOptimisations = 0, int resetThreshold = 100) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where TObject : notnull + where TKey : notnull + where TGroupKey : notnull { } + public static System.IObservable> StartWithItem(this System.IObservable> source, TObject item) + where TObject : DynamicData.IKey + where TKey : notnull { } + public static System.IObservable> StartWithItem(this System.IObservable> source, TObject item, TKey key) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> SubscribeMany(this System.IObservable> source, System.Func subscriptionFactory) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> SubscribeMany(this System.IObservable> source, System.Func subscriptionFactory) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> SuppressRefresh(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Switch(this System.IObservable> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Switch(this System.IObservable>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToCollection(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable> source, System.Func keySelector, System.Func? expireAfter = null, int limitSizeTo = -1, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable source, System.Func keySelector, System.Func? expireAfter = null, int limitSizeTo = -1, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToObservableOptional(this System.IObservable> source, TKey key, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToObservableOptional(this System.IObservable> source, TKey key, bool initialOptionalWhenMissing, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToSortedCollection(this System.IObservable> source, System.Collections.Generic.IComparer comparer) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> ToSortedCollection(this System.IObservable> source, System.Func sort, DynamicData.Binding.SortDirection sortOrder = 0) + where TObject : notnull + where TKey : notnull + where TSortKey : notnull { } + public static System.IObservable> Top(this System.IObservable> source, int size) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Top(this System.IObservable> source, System.Collections.Generic.IComparer comparer, int size) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, bool transformOnRefresh) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, bool transformOnRefresh) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func, TKey, TDestination> transformFactory, bool transformOnRefresh) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func, TKey, TDestination> transformFactory, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func, TKey, TDestination> transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func> transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func> transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func, TKey, System.Threading.Tasks.Task> transformFactory, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Func keySelector) + where TDestination : notnull + where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Func keySelector) + where TDestination : notnull + where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Func keySelector) + where TDestination : notnull + where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Func keySelector) + where TDestination : notnull + where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func, TKey, TDestination> transformFactory, System.Action> errorHandler, System.IObservable forceTransform) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func, TKey, TDestination> transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafeAsync(this System.IObservable> source, System.Func> transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafeAsync(this System.IObservable> source, System.Func> transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafeAsync(this System.IObservable> source, System.Func, TKey, System.Threading.Tasks.Task> transformFactory, System.Action> errorHandler, System.IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable, TKey>> TransformToTree(this System.IObservable> source, System.Func pivotOn, System.IObservable, bool>>? predicateChanged = null) + where TObject : class + where TKey : notnull { } + public static System.IObservable> TransformWithInlineUpdate(this System.IObservable> source, System.Func transformFactory, System.Action updateAction) + where TDestination : class + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformWithInlineUpdate(this System.IObservable> source, System.Func transformFactory, System.Action updateAction, System.Action> errorHandler) + where TDestination : class + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TreatMovesAsRemoveAdd(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable TrueForAll(this System.IObservable> source, System.Func> observableSelector, System.Func equalityCondition) + where TObject : notnull + where TKey : notnull + where TValue : notnull { } + public static System.IObservable TrueForAll(this System.IObservable> source, System.Func> observableSelector, System.Func equalityCondition) + where TObject : notnull + where TKey : notnull + where TValue : notnull { } + public static System.IObservable TrueForAny(this System.IObservable> source, System.Func> observableSelector, System.Func equalityCondition) + where TObject : notnull + where TKey : notnull + where TValue : notnull { } + public static System.IObservable TrueForAny(this System.IObservable> source, System.Func> observableSelector, System.Func equalityCondition) + where TObject : notnull + where TKey : notnull + where TValue : notnull { } + public static System.IObservable> UpdateIndex(this System.IObservable> source) + where TObject : DynamicData.Binding.IIndexAware + where TKey : notnull { } + public static System.IObservable> Virtualise(this System.IObservable> source, System.IObservable virtualRequests) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Watch(this System.IObservable> source, TKey key) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable WatchValue(this DynamicData.IObservableCache source, TKey key) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable WatchValue(this System.IObservable> source, TKey key) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable WhenAnyPropertyChanged(this System.IObservable> source, params string[] propertiesToMonitor) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull { } + public static System.IObservable> WhenPropertyChanged(this System.IObservable> source, System.Linq.Expressions.Expression> propertyAccessor, bool notifyOnInitialValue = true) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull { } + public static System.IObservable WhenValueChanged(this System.IObservable> source, System.Linq.Expressions.Expression> propertyAccessor, bool notifyOnInitialValue = true) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TKey : notnull { } + public static System.IObservable> WhereReasonsAre(this System.IObservable> source, params DynamicData.ChangeReason[] reasons) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> WhereReasonsAreNot(this System.IObservable> source, params DynamicData.ChangeReason[] reasons) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Xor(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Xor(this DynamicData.IObservableList> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Xor(this DynamicData.IObservableList>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Xor(this System.Collections.Generic.ICollection>> sources) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Xor(this System.IObservable> source, params System.IObservable>[] others) + where TObject : notnull + where TKey : notnull { } + } + public static class ObservableChangeSet + { + public static System.IObservable> Create(System.Func, System.Action> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.IDisposable> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.Tasks.Task> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.Tasks.Task> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.Tasks.Task> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task> subscribe) + where T : notnull { } + public static System.IObservable> Create(System.Func, System.Action> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.IDisposable> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.Tasks.Task> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.Tasks.Task> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.Tasks.Task> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Create(System.Func, System.Threading.CancellationToken, System.Threading.Tasks.Task> subscribe, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + } + public static class ObservableListEx + { + public static System.IObservable> Adapt(this System.IObservable> source, DynamicData.IChangeSetAdaptor adaptor) + where T : notnull { } + public static System.IObservable> AddKey(this System.IObservable> source, System.Func keySelector) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> And(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> And(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> And(this DynamicData.IObservableList>> sources) + where T : notnull { } + public static System.IObservable> And(this System.Collections.Generic.ICollection>> sources) + where T : notnull { } + public static System.IObservable> And(this System.IObservable> source, params System.IObservable>[] others) + where T : notnull { } + public static DynamicData.IObservableList AsObservableList(this DynamicData.ISourceList source) + where T : notnull { } + public static DynamicData.IObservableList AsObservableList(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> AutoRefresh(this System.IObservable> source, System.TimeSpan? changeSetBuffer = default, System.TimeSpan? propertyChangeThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable> AutoRefresh(this System.IObservable> source, System.Linq.Expressions.Expression> propertyAccessor, System.TimeSpan? changeSetBuffer = default, System.TimeSpan? propertyChangeThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable> AutoRefreshOnObservable(this System.IObservable> source, System.Func> reevaluator, System.TimeSpan? changeSetBuffer = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, DynamicData.Binding.IObservableCollection targetCollection, int resetThreshold = 25) + where T : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, out System.Collections.ObjectModel.ReadOnlyObservableCollection readOnlyObservableCollection, int resetThreshold = 25) + where T : notnull { } + public static System.IObservable> Bind(this System.IObservable> source, System.ComponentModel.BindingList bindingList, int resetThreshold = 25) + where T : notnull { } + public static System.IObservable> BufferIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> BufferIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, bool initialPauseState, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> BufferIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, System.TimeSpan? timeOut, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> BufferIf(this System.IObservable> source, System.IObservable pauseIfTrueSelector, bool initialPauseState, System.TimeSpan? timeOut, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> BufferInitial(this System.IObservable> source, System.TimeSpan initialBuffer, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull { } + public static System.IObservable> Cast(this System.IObservable> source) + where TDestination : notnull { } + public static System.IObservable> Cast(this System.IObservable> source, System.Func conversionFactory) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> CastToObject(this System.IObservable> source) + where T : class { } + public static System.IObservable> Clone(this System.IObservable> source, System.Collections.Generic.IList target) + where T : notnull { } + [System.Obsolete("Prefer Cast as it is does the same thing but is semantically correct")] + public static System.IObservable> Convert(this System.IObservable> source, System.Func conversionFactory) + where TObject : notnull + where TDestination : notnull { } + public static System.IObservable> DeferUntilLoaded(this DynamicData.IObservableList source) + where T : notnull { } + public static System.IObservable> DeferUntilLoaded(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> DisposeMany(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> DistinctValues(this System.IObservable> source, System.Func valueSelector) + where TObject : notnull + where TValue : notnull { } + public static System.IObservable> Except(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> Except(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> Except(this DynamicData.IObservableList>> sources) + where T : notnull { } + public static System.IObservable> Except(this System.Collections.Generic.ICollection>> sources) + where T : notnull { } + public static System.IObservable> Except(this System.IObservable> source, params System.IObservable>[] others) + where T : notnull { } + public static System.IObservable> ExpireAfter(this DynamicData.ISourceList source, System.Func timeSelector, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ExpireAfter(this DynamicData.ISourceList source, System.Func timeSelector, System.TimeSpan? pollingInterval = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> Filter(this System.IObservable> source, System.Func predicate) + where T : notnull { } + public static System.IObservable> Filter(this System.IObservable> source, System.IObservable> predicate, DynamicData.ListFilterPolicy filterPolicy = 1) + where T : notnull { } + public static System.IObservable> FilterOnObservable(this System.IObservable> source, System.Func> objectFilterObservable, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull { } + [System.Obsolete("Use AutoRefresh(), followed by Filter() instead")] + public static System.IObservable> FilterOnProperty(this System.IObservable> source, System.Linq.Expressions.Expression> propertySelector, System.Func predicate, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable> FlattenBufferResult(this System.IObservable>> source) + where T : notnull { } + public static System.IObservable> ForEachChange(this System.IObservable> source, System.Action> action) + where TObject : notnull { } + public static System.IObservable> ForEachItemChange(this System.IObservable> source, System.Action> action) + where TObject : notnull { } + public static System.IObservable>> GroupOn(this System.IObservable> source, System.Func groupSelector, System.IObservable? regrouper = null) + where TObject : notnull + where TGroup : notnull { } + public static System.IObservable>> GroupOnProperty(this System.IObservable> source, System.Linq.Expressions.Expression> propertySelector, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TGroup : notnull { } + public static System.IObservable>> GroupOnPropertyWithImmutableState(this System.IObservable> source, System.Linq.Expressions.Expression> propertySelector, System.TimeSpan? propertyChangedThrottle = default, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : System.ComponentModel.INotifyPropertyChanged + where TGroup : notnull { } + public static System.IObservable>> GroupWithImmutableState(this System.IObservable> source, System.Func groupSelectorKey, System.IObservable? regrouper = null) + where TObject : notnull + where TGroupKey : notnull { } + public static System.IObservable> LimitSizeTo(this DynamicData.ISourceList source, int sizeLimit, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable MergeMany(this System.IObservable> source, System.Func> observableSelector) + where T : notnull { } + public static System.IObservable> NotEmpty(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> OnItemAdded(this System.IObservable> source, System.Action addAction) + where T : notnull { } + public static System.IObservable> OnItemRefreshed(this System.IObservable> source, System.Action refreshAction) + where TObject : notnull { } + public static System.IObservable> OnItemRemoved(this System.IObservable> source, System.Action removeAction, bool invokeOnUnsubscribe = true) + where T : notnull { } + public static System.IObservable> Or(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> Or(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> Or(this DynamicData.IObservableList>> sources) + where T : notnull { } + public static System.IObservable> Or(this System.Collections.Generic.ICollection>> sources) + where T : notnull { } + public static System.IObservable> Or(this System.IObservable> source, params System.IObservable>[] others) + where T : notnull { } + public static System.IObservable> Page(this System.IObservable> source, System.IObservable requests) + where T : notnull { } + public static System.IDisposable PopulateInto(this System.IObservable> source, DynamicData.ISourceList destination) + where T : notnull { } + public static System.IObservable> QueryWhenChanged(this System.IObservable> source) + where T : notnull { } + public static System.IObservable QueryWhenChanged(this System.IObservable> source, System.Func, TDestination> resultSelector) + where TObject : notnull { } + public static System.IObservable> RefCount(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> RemoveIndex(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> Reverse(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> SkipInitial(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> Sort(this System.IObservable> source, System.IObservable> comparerChanged, DynamicData.SortOptions options = 0, System.IObservable? resort = null, int resetThreshold = 50) + where T : notnull { } + public static System.IObservable> Sort(this System.IObservable> source, System.Collections.Generic.IComparer comparer, DynamicData.SortOptions options = 0, System.IObservable? resort = null, System.IObservable>? comparerChanged = null, int resetThreshold = 50) + where T : notnull { } + public static System.IObservable> StartWithEmpty(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> SubscribeMany(this System.IObservable> source, System.Func subscriptionFactory) + where T : notnull { } + public static System.IObservable> SuppressRefresh(this System.IObservable> source) + where T : notnull { } + public static System.IObservable> Switch(this System.IObservable> sources) + where T : notnull { } + public static System.IObservable> Switch(this System.IObservable>> sources) + where T : notnull { } + public static System.IObservable> ToCollection(this System.IObservable> source) + where TObject : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable> source, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable source, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable> source, System.Func expireAfter, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable> source, int limitSizeTo, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable source, System.Func expireAfter, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable source, int limitSizeTo, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable> source, System.Func? expireAfter, int limitSizeTo, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToObservableChangeSet(this System.IObservable source, System.Func? expireAfter, int limitSizeTo, System.Reactive.Concurrency.IScheduler? scheduler = null) + where T : notnull { } + public static System.IObservable> ToSortedCollection(this System.IObservable> source, System.Collections.Generic.IComparer comparer) + where TObject : notnull { } + public static System.IObservable> ToSortedCollection(this System.IObservable> source, System.Func sort, DynamicData.Binding.SortDirection sortOrder = 0) + where TObject : notnull { } + public static System.IObservable> Top(this System.IObservable> source, int numberOfItems) + where T : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func, TDestination> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func, int, TDestination> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func, System.Threading.Tasks.Task> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> TransformAsync(this System.IObservable> source, System.Func, int, System.Threading.Tasks.Task> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TDestination : notnull + where TSource : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TDestination : notnull + where TSource : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TDestination : notnull + where TSource : notnull { } + public static System.IObservable> TransformMany(this System.IObservable> source, System.Func> manySelector, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where TDestination : notnull + where TSource : notnull { } + public static System.IObservable> Virtualise(this System.IObservable> source, System.IObservable requests) + where T : notnull { } + public static System.IObservable WhenAnyPropertyChanged(this System.IObservable> source, params string[] propertiesToMonitor) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable> WhenPropertyChanged(this System.IObservable> source, System.Linq.Expressions.Expression> propertyAccessor, bool notifyOnInitialValue = true) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable WhenValueChanged(this System.IObservable> source, System.Linq.Expressions.Expression> propertyAccessor, bool notifyOnInitialValue = true) + where TObject : System.ComponentModel.INotifyPropertyChanged { } + public static System.IObservable> WhereReasonsAre(this System.IObservable> source, params DynamicData.ListChangeReason[] reasons) + where T : notnull { } + public static System.IObservable> WhereReasonsAreNot(this System.IObservable> source, params DynamicData.ListChangeReason[] reasons) + where T : notnull { } + public static System.IObservable> Xor(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> Xor(this DynamicData.IObservableList> sources) + where T : notnull { } + public static System.IObservable> Xor(this DynamicData.IObservableList>> sources) + where T : notnull { } + public static System.IObservable> Xor(this System.Collections.Generic.ICollection>> sources) + where T : notnull { } + public static System.IObservable> Xor(this System.IObservable> source, params System.IObservable>[] others) + where T : notnull { } + } + public static class ObsoleteEx { } + public sealed class PageRequest : DynamicData.IPageRequest, System.IEquatable + { + public static readonly DynamicData.IPageRequest Default; + public static readonly DynamicData.IPageRequest Empty; + public PageRequest() { } + public PageRequest(int page, int size) { } + public System.Collections.Generic.IEqualityComparer DefaultComparer { get; } + public int Page { get; } + public int Size { get; } + public bool Equals(DynamicData.IPageRequest? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + } + public sealed class RangeChange : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + public RangeChange(System.Collections.Generic.IEnumerable items, int index = -1) { } + public int Count { get; } + public int Index { get; } + public static DynamicData.RangeChange Empty { get; } + public void Add(T item) { } + public System.Collections.Generic.IEnumerator GetEnumerator() { } + public void Insert(int index, T item) { } + public void SetStartingIndex(int index) { } + public override string ToString() { } + } + [System.Serializable] + public class SortException : System.Exception + { + public SortException() { } + public SortException(string message) { } + public SortException(string message, System.Exception innerException) { } + } + [System.Flags] + public enum SortOptimisations + { + None = 0, + ComparesImmutableValuesOnly = 1, + IgnoreEvaluates = 2, + [System.Obsolete("This is no longer being used. Use one of the other options instead.")] + InsertAtEndThenSort = 3, + } + public enum SortOptions + { + None = 0, + UseBinarySearch = 1, + } + public enum SortReason + { + InitialLoad = 0, + ComparerChanged = 1, + DataChanged = 2, + Reorder = 3, + Reset = 4, + } + public static class SourceCacheEx + { + public static System.IObservable> Cast(this DynamicData.IObservableCache source, System.Func converter) + where TSource : notnull + where TKey : notnull + where TDestination : notnull { } + } + [System.Diagnostics.DebuggerDisplay("SourceCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Items)")] + public sealed class SourceCache : DynamicData.IConnectableCache, DynamicData.IObservableCache, DynamicData.ISourceCache, System.IDisposable + where TObject : notnull + where TKey : notnull + { + public SourceCache(System.Func keySelector) { } + public int Count { get; } + public System.IObservable CountChanged { get; } + public System.Collections.Generic.IEnumerable Items { get; } + public System.Func KeySelector { get; } + public System.Collections.Generic.IEnumerable> KeyValues { get; } + public System.Collections.Generic.IEnumerable Keys { get; } + public System.IObservable> Connect(System.Func? predicate = null, bool suppressEmptyChangeSets = true) { } + public void Dispose() { } + public void Edit(System.Action> updateAction) { } + public DynamicData.Kernel.Optional Lookup(TKey key) { } + public System.IObservable> Preview(System.Func? predicate = null) { } + public System.IObservable> Watch(TKey key) { } + } + public static class SourceListEditConvenienceEx + { + public static void Add(this DynamicData.ISourceList source, T item) + where T : notnull { } + public static void AddRange(this DynamicData.ISourceList source, System.Collections.Generic.IEnumerable items) + where T : notnull { } + public static void Clear(this DynamicData.ISourceList source) + where T : notnull { } + public static void EditDiff(this DynamicData.ISourceList source, System.Collections.Generic.IEnumerable allItems, System.Collections.Generic.IEqualityComparer? equalityComparer = null) + where T : notnull { } + public static void Insert(this DynamicData.ISourceList source, int index, T item) + where T : notnull { } + public static void InsertRange(this DynamicData.ISourceList source, System.Collections.Generic.IEnumerable items, int index) + where T : notnull { } + public static void Move(this DynamicData.ISourceList source, int original, int destination) + where T : notnull { } + public static bool Remove(this DynamicData.ISourceList source, T item) + where T : notnull { } + public static void RemoveAt(this DynamicData.ISourceList source, int index) + where T : notnull { } + public static void RemoveMany(this DynamicData.ISourceList source, System.Collections.Generic.IEnumerable itemsToRemove) + where T : notnull { } + public static void RemoveRange(this DynamicData.ISourceList source, int index, int count) + where T : notnull { } + public static void Replace(this DynamicData.ISourceList source, T original, T destination) + where T : notnull { } + public static void ReplaceAt(this DynamicData.ISourceList source, int index, T item) + where T : notnull { } + } + public static class SourceListEx + { + public static System.IObservable> Cast(this DynamicData.ISourceList source, System.Func conversionFactory) + where TSource : notnull + where TDestination : notnull { } + } + [System.Diagnostics.DebuggerDisplay("SourceList<{typeof(T).Name}> ({Count} Items)")] + public sealed class SourceList : DynamicData.IObservableList, DynamicData.ISourceList, System.IDisposable + where T : notnull + { + public SourceList(System.IObservable>? source = null) { } + public int Count { get; } + public System.IObservable CountChanged { get; } + public System.Collections.Generic.IEnumerable Items { get; } + public System.IObservable> Connect(System.Func? predicate = null) { } + public void Dispose() { } + public void Edit(System.Action> updateAction) { } + public System.IObservable> Preview(System.Func? predicate = null) { } + } + [System.Serializable] + public class UnspecifiedIndexException : System.Exception + { + public UnspecifiedIndexException() { } + public UnspecifiedIndexException(string message) { } + public UnspecifiedIndexException(string message, System.Exception innerException) { } + } + public class VirtualRequest : DynamicData.IVirtualRequest, System.IEquatable + { + public static readonly DynamicData.VirtualRequest Default; + public VirtualRequest() { } + public VirtualRequest(int startIndex, int size) { } + public int Size { get; } + public int StartIndex { get; } + public static System.Collections.Generic.IEqualityComparer StartIndexSizeComparer { get; } + public bool Equals(DynamicData.IVirtualRequest? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + } +} +namespace DynamicData.Diagnostics +{ + public class ChangeStatistics : System.IEquatable + { + public ChangeStatistics() { } + public ChangeStatistics(int index, int adds, int updates, int removes, int refreshes, int moves, int count) { } + public int Adds { get; } + public int Count { get; } + public int Index { get; } + public System.DateTime LastUpdated { get; } + public int Moves { get; } + public int Refreshes { get; } + public int Removes { get; } + public int Updates { get; } + public bool Equals(DynamicData.Diagnostics.ChangeStatistics? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Diagnostics.ChangeStatistics left, DynamicData.Diagnostics.ChangeStatistics right) { } + public static bool operator ==(DynamicData.Diagnostics.ChangeStatistics left, DynamicData.Diagnostics.ChangeStatistics right) { } + } + public class ChangeSummary + { + public static readonly DynamicData.Diagnostics.ChangeSummary Empty; + public ChangeSummary(int index, DynamicData.Diagnostics.ChangeStatistics latest, DynamicData.Diagnostics.ChangeStatistics overall) { } + public DynamicData.Diagnostics.ChangeStatistics Latest { get; } + public DynamicData.Diagnostics.ChangeStatistics Overall { get; } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + } + public static class DiagnosticOperators + { + public static System.IObservable CollectUpdateStats(this System.IObservable> source) + where TSource : notnull { } + public static System.IObservable CollectUpdateStats(this System.IObservable> source) + where TSource : notnull + where TKey : notnull { } + } +} +namespace DynamicData.Experimental +{ + public static class ExperimentalEx + { + public static DynamicData.Experimental.IWatcher AsWatcher(this System.IObservable> source, System.Reactive.Concurrency.IScheduler? scheduler = null) + where TObject : notnull + where TKey : notnull { } + } + public interface IWatcher : System.IDisposable + where TObject : notnull + where TKey : notnull + { + System.IObservable> Watch(TKey key); + } +} +namespace DynamicData.Kernel +{ + public enum ConnectionStatus + { + Pending = 0, + Loaded = 1, + Errored = 2, + Completed = 3, + } + public static class EnumerableEx + { + public static T[] AsArray(this System.Collections.Generic.IEnumerable source) { } + public static System.Collections.Generic.List AsList(this System.Collections.Generic.IEnumerable source) { } + public static System.Collections.Generic.IEnumerable Duplicates(this System.Collections.Generic.IEnumerable source, System.Func valueSelector) { } + public static System.Collections.Generic.IEnumerable> IndexOfMany(this System.Collections.Generic.IEnumerable source, System.Collections.Generic.IEnumerable itemsToFind) { } + public static System.Collections.Generic.IEnumerable IndexOfMany(this System.Collections.Generic.IEnumerable source, System.Collections.Generic.IEnumerable itemsToFind, System.Func resultSelector) { } + } + public sealed class Error : DynamicData.IKeyValue, DynamicData.IKey, System.IEquatable> + where TKey : notnull + { + public Error(System.Exception? exception, TObject value, TKey key) { } + public System.Exception? Exception { get; } + public TKey Key { get; } + public TObject Value { get; } + public bool Equals(DynamicData.Kernel.Error? other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Kernel.Error left, DynamicData.Kernel.Error right) { } + public static bool operator ==(DynamicData.Kernel.Error left, DynamicData.Kernel.Error right) { } + } + public static class InternalEx + { + public static System.IObservable RetryWithBackOff(this System.IObservable source, System.Func backOffStrategy) + where TException : System.Exception { } + public static System.IDisposable ScheduleRecurringAction(this System.Reactive.Concurrency.IScheduler scheduler, System.Func interval, System.Action action) { } + public static System.IDisposable ScheduleRecurringAction(this System.Reactive.Concurrency.IScheduler scheduler, System.TimeSpan interval, System.Action action) { } + } + public readonly struct ItemWithIndex : System.IEquatable> + { + public ItemWithIndex(T item, int index) { } + public int Index { get; } + public T Item { get; } + public bool Equals(DynamicData.Kernel.ItemWithIndex other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Kernel.ItemWithIndex left, DynamicData.Kernel.ItemWithIndex right) { } + public static bool operator ==(DynamicData.Kernel.ItemWithIndex left, DynamicData.Kernel.ItemWithIndex right) { } + } + public readonly struct ItemWithValue : System.IEquatable> + { + public ItemWithValue(TObject item, TValue value) { } + public TObject Item { get; } + public TValue Value { get; } + public bool Equals(DynamicData.Kernel.ItemWithValue other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string ToString() { } + public static bool operator !=(DynamicData.Kernel.ItemWithValue left, DynamicData.Kernel.ItemWithValue right) { } + public static bool operator ==(DynamicData.Kernel.ItemWithValue left, DynamicData.Kernel.ItemWithValue right) { } + } + public sealed class OptionElse + { + public void Else(System.Action action) { } + } + public static class OptionExtensions + { + public static DynamicData.Kernel.Optional Convert(this DynamicData.Kernel.Optional source, System.Func> converter) + where TSource : notnull + where TDestination : notnull { } + public static DynamicData.Kernel.Optional Convert(this DynamicData.Kernel.Optional source, System.Func converter) + where TSource : notnull + where TDestination : notnull { } + public static TDestination? ConvertOr(this DynamicData.Kernel.Optional source, System.Func converter, System.Func fallbackConverter) + where TSource : notnull { } + public static DynamicData.Kernel.Optional FirstOrOptional(this System.Collections.Generic.IEnumerable source, System.Func selector) + where T : notnull { } + public static DynamicData.Kernel.OptionElse IfHasValue(this DynamicData.Kernel.Optional source, System.Action action) + where T : notnull { } + public static DynamicData.Kernel.OptionElse IfHasValue(this DynamicData.Kernel.Optional? source, System.Action action) + where T : notnull { } + public static DynamicData.Kernel.Optional Lookup(this System.Collections.Generic.IDictionary source, TKey key) + where TValue : notnull { } + public static DynamicData.Kernel.Optional OrElse(this DynamicData.Kernel.Optional source, System.Func> fallbackOperation) + where T : notnull { } + public static bool RemoveIfContained(this System.Collections.Generic.IDictionary source, TKey key) { } + public static System.Collections.Generic.IEnumerable SelectValues(this System.Collections.Generic.IEnumerable> source) + where T : notnull { } + public static T ValueOr(this DynamicData.Kernel.Optional source, System.Func valueSelector) + where T : notnull { } + public static T ValueOr(this T? source, T defaultValue) + where T : struct { } + public static T? ValueOrDefault(this DynamicData.Kernel.Optional source) + where T : notnull { } + public static T ValueOrThrow(this DynamicData.Kernel.Optional source, System.Func exceptionGenerator) + where T : notnull { } + } + public static class OptionObservableExtensions + { + public static System.IObservable> Convert(this System.IObservable> source, System.Func> converter) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable> Convert(this System.IObservable> source, System.Func converter) + where TSource : notnull + where TDestination : notnull { } + public static System.IObservable ConvertOr(this System.IObservable> source, System.Func converter, System.Func fallbackConverter) + where TSource : notnull { } + public static System.IObservable> OnHasNoValue(this System.IObservable> source, System.Action action, System.Action? elseAction = null) + where T : notnull { } + public static System.IObservable> OnHasValue(this System.IObservable> source, System.Action action, System.Action? elseAction = null) + where T : notnull { } + public static System.IObservable> OrElse(this System.IObservable> source, System.Func> fallbackOperation) + where T : notnull { } + public static System.IObservable SelectValues(this System.IObservable> source) + where T : notnull { } + public static System.IObservable ValueOr(this System.IObservable> source, System.Func valueSelector) + where T : notnull { } + public static System.IObservable ValueOrDefault(this System.IObservable> source) + where T : notnull { } + public static System.IObservable ValueOrThrow(this System.IObservable> source, System.Func exceptionGenerator) + where T : notnull { } + } + public static class Optional + { + public static DynamicData.Kernel.Optional None() + where T : notnull { } + public static DynamicData.Kernel.Optional Some(T? value) + where T : notnull { } + } + public readonly struct Optional : System.IEquatable> + where T : notnull + { + public bool HasValue { get; } + public T Value { get; } + public static DynamicData.Kernel.Optional None { get; } + public bool Equals(DynamicData.Kernel.Optional other) { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public override string? ToString() { } + public static DynamicData.Kernel.Optional Create(T? value) { } + public static T? FromOptional(DynamicData.Kernel.Optional value) { } + public static DynamicData.Kernel.Optional ToOptional(T? value) { } + public static T? op_Explicit(DynamicData.Kernel.Optional value) { } + public static DynamicData.Kernel.Optional op_Implicit(T? value) { } + public static bool operator !=(DynamicData.Kernel.Optional left, DynamicData.Kernel.Optional right) { } + public static bool operator ==(DynamicData.Kernel.Optional left, DynamicData.Kernel.Optional right) { } + } +} +namespace DynamicData.List +{ + public interface IGrouping + { + int Count { get; } + System.Collections.Generic.IEnumerable Items { get; } + TGroupKey Key { get; } + } +} +namespace DynamicData.Operators +{ + public interface IPageResponse + { + int Page { get; } + int PageSize { get; } + int Pages { get; } + int TotalSize { get; } + } +} +namespace DynamicData.PLinq +{ + public static class ParallelOperators + { + public static System.IObservable> Filter(this System.IObservable> source, System.Func filter, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> SubscribeMany(this System.IObservable> source, System.Func subscriptionFactory, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> SubscribeMany(this System.IObservable> source, System.Func subscriptionFactory, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TObject : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> Transform(this System.IObservable> source, System.Func transformFactory, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + public static System.IObservable> TransformSafe(this System.IObservable> source, System.Func transformFactory, System.Action> errorHandler, DynamicData.PLinq.ParallelisationOptions parallelisationOptions) + where TDestination : notnull + where TSource : notnull + where TKey : notnull { } + } + public enum ParallelType + { + None = 0, + Parallelise = 1, + Ordered = 2, + } + public class ParallelisationOptions + { + public static readonly DynamicData.PLinq.ParallelisationOptions Default; + public static readonly DynamicData.PLinq.ParallelisationOptions None; + public ParallelisationOptions(DynamicData.PLinq.ParallelType type = 0, int threshold = 0, int maxDegreeOfParallelisation = 0) { } + public int MaxDegreeOfParallelisation { get; } + public int Threshold { get; } + public DynamicData.PLinq.ParallelType Type { get; } + } +} +namespace DynamicData.Tests +{ + public class ChangeSetAggregator : System.IDisposable + where TObject : notnull + { + public ChangeSetAggregator(System.IObservable> source) { } + public DynamicData.IObservableList Data { get; } + public System.Exception? Exception { get; set; } + public System.Collections.Generic.IList> Messages { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } + public class ChangeSetAggregator : System.IDisposable + where TObject : notnull + where TKey : notnull + { + public ChangeSetAggregator(System.IObservable> source) { } + public bool Completed { get; } + public DynamicData.IObservableCache Data { get; } + public System.Exception? Error { get; } + public System.Collections.Generic.IList> Messages { get; } + public DynamicData.Diagnostics.ChangeSummary Summary { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } + public class DistinctChangeSetAggregator : System.IDisposable + where TValue : notnull + { + public DistinctChangeSetAggregator(System.IObservable> source) { } + public DynamicData.IObservableCache Data { get; } + public System.Exception? Error { get; } + public System.Collections.Generic.IList> Messages { get; } + public DynamicData.Diagnostics.ChangeSummary Summary { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } + public static class ListTextEx + { + public static DynamicData.Tests.ChangeSetAggregator AsAggregator(this System.IObservable> source) + where T : notnull { } + } + public class PagedChangeSetAggregator : System.IDisposable + where TObject : notnull + where TKey : notnull + { + public PagedChangeSetAggregator(System.IObservable> source) { } + public DynamicData.IObservableCache Data { get; } + public System.Exception? Error { get; } + public System.Collections.Generic.IList> Messages { get; } + public DynamicData.Diagnostics.ChangeSummary Summary { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } + public class SortedChangeSetAggregator : System.IDisposable + where TObject : notnull + where TKey : notnull + { + public SortedChangeSetAggregator(System.IObservable> source) { } + public DynamicData.IObservableCache Data { get; } + public System.Exception? Error { get; } + public System.Collections.Generic.IList> Messages { get; } + public DynamicData.Diagnostics.ChangeSummary Summary { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } + public static class TestEx + { + public static DynamicData.Tests.DistinctChangeSetAggregator AsAggregator(this System.IObservable> source) + where TValue : notnull { } + public static DynamicData.Tests.ChangeSetAggregator AsAggregator(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static DynamicData.Tests.PagedChangeSetAggregator AsAggregator(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static DynamicData.Tests.SortedChangeSetAggregator AsAggregator(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + public static DynamicData.Tests.VirtualChangeSetAggregator AsAggregator(this System.IObservable> source) + where TObject : notnull + where TKey : notnull { } + } + public class VirtualChangeSetAggregator : System.IDisposable + where TObject : notnull + where TKey : notnull + { + public VirtualChangeSetAggregator(System.IObservable> source) { } + public DynamicData.IObservableCache Data { get; } + public System.Exception? Error { get; } + public System.Collections.Generic.IList> Messages { get; } + public DynamicData.Diagnostics.ChangeSummary Summary { get; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } +} \ No newline at end of file diff --git a/src/DynamicData.Tests/AggregationTests/AverageFixture.cs b/src/DynamicData.Tests/AggregationTests/AverageFixture.cs index 11529f268..74fb16b87 100644 --- a/src/DynamicData.Tests/AggregationTests/AverageFixture.cs +++ b/src/DynamicData.Tests/AggregationTests/AverageFixture.cs @@ -34,6 +34,150 @@ public void AddedItemsContributeToSum() accumulator.Dispose(); } + [Fact] + public void AddedItemsContributeToSumLong() + { + double avg = 0; + + var accumulator = _source.Connect().Avg(p => Convert.ToInt64(p.Age)).Subscribe(x => avg = x); + + _source.AddOrUpdate(new Person("A", 10)); + _source.AddOrUpdate(new Person("B", 20)); + _source.AddOrUpdate(new Person("C", 30)); + + avg.Should().Be(20, "Average value should be 20"); + + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumFloat() + { + double avg = 0; + + var accumulator = _source.Connect().Avg(p => Convert.ToSingle(p.Age)).Subscribe(x => avg = x); + + _source.AddOrUpdate(new Person("A", 10)); + _source.AddOrUpdate(new Person("B", 20)); + _source.AddOrUpdate(new Person("C", 30)); + + avg.Should().Be(20, "Average value should be 20"); + + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumDouble() + { + double avg = 0; + + var accumulator = _source.Connect().Avg(p => Convert.ToDouble(p.Age)).Subscribe(x => avg = x); + + _source.AddOrUpdate(new Person("A", 10)); + _source.AddOrUpdate(new Person("B", 20)); + _source.AddOrUpdate(new Person("C", 30)); + + avg.Should().Be(20, "Average value should be 20"); + + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumDecimal() + { + decimal avg = 0; + + var accumulator = _source.Connect().Avg(p => Convert.ToDecimal(p.Age)).Subscribe(x => avg = x); + + _source.AddOrUpdate(new Person("A", 10)); + _source.AddOrUpdate(new Person("B", 20)); + _source.AddOrUpdate(new Person("C", 30)); + + avg.Should().Be(20, "Average value should be 20"); + + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumNullable() + { + double avg = 0; + + var accumulator = _source.Connect().Avg(p => p.AgeNullable).Subscribe(x => avg = x); + + _source.AddOrUpdate(new Person("A", new int?(10), "F", null)); + _source.AddOrUpdate(new Person("B", new int?(20), "F", null)); + _source.AddOrUpdate(new Person("C", new int?(30), "F", null)); + + avg.Should().Be(20, "Average value should be 20"); + + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumNullableLong() + { + double avg = 0; + + var accumulator = _source.Connect().Avg(p => (long?)(p.AgeNullable.HasValue ? Convert.ToInt64(p.AgeNullable) : default)).Subscribe(x => avg = x); + + _source.AddOrUpdate(new Person("A", new int?(10), "F", null)); + _source.AddOrUpdate(new Person("B", new int?(20), "F", null)); + _source.AddOrUpdate(new Person("C", new int?(30), "F", null)); + + avg.Should().Be(20, "Average value should be 20"); + + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumNullableFloat() + { + double avg = 0; + + var accumulator = _source.Connect().Avg(p => (float?)(p.AgeNullable.HasValue ? Convert.ToSingle(p.AgeNullable) : default)).Subscribe(x => avg = x); + + _source.AddOrUpdate(new Person("A", new int?(10), "F", null)); + _source.AddOrUpdate(new Person("B", new int?(20), "F", null)); + _source.AddOrUpdate(new Person("C", new int?(30), "F", null)); + + avg.Should().Be(20, "Average value should be 20"); + + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumNullableDouble() + { + double avg = 0; + + var accumulator = _source.Connect().Avg(p => (double?)(p.AgeNullable.HasValue ? Convert.ToDouble(p.AgeNullable) : default)).Subscribe(x => avg = x); + + _source.AddOrUpdate(new Person("A", new int?(10), "F", null)); + _source.AddOrUpdate(new Person("B", new int?(20), "F", null)); + _source.AddOrUpdate(new Person("C", new int?(30), "F", null)); + + avg.Should().Be(20, "Average value should be 20"); + + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumNullableDecimal() + { + decimal avg = 0; + + var accumulator = _source.Connect().Avg(p => (decimal?)(p.AgeNullable.HasValue ? Convert.ToDecimal(p.AgeNullable) : default)).Subscribe(x => avg = x); + + _source.AddOrUpdate(new Person("A", new int?(10), "F", null)); + _source.AddOrUpdate(new Person("B", new int?(20), "F", null)); + _source.AddOrUpdate(new Person("C", new int?(30), "F", null)); + + avg.Should().Be(20, "Average value should be 20"); + + accumulator.Dispose(); + } + public void Dispose() { _source.Dispose(); diff --git a/src/DynamicData.Tests/AggregationTests/SumFixture.cs b/src/DynamicData.Tests/AggregationTests/SumFixture.cs index fc647d5ae..0845b2c58 100644 --- a/src/DynamicData.Tests/AggregationTests/SumFixture.cs +++ b/src/DynamicData.Tests/AggregationTests/SumFixture.cs @@ -22,13 +22,167 @@ public SumFixture() public void AddedItemsContributeToSum() { var sum = 0; + double dev = 0; var accumulator = _source.Connect().Sum(p => p.Age).Subscribe(x => sum = x); + var deviation = _source.Connect().StdDev(p => p.Age, (int)0).Subscribe(x => dev = x); _source.AddOrUpdate(new Person("A", 10)); _source.AddOrUpdate(new Person("B", 20)); _source.AddOrUpdate(new Person("C", 30)); + sum.Should().Be(60, "Accumulated value should be 60"); + dev.Should().Be(7.0710678118654755, ""); + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumLong() + { + long sum = 0; + double dev = 0; + + var accumulator = _source.Connect().Sum(p => Convert.ToInt64(p.Age)).Subscribe(x => sum = x); + var deviation = _source.Connect().StdDev(p => p.Age, (long)0).Subscribe(x => dev = x); + + _source.AddOrUpdate(new Person("A", 10)); + _source.AddOrUpdate(new Person("B", 20)); + _source.AddOrUpdate(new Person("C", 30)); + + sum.Should().Be(60, "Accumulated value should be 60"); + dev.Should().Be(7.0710678118654755, ""); + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumFloat() + { + float sum = 0; + double dev = 0; + + var accumulator = _source.Connect().Sum(p => Convert.ToSingle(p.Age)).Subscribe(x => sum = x); + var deviation = _source.Connect().StdDev(p => p.Age, (float)0).Subscribe(x => dev = x); + + _source.AddOrUpdate(new Person("A", 10)); + _source.AddOrUpdate(new Person("B", 20)); + _source.AddOrUpdate(new Person("C", 30)); + + sum.Should().Be(60, "Accumulated value should be 60"); + dev.Should().Be(7.0710678118654755, ""); + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumDouble() + { + double sum = 0; + double dev = 0; + + var accumulator = _source.Connect().Sum(p => Convert.ToDouble(p.Age)).Subscribe(x => sum = x); + var deviation = _source.Connect().StdDev(p => p.Age, (double)0).Subscribe(x => dev = x); + + _source.AddOrUpdate(new Person("A", 10)); + _source.AddOrUpdate(new Person("B", 20)); + _source.AddOrUpdate(new Person("C", 30)); + + sum.Should().Be(60, "Accumulated value should be 60"); + dev.Should().Be(7.0710678118654755, ""); + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumDecimal() + { + decimal sum = 0; + decimal dev = 0; + + var accumulator = _source.Connect().Sum(p => Convert.ToDecimal(p.Age)).Subscribe(x => sum = x); + var deviation = _source.Connect().StdDev(p => p.Age, (decimal)0).Subscribe(x => dev = x); + + _source.AddOrUpdate(new Person("A", 10)); + _source.AddOrUpdate(new Person("B", 20)); + _source.AddOrUpdate(new Person("C", 30)); + + sum.Should().Be(60, "Accumulated value should be 60"); + dev.Should().Be(7.0710678118654752440084436210M, ""); + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumNullable() + { + var sum = 0; + + var accumulator = _source.Connect().Sum(p => p.AgeNullable).Subscribe(x => sum = x); + + _source.AddOrUpdate(new Person("A", new int?(10), "F", null)); + _source.AddOrUpdate(new Person("B", new int?(20), "F", null)); + _source.AddOrUpdate(new Person("C", new int?(30), "F", null)); + + sum.Should().Be(60, "Accumulated value should be 60"); + + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumLongNullable() + { + long sum = 0; + + var accumulator = _source.Connect().Sum(p => (long?)(p.AgeNullable.HasValue ? Convert.ToInt64(p.AgeNullable) : default)).Subscribe(x => sum = x); + + _source.AddOrUpdate(new Person("A", new int?(10), "F", null)); + _source.AddOrUpdate(new Person("B", new int?(20), "F", null)); + _source.AddOrUpdate(new Person("C", new int?(30), "F", null)); + + sum.Should().Be(60, "Accumulated value should be 60"); + + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumFloatNullable() + { + float sum = 0; + + var accumulator = _source.Connect().Sum(p => (float?)(p.AgeNullable.HasValue ? Convert.ToSingle(p.AgeNullable) : default)).Subscribe(x => sum = x); + + _source.AddOrUpdate(new Person("A", new int?(10), "F", null)); + _source.AddOrUpdate(new Person("B", new int?(20), "F", null)); + _source.AddOrUpdate(new Person("C", new int?(30), "F", null)); + + sum.Should().Be(60, "Accumulated value should be 60"); + + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumDoubleNullable() + { + double sum = 0; + + var accumulator = _source.Connect().Sum(p => (double?)(p.AgeNullable.HasValue ? Convert.ToDouble(p.AgeNullable) : default)).Subscribe(x => sum = x); + + _source.AddOrUpdate(new Person("A", new int?(10), "F", null)); + _source.AddOrUpdate(new Person("B", new int?(20), "F", null)); + _source.AddOrUpdate(new Person("C", new int?(30), "F", null)); + + sum.Should().Be(60, "Accumulated value should be 60"); + + accumulator.Dispose(); + } + + [Fact] + public void AddedItemsContributeToSumDecimalNullable() + { + decimal sum = 0; + + var accumulator = _source.Connect().Sum(p => (decimal?)(p.AgeNullable.HasValue ? Convert.ToDecimal(p.AgeNullable) : default)).Subscribe(x => sum = x); + + _source.AddOrUpdate(new Person("A", new int?(10), "F", null)); + _source.AddOrUpdate(new Person("B", new int?(20), "F", null)); + _source.AddOrUpdate(new Person("C", new int?(30), "F", null)); + sum.Should().Be(60, "Accumulated value should be 60"); accumulator.Dispose(); diff --git a/src/DynamicData.Tests/Domain/Person.cs b/src/DynamicData.Tests/Domain/Person.cs index eaaf240ea..bcc516a53 100644 --- a/src/DynamicData.Tests/Domain/Person.cs +++ b/src/DynamicData.Tests/Domain/Person.cs @@ -8,6 +8,7 @@ namespace DynamicData.Tests.Domain; public class Person : AbstractNotifyPropertyChanged, IEquatable { private int _age; + private int? _ageNullable; public Person() : this("unknown", 0, "none") @@ -27,6 +28,14 @@ public Person(string name, int age, string gender = "F", string? parentName = nu ParentName = parentName ?? string.Empty; } + public Person(string name, int? age, string gender = "F", string? parentName = null) + { + Name = name; + _ageNullable = age; + Gender = gender; + ParentName = parentName ?? string.Empty; + } + public static IEqualityComparer AgeComparer { get; } = new AgeEqualityComparer(); public static IEqualityComparer NameAgeGenderComparer { get; } = new NameAgeGenderEqualityComparer(); @@ -37,6 +46,12 @@ public int Age set => SetAndRaise(ref _age, value); } + public int? AgeNullable + { + get => _ageNullable; + set => SetAndRaise(ref _ageNullable, value); + } + public string Gender { get; } public string Key => Name; diff --git a/src/DynamicData.Tests/DynamicData.Tests.csproj b/src/DynamicData.Tests/DynamicData.Tests.csproj index 927b377e7..e49691d57 100644 --- a/src/DynamicData.Tests/DynamicData.Tests.csproj +++ b/src/DynamicData.Tests/DynamicData.Tests.csproj @@ -1,9 +1,10 @@  - net6.0 + net6.0;net7.0;net8.0 $(NoWarn);CS0618;CA1801;CA1063;CS8767;CS8602; CS8618 enable latest + 2.6.1 @@ -12,10 +13,10 @@ - - + + - + diff --git a/src/DynamicData.Tests/EnumerableIListFixture.cs b/src/DynamicData.Tests/EnumerableIListFixture.cs new file mode 100644 index 000000000..8ff7ae6b0 --- /dev/null +++ b/src/DynamicData.Tests/EnumerableIListFixture.cs @@ -0,0 +1,70 @@ +using System; +using DynamicData.Cache.Internal; +using System.Collections.Generic; +using System.Reactive.Concurrency; +using System.Reactive.Linq; +using System.Reactive.Subjects; +using System.Security.Cryptography; +using DynamicData.Kernel; +using Xunit; + +namespace DynamicData.Tests +{ + public class EnumerableIListFixture + { + [Fact] + public void EnumerableIListTests() + { + var data = new byte[40]; + using (var generator = RandomNumberGenerator.Create()) + { + generator.GetBytes(data); + } + + var inputData = new byte[39]; + var lastItem = data[data.Length - 1]; + var firstItem = data[0]; + Array.Copy(data, 1, inputData, 0, 38); + var listOfRandomFloats = new List(inputData); + var fixture = EnumerableIList.Create(listOfRandomFloats); + fixture.Add(lastItem); + fixture.Insert(0, firstItem); + + Assert.Equal(fixture.Count, listOfRandomFloats.Count); + + Assert.True(fixture.IndexOf(lastItem) > 0); + + fixture.Remove(lastItem); + + Assert.Equal(fixture.Count, listOfRandomFloats.Count); + + fixture.RemoveAt(0); + + Assert.Equal(fixture[10], listOfRandomFloats[10]); + + fixture.Clear(); + + Assert.True(fixture.Count == 0); + } + + [Fact] + public void ExceptionTests() + { + var exSubject = new Subject(); + + object exceptionRecived = default!; + exSubject.ObserveOn(ImmediateScheduler.Instance).Subscribe(ex => { exceptionRecived = ex; }); + exSubject.OnNext(new UnspecifiedIndexException()); + + Assert.IsType(exceptionRecived); + + exSubject.OnNext(new KeySelectorException()); + + Assert.IsType(exceptionRecived); + + exSubject.OnNext(new MissingKeyException()); + + Assert.IsType(exceptionRecived); + } + } +} diff --git a/src/DynamicData.sln b/src/DynamicData.sln index 3246f918e..086f6038b 100644 --- a/src/DynamicData.sln +++ b/src/DynamicData.sln @@ -9,11 +9,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".other", ".other", "{DFCC45 ProjectSection(SolutionItems) = preProject ..\.editorconfig = ..\.editorconfig ..\.gitignore = ..\.gitignore + ..\.github\workflows\ci-build.yml = ..\.github\workflows\ci-build.yml Directory.Build.props = Directory.Build.props Directory.build.targets = Directory.build.targets global.json = global.json NuGet.Config = NuGet.Config ..\README.md = ..\README.md + ..\.github\workflows\release.yml = ..\.github\workflows\release.yml ReleaseNotes.md = ReleaseNotes.md stylecop.json = stylecop.json ..\version.json = ..\version.json diff --git a/src/DynamicData/Aggregation/AggregateEnumerator.cs b/src/DynamicData/Aggregation/AggregateEnumerator.cs index 7800f3346..6cebcf69d 100644 --- a/src/DynamicData/Aggregation/AggregateEnumerator.cs +++ b/src/DynamicData/Aggregation/AggregateEnumerator.cs @@ -3,25 +3,17 @@ // See the LICENSE file in the project root for full license information. using System.Collections; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using DynamicData.Cache; namespace DynamicData.Aggregation; -internal class AggregateEnumerator : IAggregateChangeSet +internal class AggregateEnumerator(IChangeSet source) : IAggregateChangeSet where T : notnull { - private readonly IChangeSet _source; - - public AggregateEnumerator(IChangeSet source) - { - _source = source; - } - public IEnumerator> GetEnumerator() { - foreach (var change in _source) + foreach (var change in source) { switch (change.Reason) { @@ -58,23 +50,15 @@ public IEnumerator> GetEnumerator() } } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Same name, different generics.")] -internal class AggregateEnumerator : IAggregateChangeSet +internal class AggregateEnumerator(IChangeSet source) : IAggregateChangeSet where TObject : notnull where TKey : notnull { - private readonly ChangeSet _source; - - public AggregateEnumerator(IChangeSet source) - { - _source = source.ToConcreteType(); - } + private readonly ChangeSet _source = source.ToConcreteType(); public IEnumerator> GetEnumerator() { @@ -101,8 +85,5 @@ public IEnumerator> GetEnumerator() } } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/src/DynamicData/Aggregation/AggregateItem.cs b/src/DynamicData/Aggregation/AggregateItem.cs index 5b14a5cc9..e69c0ff90 100644 --- a/src/DynamicData/Aggregation/AggregateItem.cs +++ b/src/DynamicData/Aggregation/AggregateItem.cs @@ -2,59 +2,39 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - namespace DynamicData.Aggregation; /// /// An object representing added and removed items in a continuous aggregation stream. /// /// The type of the object. -public readonly struct AggregateItem : IEquatable> +/// +/// Initializes a new instance of the struct. +/// +/// The type. +/// The item. +public readonly struct AggregateItem(AggregateType type, TObject item) : IEquatable> { - /// - /// Initializes a new instance of the struct. - /// - /// The type. - /// The item. - public AggregateItem(AggregateType type, TObject item) - { - Type = type; - Item = item; - } - /// /// Gets the type. /// - public AggregateType Type { get; } + public AggregateType Type { get; } = type; /// /// Gets the item. /// - public TObject Item { get; } + public TObject Item { get; } = item; - public static bool operator ==(AggregateItem left, AggregateItem right) - { - return left.Equals(right); - } + public static bool operator ==(AggregateItem left, AggregateItem right) => left.Equals(right); - public static bool operator !=(AggregateItem left, AggregateItem right) - { - return !(left == right); - } + public static bool operator !=(AggregateItem left, AggregateItem right) => !(left == right); /// - public override bool Equals(object? obj) - { - return obj is AggregateItem item && Equals(item); - } + public override bool Equals(object? obj) => obj is AggregateItem item && Equals(item); /// - public bool Equals(AggregateItem other) - { - return Type == other.Type && EqualityComparer.Default.Equals(Item, other.Item); - } + public bool Equals(AggregateItem other) => + Type == other.Type && EqualityComparer.Default.Equals(Item, other.Item); /// public override int GetHashCode() diff --git a/src/DynamicData/Aggregation/AggregationEx.cs b/src/DynamicData/Aggregation/AggregationEx.cs index da4d5e58f..e620eab22 100644 --- a/src/DynamicData/Aggregation/AggregationEx.cs +++ b/src/DynamicData/Aggregation/AggregationEx.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Linq; using System.Reactive; using System.Reactive.Linq; @@ -58,10 +56,8 @@ public static IObservable> ForAggregation( /// The source. /// The invalidate. /// An observable which emits the value. - public static IObservable InvalidateWhen(this IObservable source, IObservable invalidate) - { - return invalidate.StartWith(Unit.Default).Select(_ => source).Switch().DistinctUntilChanged(); - } + public static IObservable InvalidateWhen(this IObservable source, IObservable invalidate) => + invalidate.StartWith(Unit.Default).Select(_ => source).Switch().DistinctUntilChanged(); /// /// Used to invalidate an aggregating stream. Used when there has been an inline change. @@ -71,10 +67,8 @@ public static IObservable InvalidateWhen(this IObservable source, IObse /// The source. /// The invalidate. /// An observable which emits the value. - public static IObservable InvalidateWhen(this IObservable source, IObservable invalidate) - { - return invalidate.StartWith(default(TTrigger)).Select(_ => source).Switch().DistinctUntilChanged(); - } + public static IObservable InvalidateWhen(this IObservable source, IObservable invalidate) => + invalidate.StartWith(default(TTrigger)).Select(_ => source).Switch().DistinctUntilChanged(); /// /// Applies an accumulator when items are added to and removed from specified stream, @@ -89,10 +83,7 @@ public static IObservable InvalidateWhen(this IObservable sou /// The remove action. /// An observable with the accumulated value. internal static IObservable Accumulate(this IObservable> source, TResult seed, Func accessor, Func addAction, Func removeAction) - where TObject : notnull - { - return source.ForAggregation().Accumulate(seed, accessor, addAction, removeAction); - } + where TObject : notnull => source.ForAggregation().Accumulate(seed, accessor, addAction, removeAction); /// /// Applies an accumulator when items are added to and removed from specified stream, @@ -109,10 +100,7 @@ internal static IObservable Accumulate(this IObservab /// An observable with the accumulated value. internal static IObservable Accumulate(this IObservable> source, TResult seed, Func accessor, Func addAction, Func removeAction) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Accumulate(seed, accessor, addAction, removeAction); - } + where TKey : notnull => source.ForAggregation().Accumulate(seed, accessor, addAction, removeAction); /// /// Applies an accumulator when items are added to and removed from specified stream, @@ -148,6 +136,8 @@ internal static IObservable Accumulate(this IObservab throw new ArgumentNullException(nameof(removeAction)); } - return source.Scan(seed, (state, changes) => { return changes.Aggregate(state, (current, aggregateItem) => aggregateItem.Type == AggregateType.Add ? addAction(current, accessor(aggregateItem.Item)) : removeAction(current, accessor(aggregateItem.Item))); }); + return source.Scan(seed, (state, changes) => + changes.Aggregate(state, (current, aggregateItem) => + aggregateItem.Type == AggregateType.Add ? addAction(current, accessor(aggregateItem.Item)) : removeAction(current, accessor(aggregateItem.Item)))); } } diff --git a/src/DynamicData/Aggregation/Avg.cs b/src/DynamicData/Aggregation/Avg.cs index ac5326f27..a7c9c6343 100644 --- a/src/DynamicData/Aggregation/Avg.cs +++ b/src/DynamicData/Aggregation/Avg.cs @@ -4,15 +4,9 @@ namespace DynamicData.Aggregation; -internal readonly struct Avg +internal readonly struct Avg(int count, TValue sum) { - public Avg(int count, TValue sum) - { - Count = count; - Sum = sum; - } + public int Count { get; } = count; - public int Count { get; } - - public TValue Sum { get; } + public TValue Sum { get; } = sum; } diff --git a/src/DynamicData/Aggregation/AvgEx.cs b/src/DynamicData/Aggregation/AvgEx.cs index 7192d723a..7c1c34f11 100644 --- a/src/DynamicData/Aggregation/AvgEx.cs +++ b/src/DynamicData/Aggregation/AvgEx.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Linq; using System.Reactive.Linq; namespace DynamicData.Aggregation; @@ -26,10 +24,7 @@ public static class AvgEx /// public static IObservable Avg(this IObservable> source, Func valueSelector, int emptyValue = 0) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where TKey : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -44,10 +39,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, int emptyValue = 0) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where TKey : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -62,10 +54,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, long emptyValue = 0) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where TKey : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -80,10 +69,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, long emptyValue = 0) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where TKey : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -98,10 +84,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, double emptyValue = 0) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where TKey : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -116,10 +99,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, double emptyValue = 0) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where TKey : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -134,10 +114,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, decimal emptyValue = 0) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where TKey : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -152,10 +129,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, decimal emptyValue = 0) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where TKey : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -170,10 +144,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, float emptyValue = 0) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where TKey : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -188,10 +159,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, float emptyValue = 0) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where TKey : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -204,10 +172,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, int emptyValue = 0) - where T : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where T : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -220,10 +185,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, int emptyValue = 0) - where T : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where T : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -236,10 +198,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, long emptyValue = 0) - where T : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where T : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -252,10 +211,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, long emptyValue = 0) - where T : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where T : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -268,10 +224,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, double emptyValue = 0) - where T : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where T : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -284,10 +237,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, double emptyValue = 0) - where T : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where T : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -300,10 +250,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, decimal emptyValue = 0) - where T : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where T : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -316,10 +263,7 @@ public static IObservable Avg(this IObservable> source /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, decimal emptyValue = 0) - where T : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where T : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -332,10 +276,7 @@ public static IObservable Avg(this IObservable> source /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, float emptyValue = 0) - where T : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where T : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -348,10 +289,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, float emptyValue = 0) - where T : notnull - { - return source.ForAggregation().Avg(valueSelector, emptyValue); - } + where T : notnull => source.ForAggregation().Avg(valueSelector, emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -363,10 +301,7 @@ public static IObservable Avg(this IObservable> source, /// /// An observable of averages. /// - public static IObservable Avg(this IObservable> source, Func valueSelector, int emptyValue = 0) - { - return source.AvgCalc(valueSelector, emptyValue, (current, item) => new Avg(current.Count + 1, current.Sum + item), (current, item) => new Avg(current.Count - 1, current.Sum - item), values => values.Sum / (double)values.Count); - } + public static IObservable Avg(this IObservable> source, Func valueSelector, int emptyValue = 0) => source.AvgCalc(valueSelector, emptyValue, (current, item) => new Avg(current.Count + 1, current.Sum + item), (current, item) => new Avg(current.Count - 1, current.Sum - item), values => values.Sum / (double)values.Count); /// /// Continuous calculation of the average of the underlying data source. @@ -378,10 +313,7 @@ public static IObservable Avg(this IObservable /// /// An observable of averages. /// - public static IObservable Avg(this IObservable> source, Func valueSelector, int emptyValue = 0) - { - return source.Avg(t => valueSelector(t).GetValueOrDefault(), emptyValue); - } + public static IObservable Avg(this IObservable> source, Func valueSelector, int emptyValue = 0) => source.Avg(t => valueSelector(t).GetValueOrDefault(), emptyValue); /// /// Averages the specified value selector. @@ -391,10 +323,7 @@ public static IObservable Avg(this IObservable /// The value selector. /// The empty value. /// An observable of averages as a double value. - public static IObservable Avg(this IObservable> source, Func valueSelector, long emptyValue = 0) - { - return source.AvgCalc(valueSelector, emptyValue, (current, item) => new Avg(current.Count + 1, current.Sum + item), (current, item) => new Avg(current.Count - 1, current.Sum - item), values => values.Sum / (double)values.Count); - } + public static IObservable Avg(this IObservable> source, Func valueSelector, long emptyValue = 0) => source.AvgCalc(valueSelector, emptyValue, (current, item) => new Avg(current.Count + 1, current.Sum + item), (current, item) => new Avg(current.Count - 1, current.Sum - item), values => values.Sum / (double)values.Count); /// /// Continuous calculation of the average of the underlying data source. @@ -406,10 +335,7 @@ public static IObservable Avg(this IObservable /// /// An observable of averages. /// - public static IObservable Avg(this IObservable> source, Func valueSelector, long emptyValue = 0) - { - return source.Avg(t => valueSelector(t).GetValueOrDefault(), emptyValue); - } + public static IObservable Avg(this IObservable> source, Func valueSelector, long emptyValue = 0) => source.Avg(t => valueSelector(t).GetValueOrDefault(), emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -421,10 +347,7 @@ public static IObservable Avg(this IObservable /// /// An observable of averages. /// - public static IObservable Avg(this IObservable> source, Func valueSelector, double emptyValue = 0) - { - return source.AvgCalc(valueSelector, emptyValue, (current, item) => new Avg(current.Count + 1, current.Sum + item), (current, item) => new Avg(current.Count - 1, current.Sum - item), values => values.Sum / (double)values.Count); - } + public static IObservable Avg(this IObservable> source, Func valueSelector, double emptyValue = 0) => source.AvgCalc(valueSelector, emptyValue, (current, item) => new Avg(current.Count + 1, current.Sum + item), (current, item) => new Avg(current.Count - 1, current.Sum - item), values => values.Sum / (double)values.Count); /// /// Continuous calculation of the average of the underlying data source. @@ -436,10 +359,7 @@ public static IObservable Avg(this IObservable /// /// An observable of averages. /// - public static IObservable Avg(this IObservable> source, Func valueSelector, double emptyValue = 0) - { - return source.Avg(t => valueSelector(t).GetValueOrDefault(), emptyValue); - } + public static IObservable Avg(this IObservable> source, Func valueSelector, double emptyValue = 0) => source.Avg(t => valueSelector(t).GetValueOrDefault(), emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -451,10 +371,7 @@ public static IObservable Avg(this IObservable /// /// An observable of averages. /// - public static IObservable Avg(this IObservable> source, Func valueSelector, decimal emptyValue = 0) - { - return source.AvgCalc(valueSelector, emptyValue, (current, item) => new Avg(current.Count + 1, current.Sum + item), (current, item) => new Avg(current.Count - 1, current.Sum - item), values => values.Sum / values.Count); - } + public static IObservable Avg(this IObservable> source, Func valueSelector, decimal emptyValue = 0) => source.AvgCalc(valueSelector, emptyValue, (current, item) => new Avg(current.Count + 1, current.Sum + item), (current, item) => new Avg(current.Count - 1, current.Sum - item), values => values.Sum / values.Count); /// /// Averages the specified value selector. @@ -464,10 +381,7 @@ public static IObservable Avg(this IObservableThe value selector. /// The empty value. /// An observable of decimals with the averaged values. - public static IObservable Avg(this IObservable> source, Func valueSelector, decimal emptyValue = 0) - { - return source.Avg(t => valueSelector(t).GetValueOrDefault(), emptyValue); - } + public static IObservable Avg(this IObservable> source, Func valueSelector, decimal emptyValue = 0) => source.Avg(t => valueSelector(t).GetValueOrDefault(), emptyValue); /// /// Continuous calculation of the average of the underlying data source. @@ -479,10 +393,7 @@ public static IObservable Avg(this IObservable /// An observable of averages. /// - public static IObservable Avg(this IObservable> source, Func valueSelector, float emptyValue = 0) - { - return source.AvgCalc(valueSelector, emptyValue, (current, item) => new Avg(current.Count + 1, current.Sum + item), (current, item) => new Avg(current.Count - 1, current.Sum - item), values => values.Sum / values.Count); - } + public static IObservable Avg(this IObservable> source, Func valueSelector, float emptyValue = 0) => source.AvgCalc(valueSelector, emptyValue, (current, item) => new Avg(current.Count + 1, current.Sum + item), (current, item) => new Avg(current.Count - 1, current.Sum - item), values => values.Sum / values.Count); /// /// Continuous calculation of the average of the underlying data source. @@ -494,13 +405,17 @@ public static IObservable Avg(this IObservable> /// /// An observable of averages. /// - public static IObservable Avg(this IObservable> source, Func valueSelector, float emptyValue = 0) - { - return source.Avg(t => valueSelector(t).GetValueOrDefault(), emptyValue); - } + public static IObservable Avg(this IObservable> source, Func valueSelector, float emptyValue = 0) => source.Avg(t => valueSelector(t).GetValueOrDefault(), emptyValue); private static IObservable AvgCalc(this IObservable> source, Func valueSelector, TResult fallbackValue, Func, TValue, Avg> addAction, Func, TValue, Avg> removeAction, Func, TResult> resultAction) { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(valueSelector); + ArgumentNullException.ThrowIfNull(addAction); + ArgumentNullException.ThrowIfNull(removeAction); + ArgumentNullException.ThrowIfNull(resultAction); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -525,7 +440,10 @@ private static IObservable AvgCalc(this IObse { throw new ArgumentNullException(nameof(resultAction)); } +#endif - return source.Scan(default(Avg), (state, changes) => { return changes.Aggregate(state, (current, aggregateItem) => aggregateItem.Type == AggregateType.Add ? addAction(current, valueSelector(aggregateItem.Item)) : removeAction(current, valueSelector(aggregateItem.Item))); }).Select(values => values.Count == 0 ? fallbackValue : resultAction(values)); + return source.Scan(default(Avg), (state, changes) => + changes.Aggregate(state, (current, aggregateItem) => + aggregateItem.Type == AggregateType.Add ? addAction(current, valueSelector(aggregateItem.Item)) : removeAction(current, valueSelector(aggregateItem.Item)))).Select(values => values.Count == 0 ? fallbackValue : resultAction(values)); } } diff --git a/src/DynamicData/Aggregation/CountEx.cs b/src/DynamicData/Aggregation/CountEx.cs index fb58fc39a..ffdb3bbcf 100644 --- a/src/DynamicData/Aggregation/CountEx.cs +++ b/src/DynamicData/Aggregation/CountEx.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Linq; namespace DynamicData.Aggregation; @@ -21,10 +20,7 @@ public static class CountEx /// An observable which emits the count. public static IObservable Count(this IObservable> source) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Count(); - } + where TKey : notnull => source.ForAggregation().Count(); /// /// Counts the total number of items in the underlying data source. @@ -33,10 +29,7 @@ public static IObservable Count(this IObservableThe source. /// An observable which emits the count. public static IObservable Count(this IObservable> source) - where TObject : notnull - { - return source.ForAggregation().Count(); - } + where TObject : notnull => source.ForAggregation().Count(); /// /// Counts the total number of items in the underlying data source. @@ -44,10 +37,7 @@ public static IObservable Count(this IObservableThe type of the object. /// The source. /// An observable which emits the count. - public static IObservable Count(this IObservable> source) - { - return source.Accumulate(0, _ => 1, (current, increment) => current + increment, (current, increment) => current - increment); - } + public static IObservable Count(this IObservable> source) => source.Accumulate(0, _ => 1, (current, increment) => current + increment, (current, increment) => current - increment); /// /// Counts the total number of items in the underlying data source. @@ -56,10 +46,7 @@ public static IObservable Count(this IObservableThe source. /// An observable which emits the count. public static IObservable Count(this IObservable> source) - where TObject : notnull - { - return source.ForAggregation().Count(); - } + where TObject : notnull => source.ForAggregation().Count(); /// /// Counts the total number of items in the underlying data source @@ -71,10 +58,7 @@ public static IObservable Count(this IObservableAn observable which emits the count. public static IObservable IsEmpty(this IObservable> source) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Count().StartWith(0).Select(count => count == 0); - } + where TKey : notnull => source.ForAggregation().Count().StartWith(0).Select(count => count == 0); /// /// Counts the total number of items in the underlying data source @@ -84,10 +68,7 @@ public static IObservable IsEmpty(this IObservableThe source. /// An observable which emits the count. public static IObservable IsEmpty(this IObservable> source) - where TObject : notnull - { - return source.ForAggregation().Count().StartWith(0).Select(count => count == 0); - } + where TObject : notnull => source.ForAggregation().Count().StartWith(0).Select(count => count == 0); /// /// Counts the total number of items in the underlying data source @@ -99,10 +80,7 @@ public static IObservable IsEmpty(this IObservableAn observable which emits the count. public static IObservable IsNotEmpty(this IObservable> source) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Count().StartWith(0).Select(count => count > 0); - } + where TKey : notnull => source.ForAggregation().Count().StartWith(0).Select(count => count > 0); /// /// Counts the total number of items in the underlying data source @@ -112,8 +90,5 @@ public static IObservable IsNotEmpty(this IObservableThe source. /// An observable which emits the count. public static IObservable IsNotEmpty(this IObservable> source) - where TObject : notnull - { - return source.ForAggregation().Count().StartWith(0).Select(count => count > 0); - } + where TObject : notnull => source.ForAggregation().Count().StartWith(0).Select(count => count > 0); } diff --git a/src/DynamicData/Aggregation/IAggregateChangeSet.cs b/src/DynamicData/Aggregation/IAggregateChangeSet.cs index 964ef4949..34d2e936b 100644 --- a/src/DynamicData/Aggregation/IAggregateChangeSet.cs +++ b/src/DynamicData/Aggregation/IAggregateChangeSet.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - namespace DynamicData.Aggregation; /// diff --git a/src/DynamicData/Aggregation/MaxEx.cs b/src/DynamicData/Aggregation/MaxEx.cs index 377cfbf99..2ce9964e5 100644 --- a/src/DynamicData/Aggregation/MaxEx.cs +++ b/src/DynamicData/Aggregation/MaxEx.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Linq; namespace DynamicData.Aggregation; @@ -34,10 +31,7 @@ private enum MaxOrMin /// public static IObservable Maximum(this IObservable> source, Func valueSelector, TResult emptyValue = default) where TObject : notnull - where TResult : struct, IComparable - { - return source.ToChangesAndCollection().Calculate(valueSelector, MaxOrMin.Max, emptyValue); - } + where TResult : struct, IComparable => source.ToChangesAndCollection().Calculate(valueSelector, MaxOrMin.Max, emptyValue); /// /// Continually calculates the maximum value from the underlying data source. @@ -54,10 +48,7 @@ public static IObservable Maximum(this IObservable Maximum(this IObservable> source, Func valueSelector, TResult emptyValue = default) where TObject : notnull where TKey : notnull - where TResult : struct, IComparable - { - return source.ToChangesAndCollection().Calculate(valueSelector, MaxOrMin.Max, emptyValue); - } + where TResult : struct, IComparable => source.ToChangesAndCollection().Calculate(valueSelector, MaxOrMin.Max, emptyValue); /// /// Continually calculates the minimum value from the underlying data source. @@ -70,10 +61,7 @@ public static IObservable Maximum(this IObserva /// A distinct observable of the minimums item. public static IObservable Minimum(this IObservable> source, Func valueSelector, TResult emptyValue = default) where TObject : notnull - where TResult : struct, IComparable - { - return source.ToChangesAndCollection().Calculate(valueSelector, MaxOrMin.Min, emptyValue); - } + where TResult : struct, IComparable => source.ToChangesAndCollection().Calculate(valueSelector, MaxOrMin.Min, emptyValue); /// /// Continually calculates the minimum value from the underlying data source. @@ -90,14 +78,15 @@ public static IObservable Minimum(this IObservable Minimum(this IObservable> source, Func valueSelector, TResult emptyValue = default) where TObject : notnull where TKey : notnull - where TResult : struct, IComparable - { - return source.ToChangesAndCollection().Calculate(valueSelector, MaxOrMin.Min, emptyValue); - } + where TResult : struct, IComparable => source.ToChangesAndCollection().Calculate(valueSelector, MaxOrMin.Min, emptyValue); private static IObservable Calculate(this IObservable> source, Func valueSelector, MaxOrMin maxOrMin, TResult emptyValue = default) where TResult : struct, IComparable { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(valueSelector); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -107,6 +96,7 @@ private static IObservable Calculate(this IObservable { throw new ArgumentNullException(nameof(valueSelector)); } +#endif return source.Scan( default(TResult?), @@ -169,10 +159,14 @@ private static IObservable> ToChangesAndCollection where TObject : notnull where TKey : notnull { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); } +#endif return source.Publish( shared => @@ -186,10 +180,14 @@ private static IObservable> ToChangesAndCollection private static IObservable> ToChangesAndCollection(this IObservable> source) where TObject : notnull { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); } +#endif return source.Publish( shared => @@ -200,16 +198,10 @@ private static IObservable> ToChangesAndCollection }); } - private class ChangesAndCollection + private class ChangesAndCollection(IAggregateChangeSet changes, IReadOnlyCollection collection) { - public ChangesAndCollection(IAggregateChangeSet changes, IReadOnlyCollection collection) - { - Changes = changes; - Collection = collection; - } - - public IAggregateChangeSet Changes { get; } + public IAggregateChangeSet Changes { get; } = changes; - public IReadOnlyCollection Collection { get; } + public IReadOnlyCollection Collection { get; } = collection; } } diff --git a/src/DynamicData/Aggregation/StdDev.cs b/src/DynamicData/Aggregation/StdDev.cs index 18b835f1c..2f9942a21 100644 --- a/src/DynamicData/Aggregation/StdDev.cs +++ b/src/DynamicData/Aggregation/StdDev.cs @@ -4,18 +4,11 @@ namespace DynamicData.Aggregation; -internal readonly struct StdDev +internal readonly struct StdDev(int count, TValue sumOfItems, TValue sumOfSquares) { - public StdDev(int count, TValue sumOfItems, TValue sumOfSquares) - { - Count = count; - SumOfItems = sumOfItems; - SumOfSquares = sumOfSquares; - } + public int Count { get; } = count; - public int Count { get; } + public TValue SumOfItems { get; } = sumOfItems; - public TValue SumOfItems { get; } - - public TValue SumOfSquares { get; } + public TValue SumOfSquares { get; } = sumOfSquares; } diff --git a/src/DynamicData/Aggregation/StdDevEx.cs b/src/DynamicData/Aggregation/StdDevEx.cs index 214b6b65e..c37e98c63 100644 --- a/src/DynamicData/Aggregation/StdDevEx.cs +++ b/src/DynamicData/Aggregation/StdDevEx.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Linq; using System.Reactive.Linq; namespace DynamicData.Aggregation; @@ -22,10 +20,7 @@ public static class StdDevEx /// The fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, int fallbackValue) - where T : notnull - { - return source.ForAggregation().StdDev(valueSelector, fallbackValue); - } + where T : notnull => source.ForAggregation().StdDev(valueSelector, fallbackValue); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -36,10 +31,7 @@ public static IObservable StdDev(this IObservable> sour /// The fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, long fallbackValue) - where T : notnull - { - return source.ForAggregation().StdDev(valueSelector, fallbackValue); - } + where T : notnull => source.ForAggregation().StdDev(valueSelector, fallbackValue); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -50,10 +42,7 @@ public static IObservable StdDev(this IObservable> sour /// The fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, double fallbackValue) - where T : notnull - { - return source.ForAggregation().StdDev(valueSelector, fallbackValue); - } + where T : notnull => source.ForAggregation().StdDev(valueSelector, fallbackValue); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -63,11 +52,8 @@ public static IObservable StdDev(this IObservable> sour /// The value selector. /// The fallback value. /// An observable which emits the standard deviation value. - public static IObservable StdDev(this IObservable> source, Func valueSelector, decimal fallbackValue) - where T : notnull - { - return source.ForAggregation().StdDev(valueSelector, fallbackValue); - } + public static IObservable StdDev(this IObservable> source, Func valueSelector, decimal fallbackValue) + where T : notnull => source.ForAggregation().StdDev(valueSelector, fallbackValue); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -78,10 +64,7 @@ public static IObservable StdDev(this IObservable> sour /// The fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, float fallbackValue = 0) - where T : notnull - { - return source.ForAggregation().StdDev(valueSelector, fallbackValue); - } + where T : notnull => source.ForAggregation().StdDev(valueSelector, fallbackValue); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -94,10 +77,7 @@ public static IObservable StdDev(this IObservable> sour /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, int fallbackValue) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().StdDev(valueSelector, fallbackValue); - } + where TKey : notnull => source.ForAggregation().StdDev(valueSelector, fallbackValue); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -110,10 +90,7 @@ public static IObservable StdDev(this IObservableAn observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, long fallbackValue) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().StdDev(valueSelector, fallbackValue); - } + where TKey : notnull => source.ForAggregation().StdDev(valueSelector, fallbackValue); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -126,10 +103,7 @@ public static IObservable StdDev(this IObservableAn observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, double fallbackValue) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().StdDev(valueSelector, fallbackValue); - } + where TKey : notnull => source.ForAggregation().StdDev(valueSelector, fallbackValue); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -140,12 +114,9 @@ public static IObservable StdDev(this IObservableThe value selector. /// The fallback value. /// An observable which emits the standard deviation value. - public static IObservable StdDev(this IObservable> source, Func valueSelector, decimal fallbackValue) + public static IObservable StdDev(this IObservable> source, Func valueSelector, decimal fallbackValue) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().StdDev(valueSelector, fallbackValue); - } + where TKey : notnull => source.ForAggregation().StdDev(valueSelector, fallbackValue); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -158,10 +129,7 @@ public static IObservable StdDev(this IObservableAn observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, float fallbackValue = 0) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().StdDev(valueSelector, fallbackValue); - } + where TKey : notnull => source.ForAggregation().StdDev(valueSelector, fallbackValue); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -171,10 +139,7 @@ public static IObservable StdDev(this IObservableThe value selector. /// The fallback value. /// An observable which emits the standard deviation value. - public static IObservable StdDev(this IObservable> source, Func valueSelector, int fallbackValue = 0) - { - return source.StdDevCalc(t => (long)valueSelector(t), fallbackValue, (current, item) => new StdDev(current.Count + 1, current.SumOfItems + item, current.SumOfSquares + (item * item)), (current, item) => new StdDev(current.Count - 1, current.SumOfItems - item, current.SumOfSquares - (item * item)), values => Math.Sqrt(values.SumOfSquares - ((values.SumOfItems * values.SumOfItems) / values.Count)) * (1.0d / (values.Count - 1))); - } + public static IObservable StdDev(this IObservable> source, Func valueSelector, int fallbackValue = 0) => source.StdDevCalc(t => (long)valueSelector(t), fallbackValue, (current, item) => new StdDev(current.Count + 1, current.SumOfItems + item, current.SumOfSquares + (item * item)), (current, item) => new StdDev(current.Count - 1, current.SumOfItems - item, current.SumOfSquares - (item * item)), values => Math.Sqrt(values.SumOfSquares - ((values.SumOfItems * values.SumOfItems) / values.Count)) * (1.0d / (values.Count - 1))); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -184,10 +149,8 @@ public static IObservable StdDev(this IObservableThe value selector. /// The fallback value. /// An observable which emits the standard deviation value. - public static IObservable StdDev(this IObservable> source, Func valueSelector, long fallbackValue = 0) - { - return source.StdDevCalc(valueSelector, fallbackValue, (current, item) => new StdDev(current.Count + 1, current.SumOfItems + item, current.SumOfSquares + (item * item)), (current, item) => new StdDev(current.Count - 1, current.SumOfItems - item, current.SumOfSquares - (item * item)), values => Math.Sqrt(values.SumOfSquares - ((values.SumOfItems * values.SumOfItems) / values.Count)) * (1.0d / (values.Count - 1))); - } + public static IObservable StdDev(this IObservable> source, Func valueSelector, long fallbackValue = 0) => + source.StdDevCalc(valueSelector, fallbackValue, (current, item) => new StdDev(current.Count + 1, current.SumOfItems + item, current.SumOfSquares + (item * item)), (current, item) => new StdDev(current.Count - 1, current.SumOfItems - item, current.SumOfSquares - (item * item)), values => Math.Sqrt(values.SumOfSquares - ((values.SumOfItems * values.SumOfItems) / values.Count)) * (1.0d / (values.Count - 1))); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -197,16 +160,9 @@ public static IObservable StdDev(this IObservableThe value selector. /// The fallback value. /// An observable which emits the standard deviation value. - public static IObservable StdDev(this IObservable> source, Func valueSelector, decimal fallbackValue = 0M) - { - throw new NotImplementedException("For some reason there is a problem with decimal value inference"); - - //// return source.StdDevCalc(valueSelector, - //// fallbackValue, - //// (current, item) => new StdDev(current.Count + 1, current.SumOfItems + item, current.SumOfSquares + (item * item)), - //// (current, item) => new StdDev(current.Count - 1, current.SumOfItems - item, current.SumOfSquares - (item * item)), - //// values => Math.Sqrt((double)values.SumOfSquares - (double)(values.SumOfItems * values.SumOfItems) / values.Count) * (1.0d / (values.Count - 1))); - } + public static IObservable StdDev(this IObservable> source, Func valueSelector, decimal fallbackValue = 0M) => + //// throw new NotImplementedException("For some reason there is a problem with decimal value inference"); + source.StdDevCalc(valueSelector, fallbackValue, (current, item) => new StdDev(current.Count + 1, current.SumOfItems + item, current.SumOfSquares + (item * item)), (current, item) => new StdDev(current.Count - 1, current.SumOfItems - item, current.SumOfSquares - (item * item)), values => Sqrt((decimal)(values.SumOfSquares - ((values.SumOfItems * values.SumOfItems) / values.Count))) * (1.0M / (values.Count - 1))); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -216,10 +172,7 @@ public static IObservable StdDev(this IObservableThe value selector. /// The fallback value. /// An observable which emits the standard deviation value. - public static IObservable StdDev(this IObservable> source, Func valueSelector, double fallbackValue = 0) - { - return source.StdDevCalc(valueSelector, fallbackValue, (current, item) => new StdDev(current.Count + 1, current.SumOfItems + item, current.SumOfSquares + (item * item)), (current, item) => new StdDev(current.Count - 1, current.SumOfItems - item, current.SumOfSquares - (item * item)), values => Math.Sqrt(values.SumOfSquares - ((values.SumOfItems * values.SumOfItems) / values.Count)) * (1.0d / (values.Count - 1))); - } + public static IObservable StdDev(this IObservable> source, Func valueSelector, double fallbackValue = 0) => source.StdDevCalc(valueSelector, fallbackValue, (current, item) => new StdDev(current.Count + 1, current.SumOfItems + item, current.SumOfSquares + (item * item)), (current, item) => new StdDev(current.Count - 1, current.SumOfItems - item, current.SumOfSquares - (item * item)), values => Math.Sqrt(values.SumOfSquares - ((values.SumOfItems * values.SumOfItems) / values.Count)) * (1.0d / (values.Count - 1))); /// /// Continual computation of the standard deviation of the values in the underlying data source. @@ -229,13 +182,17 @@ public static IObservable StdDev(this IObservableThe value selector. /// The fallback value. /// An observable which emits the standard deviation value. - public static IObservable StdDev(this IObservable> source, Func valueSelector, float fallbackValue = 0) - { - return source.StdDevCalc(valueSelector, fallbackValue, (current, item) => new StdDev(current.Count + 1, current.SumOfItems + item, current.SumOfSquares + (item * item)), (current, item) => new StdDev(current.Count - 1, current.SumOfItems - item, current.SumOfSquares - (item * item)), values => Math.Sqrt(values.SumOfSquares - ((values.SumOfItems * values.SumOfItems) / values.Count)) * (1.0d / (values.Count - 1))); - } + public static IObservable StdDev(this IObservable> source, Func valueSelector, float fallbackValue = 0) => source.StdDevCalc(valueSelector, fallbackValue, (current, item) => new StdDev(current.Count + 1, current.SumOfItems + item, current.SumOfSquares + (item * item)), (current, item) => new StdDev(current.Count - 1, current.SumOfItems - item, current.SumOfSquares - (item * item)), values => Math.Sqrt(values.SumOfSquares - ((values.SumOfItems * values.SumOfItems) / values.Count)) * (1.0d / (values.Count - 1))); private static IObservable StdDevCalc(this IObservable> source, Func valueSelector, TResult fallbackValue, Func, TValue, StdDev> addAction, Func, TValue, StdDev> removeAction, Func, TResult> resultAction) { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(valueSelector); + ArgumentNullException.ThrowIfNull(addAction); + ArgumentNullException.ThrowIfNull(removeAction); + ArgumentNullException.ThrowIfNull(resultAction); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -260,7 +217,25 @@ private static IObservable StdDevCalc(this IO { throw new ArgumentNullException(nameof(resultAction)); } +#endif + + return source.Scan(default(StdDev), (state, changes) => + changes.Aggregate(state, (current, aggregateItem) => + aggregateItem.Type == AggregateType.Add ? addAction(current, valueSelector(aggregateItem.Item)) : removeAction(current, valueSelector(aggregateItem.Item)))).Select(values => values.Count < 2 ? fallbackValue : resultAction(values)); + } - return source.Scan(default(StdDev), (state, changes) => { return changes.Aggregate(state, (current, aggregateItem) => aggregateItem.Type == AggregateType.Add ? addAction(current, valueSelector(aggregateItem.Item)) : removeAction(current, valueSelector(aggregateItem.Item))); }).Select(values => values.Count < 2 ? fallbackValue : resultAction(values)); + private static decimal Sqrt(decimal x, decimal epsilon = 0.0M) + { + if (x < 0) throw new OverflowException("Cannot calculate square root from a negative number"); + + decimal current = (decimal)Math.Sqrt((double)x), previous; + do + { + previous = current; + if (previous == 0.0M) return 0; + current = (previous + (x / previous)) / 2; + } + while (Math.Abs(previous - current) > epsilon); + return current; } } diff --git a/src/DynamicData/Aggregation/SumEx.cs b/src/DynamicData/Aggregation/SumEx.cs index efb8902f2..c9997742d 100644 --- a/src/DynamicData/Aggregation/SumEx.cs +++ b/src/DynamicData/Aggregation/SumEx.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - using DynamicData.Kernel; namespace DynamicData.Aggregation; @@ -23,10 +21,7 @@ public static class SumEx /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where TKey : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -38,10 +33,7 @@ public static IObservable Sum(this IObservableAn observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where TKey : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -53,10 +45,7 @@ public static IObservable Sum(this IObservableAn observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where TKey : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -68,10 +57,7 @@ public static IObservable Sum(this IObservableAn observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where TKey : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -83,10 +69,7 @@ public static IObservable Sum(this IObservableAn observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where TKey : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -98,10 +81,7 @@ public static IObservable Sum(this IObservableAn observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where TKey : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -113,10 +93,7 @@ public static IObservable Sum(this IObservableAn observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where TKey : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -128,10 +105,7 @@ public static IObservable Sum(this IObservableAn observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where TKey : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -143,10 +117,7 @@ public static IObservable Sum(this IObservableAn observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where TKey : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -158,10 +129,7 @@ public static IObservable Sum(this IObservableAn observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) where TObject : notnull - where TKey : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where TKey : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -171,10 +139,7 @@ public static IObservable Sum(this IObservableThe value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) - where T : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where T : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -184,10 +149,7 @@ public static IObservable Sum(this IObservable> source, Fu /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) - where T : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where T : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -197,10 +159,7 @@ public static IObservable Sum(this IObservable> source, Fu /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) - where T : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where T : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -210,10 +169,7 @@ public static IObservable Sum(this IObservable> source, F /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) - where T : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where T : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -223,10 +179,7 @@ public static IObservable Sum(this IObservable> source, F /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) - where T : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where T : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -236,10 +189,7 @@ public static IObservable Sum(this IObservable> source, /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) - where T : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where T : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -249,10 +199,7 @@ public static IObservable Sum(this IObservable> source, /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) - where T : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where T : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -262,10 +209,7 @@ public static IObservable Sum(this IObservable> source /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) - where T : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where T : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -275,10 +219,7 @@ public static IObservable Sum(this IObservable> source /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) - where T : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where T : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -288,10 +229,7 @@ public static IObservable Sum(this IObservable> source, /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) - where T : notnull - { - return source.ForAggregation().Sum(valueSelector); - } + where T : notnull => source.ForAggregation().Sum(valueSelector); /// /// Continual computes the sum of values matching the value selector. @@ -302,6 +240,11 @@ public static IObservable Sum(this IObservable> source, /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(valueSelector); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -311,6 +254,7 @@ public static IObservable Sum(this IObservable> s { throw new ArgumentNullException(nameof(valueSelector)); } +#endif return source.Accumulate(0, valueSelector, (current, value) => current + value, (current, value) => current - value); } @@ -322,10 +266,7 @@ public static IObservable Sum(this IObservable> s /// The source. /// The value selector. /// An observable which emits the summed value. - public static IObservable Sum(this IObservable> source, Func valueSelector) - { - return source.Accumulate(0, t => valueSelector(t).GetValueOrDefault(), (current, value) => current + value, (current, value) => current - value); - } + public static IObservable Sum(this IObservable> source, Func valueSelector) => source.Accumulate(0, t => valueSelector(t).GetValueOrDefault(), (current, value) => current + value, (current, value) => current - value); /// /// Continual computes the sum of values matching the value selector. @@ -336,6 +277,11 @@ public static IObservable Sum(this IObservable> s /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(valueSelector); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -345,6 +291,7 @@ public static IObservable Sum(this IObservable> { throw new ArgumentNullException(nameof(valueSelector)); } +#endif return source.Accumulate(0, valueSelector, (current, value) => current + value, (current, value) => current - value); } @@ -358,6 +305,11 @@ public static IObservable Sum(this IObservable> /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(valueSelector); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -367,6 +319,7 @@ public static IObservable Sum(this IObservable> { throw new ArgumentNullException(nameof(valueSelector)); } +#endif return source.Accumulate(0L, t => valueSelector(t).ValueOr(0), (current, value) => current + value, (current, value) => current - value); } @@ -380,6 +333,11 @@ public static IObservable Sum(this IObservable> /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(valueSelector); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -389,6 +347,7 @@ public static IObservable Sum(this IObservable { throw new ArgumentNullException(nameof(valueSelector)); } +#endif return source.Accumulate(0, valueSelector, (current, value) => current + value, (current, value) => current - value); } @@ -402,6 +361,11 @@ public static IObservable Sum(this IObservable /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(valueSelector); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -411,6 +375,7 @@ public static IObservable Sum(this IObservable { throw new ArgumentNullException(nameof(valueSelector)); } +#endif return source.Accumulate(0D, t => valueSelector(t).ValueOr(0), (current, value) => current + value, (current, value) => current - value); } @@ -424,6 +389,11 @@ public static IObservable Sum(this IObservable /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(valueSelector); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -433,6 +403,7 @@ public static IObservable Sum(this IObservable current + value, (current, value) => current - value); } @@ -446,6 +417,11 @@ public static IObservable Sum(this IObservableAn observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(valueSelector); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -455,6 +431,7 @@ public static IObservable Sum(this IObservable valueSelector(t).ValueOr(0), (current, value) => current + value, (current, value) => current - value); } @@ -468,6 +445,11 @@ public static IObservable Sum(this IObservableAn observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(valueSelector); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -477,6 +459,7 @@ public static IObservable Sum(this IObservable> { throw new ArgumentNullException(nameof(valueSelector)); } +#endif return source.Accumulate(0, valueSelector, (current, value) => current + value, (current, value) => current - value); } @@ -490,6 +473,11 @@ public static IObservable Sum(this IObservable> /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) { +#if NET6_0_OR_GREATER + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(valueSelector); +#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -499,6 +487,7 @@ public static IObservable Sum(this IObservable> { throw new ArgumentNullException(nameof(valueSelector)); } +#endif return source.Accumulate(0F, t => valueSelector(t).ValueOr(0), (current, value) => current + value, (current, value) => current - value); } diff --git a/src/DynamicData/Alias/ObservableCacheAlias.cs b/src/DynamicData/Alias/ObservableCacheAlias.cs index 80b35051d..c09232322 100644 --- a/src/DynamicData/Alias/ObservableCacheAlias.cs +++ b/src/DynamicData/Alias/ObservableCacheAlias.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive; using DynamicData.Kernel; @@ -71,10 +69,7 @@ public static IObservable> Select> Select(this IObservable> source, Func transformFactory, IObservable>? forceTransform = null) where TDestination : notnull where TSource : notnull - where TKey : notnull - { - return source.Transform(transformFactory, forceTransform); - } + where TKey : notnull => source.Transform(transformFactory, forceTransform); /// /// Projects each update item to a new form using the specified transform function. @@ -94,10 +89,7 @@ public static IObservable> Select> Select(this IObservable> source, Func transformFactory, IObservable forceTransform) where TDestination : notnull where TSource : notnull - where TKey : notnull - { - return source.Transform(transformFactory, forceTransform); - } + where TKey : notnull => source.Transform(transformFactory, forceTransform); /// /// Projects each update item to a new form using the specified transform function. @@ -147,10 +139,7 @@ public static IObservable> SelectMany< where TDestination : notnull where TDestinationKey : notnull where TSource : notnull - where TSourceKey : notnull - { - return source.TransformMany(manySelector, keySelector); - } + where TSourceKey : notnull => source.TransformMany(manySelector, keySelector); /// /// Projects each update item to a new form using the specified transform function, @@ -305,10 +294,7 @@ public static IObservable> SelectSafe> SelectSafe(this IObservable> source, Func transformFactory, Action> errorHandler, IObservable forceTransform) where TDestination : notnull where TSource : notnull - where TKey : notnull - { - return source.TransformSafe(transformFactory, errorHandler, forceTransform); - } + where TKey : notnull => source.TransformSafe(transformFactory, errorHandler, forceTransform); /// /// Transforms the object to a fully recursive tree, create a hierarchy based on the pivot function. diff --git a/src/DynamicData/Alias/ObservableListAlias.cs b/src/DynamicData/Alias/ObservableListAlias.cs index fd2eab3e3..b430c7ef4 100644 --- a/src/DynamicData/Alias/ObservableListAlias.cs +++ b/src/DynamicData/Alias/ObservableListAlias.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - namespace DynamicData.Alias; /// diff --git a/src/DynamicData/Binding/AbstractNotifyPropertyChanged.cs b/src/DynamicData/Binding/AbstractNotifyPropertyChanged.cs index 4cd8226ad..1972a6137 100644 --- a/src/DynamicData/Binding/AbstractNotifyPropertyChanged.cs +++ b/src/DynamicData/Binding/AbstractNotifyPropertyChanged.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Reactive.Disposables; @@ -28,20 +26,15 @@ public abstract class AbstractNotifyPropertyChanged : INotifyPropertyChanged /// A disposable to indicate to stop suspending the notifications. [Obsolete("This never worked properly in the first place")] [SuppressMessage("Design", "CA1822: Make static", Justification = "Backwards compatibility")] - public IDisposable SuspendNotifications(bool invokePropertyChangeEventWhenDisposed = true) - { - // Removed code because it adds weight to the object - return Disposable.Empty; - } + public IDisposable SuspendNotifications(bool invokePropertyChangeEventWhenDisposed = true) => + Disposable.Empty; // Removed code because it adds weight to the object /// /// Invokes on property changed. /// /// Name of the property. - protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) - { + protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } /// /// If the value has changed, sets referenced backing field and raise notify property changed. @@ -50,11 +43,8 @@ protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName /// The backing field. /// The new value. /// Name of the property. - protected virtual void SetAndRaise(ref T backingField, T newValue, [CallerMemberName] string? propertyName = null) - { - // ReSharper disable once ExplicitCallerInfoArgument - SetAndRaise(ref backingField, newValue, EqualityComparer.Default, propertyName); - } + protected virtual void SetAndRaise(ref T backingField, T newValue, [CallerMemberName] string? propertyName = null) => + SetAndRaise(ref backingField, newValue, EqualityComparer.Default, propertyName); // ReSharper disable once ExplicitCallerInfoArgument /// /// If the value has changed, sets referenced backing field and raise notify property changed. diff --git a/src/DynamicData/Binding/BindingListEx.cs b/src/DynamicData/Binding/BindingListEx.cs index 178e64590..3addfa5d4 100644 --- a/src/DynamicData/Binding/BindingListEx.cs +++ b/src/DynamicData/Binding/BindingListEx.cs @@ -160,10 +160,8 @@ private static void Clone(this BindingList source, Change item, IEquali /// /// The source list. /// An observable which emits event pattern changed event args. - public static IObservable> ObserveCollectionChanges(this IBindingList source) - { - return Observable.FromEventPattern(h => source.ListChanged += h, h => source.ListChanged -= h); - } + public static IObservable> ObserveCollectionChanges(this IBindingList source) => + Observable.FromEventPattern(h => source.ListChanged += h, h => source.ListChanged -= h); /// /// Convert a binding list into an observable change set. diff --git a/src/DynamicData/Binding/ExpressionBuilder.cs b/src/DynamicData/Binding/ExpressionBuilder.cs index edc6394f6..e966e2fa1 100644 --- a/src/DynamicData/Binding/ExpressionBuilder.cs +++ b/src/DynamicData/Binding/ExpressionBuilder.cs @@ -2,10 +2,7 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; using System.Linq.Expressions; using System.Reactive; using System.Reactive.Linq; @@ -111,8 +108,7 @@ internal static IEnumerable GetMemberChain internal static PropertyInfo GetProperty(this Expression> expression) { - var property = expression.GetMember() as PropertyInfo; - if (property is null) + if (expression.GetMember() is not PropertyInfo property) { throw new ArgumentException("Not a property expression"); } @@ -122,8 +118,7 @@ internal static PropertyInfo GetProperty(this Expression diff --git a/src/DynamicData/Binding/IObservableCollection.cs b/src/DynamicData/Binding/IObservableCollection.cs index ad0d68e54..d5f0ab82c 100644 --- a/src/DynamicData/Binding/IObservableCollection.cs +++ b/src/DynamicData/Binding/IObservableCollection.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; diff --git a/src/DynamicData/Binding/IObservableListEx.cs b/src/DynamicData/Binding/IObservableListEx.cs index 47352ba9d..3f6ee8919 100644 --- a/src/DynamicData/Binding/IObservableListEx.cs +++ b/src/DynamicData/Binding/IObservableListEx.cs @@ -2,9 +2,7 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Collections.ObjectModel; -using System.Linq; using System.Reactive.Linq; namespace DynamicData.Binding; diff --git a/src/DynamicData/Binding/NotifyPropertyChangedEx.cs b/src/DynamicData/Binding/NotifyPropertyChangedEx.cs index 40c591981..8e6780e95 100644 --- a/src/DynamicData/Binding/NotifyPropertyChangedEx.cs +++ b/src/DynamicData/Binding/NotifyPropertyChangedEx.cs @@ -2,9 +2,7 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.ComponentModel; -using System.Linq; using System.Linq.Expressions; using System.Reactive.Linq; diff --git a/src/DynamicData/Binding/Observable.cs b/src/DynamicData/Binding/Observable.cs index 3f9240052..403d2849f 100644 --- a/src/DynamicData/Binding/Observable.cs +++ b/src/DynamicData/Binding/Observable.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Linq; namespace DynamicData.Binding; diff --git a/src/DynamicData/Binding/ObservableCollectionAdaptor.cs b/src/DynamicData/Binding/ObservableCollectionAdaptor.cs index 6926fa702..d83c7769b 100644 --- a/src/DynamicData/Binding/ObservableCollectionAdaptor.cs +++ b/src/DynamicData/Binding/ObservableCollectionAdaptor.cs @@ -2,11 +2,9 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Diagnostics.CodeAnalysis; using DynamicData.Cache; using DynamicData.Cache.Internal; -using DynamicData.Kernel; namespace DynamicData.Binding; @@ -14,27 +12,18 @@ namespace DynamicData.Binding; /// Adaptor to reflect a change set into an observable list. /// /// The type of the item. -public class ObservableCollectionAdaptor : IChangeSetAdaptor +/// +/// Initializes a new instance of the class. +/// +/// The collection. +/// The refresh threshold. +/// collection. +public class ObservableCollectionAdaptor(IObservableCollection collection, int refreshThreshold = 25) : IChangeSetAdaptor where T : notnull { - private readonly IObservableCollection _collection; - - private readonly int _refreshThreshold; - + private readonly IObservableCollection _collection = collection ?? throw new ArgumentNullException(nameof(collection)); private bool _loaded; - /// - /// Initializes a new instance of the class. - /// - /// The collection. - /// The refresh threshold. - /// collection. - public ObservableCollectionAdaptor(IObservableCollection collection, int refreshThreshold = 25) - { - _collection = collection ?? throw new ArgumentNullException(nameof(collection)); - _refreshThreshold = refreshThreshold; - } - /// /// Maintains the specified collection from the changes. /// @@ -46,7 +35,7 @@ public void Adapt(IChangeSet changes) throw new ArgumentNullException(nameof(changes)); } - if (changes.TotalChanges - changes.Refreshes > _refreshThreshold || !_loaded) + if (changes.TotalChanges - changes.Refreshes > refreshThreshold || !_loaded) { using (_collection.SuspendNotifications()) { @@ -67,29 +56,19 @@ public void Adapt(IChangeSet changes) /// /// The type of the object. /// The type of the key. +/// +/// Initializes a new instance of the class. +/// +/// The threshold before a reset notification is triggered. +/// Use replace instead of remove / add for updates. [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Same class name, only generic difference.")] -public class ObservableCollectionAdaptor : IObservableCollectionAdaptor +public class ObservableCollectionAdaptor(int refreshThreshold = 25, bool useReplaceForUpdates = false) : IObservableCollectionAdaptor where TObject : notnull where TKey : notnull { private readonly Cache _cache = new(); - - private readonly int _refreshThreshold; - private readonly bool _useReplaceForUpdates; - private bool _loaded; - /// - /// Initializes a new instance of the class. - /// - /// The threshold before a reset notification is triggered. - /// Use replace instead of remove / add for updates. - public ObservableCollectionAdaptor(int refreshThreshold = 25, bool useReplaceForUpdates = false) - { - _refreshThreshold = refreshThreshold; - _useReplaceForUpdates = useReplaceForUpdates; - } - /// /// Maintains the specified collection from the changes. /// @@ -109,7 +88,7 @@ public void Adapt(IChangeSet changes, IObservableCollection _refreshThreshold || !_loaded) + if (changes.Count - changes.Refreshes > refreshThreshold || !_loaded) { _loaded = true; using (collection.SuspendNotifications()) @@ -128,7 +107,7 @@ public void Adapt(IChangeSet changes, IObservableCollection changes, IObservableCollection list) { - foreach (Change change in changes.ToConcreteType()) + foreach (var change in changes.ToConcreteType()) { switch (change.Reason) { @@ -143,7 +122,7 @@ private void DoUpdate(IChangeSet changes, IObservableCollection /// The source collection. /// An observable that emits the event patterns. - public static IObservable> ObserveCollectionChanges(this INotifyCollectionChanged source) - { - return Observable.FromEventPattern(h => source.CollectionChanged += h, h => source.CollectionChanged -= h); - } + public static IObservable> ObserveCollectionChanges(this INotifyCollectionChanged source) => Observable.FromEventPattern(h => source.CollectionChanged += h, h => source.CollectionChanged -= h); /// /// Convert an observable collection into an observable change set. diff --git a/src/DynamicData/Binding/ObservableCollectionExtended.cs b/src/DynamicData/Binding/ObservableCollectionExtended.cs index d760bbf74..4fce4e4a9 100644 --- a/src/DynamicData/Binding/ObservableCollectionExtended.cs +++ b/src/DynamicData/Binding/ObservableCollectionExtended.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; diff --git a/src/DynamicData/Binding/ObservablePropertyFactory.cs b/src/DynamicData/Binding/ObservablePropertyFactory.cs index bbfa22210..4594fbb59 100644 --- a/src/DynamicData/Binding/ObservablePropertyFactory.cs +++ b/src/DynamicData/Binding/ObservablePropertyFactory.cs @@ -2,10 +2,7 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; using System.Linq.Expressions; using System.Reactive; using System.Reactive.Linq; @@ -17,8 +14,7 @@ internal class ObservablePropertyFactory { private readonly Func>> _factory; - public ObservablePropertyFactory(Func valueAccessor, ObservablePropertyPart[] chain) - { + public ObservablePropertyFactory(Func valueAccessor, ObservablePropertyPart[] chain) => _factory = (t, notifyInitial) => { // 1) notify when values have changed @@ -31,7 +27,6 @@ public ObservablePropertyFactory(Func valueAccessor, Observa return valueHasChanged.Select(_ => GetPropertyValue(t, chain, valueAccessor)); }; - } public ObservablePropertyFactory(Expression> expression) { @@ -55,10 +50,7 @@ public ObservablePropertyFactory(Expression> expression }; } - public IObservable> Create(TObject source, bool notifyInitial) - { - return _factory(source, notifyInitial); - } + public IObservable> Create(TObject source, bool notifyInitial) => _factory(source, notifyInitial); // create notifier for all parts of the property path private static IEnumerable> GetNotifiers(TObject source, IEnumerable chain) diff --git a/src/DynamicData/Binding/ObservablePropertyFactoryCache.cs b/src/DynamicData/Binding/ObservablePropertyFactoryCache.cs index 89356a119..c0bca0c20 100644 --- a/src/DynamicData/Binding/ObservablePropertyFactoryCache.cs +++ b/src/DynamicData/Binding/ObservablePropertyFactoryCache.cs @@ -2,10 +2,8 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Collections.Concurrent; using System.ComponentModel; -using System.Linq; using System.Linq.Expressions; namespace DynamicData.Binding; diff --git a/src/DynamicData/Binding/ObservablePropertyPart.cs b/src/DynamicData/Binding/ObservablePropertyPart.cs index 398990154..c2ffbf228 100644 --- a/src/DynamicData/Binding/ObservablePropertyPart.cs +++ b/src/DynamicData/Binding/ObservablePropertyPart.cs @@ -2,27 +2,16 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Diagnostics; using System.Linq.Expressions; using System.Reactive; namespace DynamicData.Binding; -[DebuggerDisplay("ObservablePropertyPart<{" + nameof(_expression) + "}>")] -internal sealed class ObservablePropertyPart +[DebuggerDisplay("ObservablePropertyPart<{" + nameof(expression) + "}>")] +internal sealed class ObservablePropertyPart(MemberExpression expression) { - // ReSharper disable once NotAccessedField.Local - private readonly MemberExpression _expression; + public Func Accessor { get; } = expression.CreateValueAccessor(); - public ObservablePropertyPart(MemberExpression expression) - { - _expression = expression; - Factory = expression.CreatePropertyChangedFactory(); - Accessor = expression.CreateValueAccessor(); - } - - public Func Accessor { get; } - - public Func> Factory { get; } + public Func> Factory { get; } = expression.CreatePropertyChangedFactory(); } diff --git a/src/DynamicData/Binding/PropertyValue.cs b/src/DynamicData/Binding/PropertyValue.cs index 4b9d95e11..67ce27b8a 100644 --- a/src/DynamicData/Binding/PropertyValue.cs +++ b/src/DynamicData/Binding/PropertyValue.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - namespace DynamicData.Binding; /// @@ -55,10 +52,7 @@ internal PropertyValue(TObject sender) /// /// The result of the operator. /// - public static bool operator ==(PropertyValue? left, PropertyValue? right) - { - return Equals(left, right); - } + public static bool operator ==(PropertyValue? left, PropertyValue? right) => Equals(left, right); /// /// Implements the operator !=. @@ -68,10 +62,7 @@ internal PropertyValue(TObject sender) /// /// The result of the operator. /// - public static bool operator !=(PropertyValue? left, PropertyValue? right) - { - return !Equals(left, right); - } + public static bool operator !=(PropertyValue? left, PropertyValue? right) => !Equals(left, right); /// public bool Equals(PropertyValue? other) @@ -100,10 +91,7 @@ public bool Equals(PropertyValue? other) } /// - public override bool Equals(object? obj) - { - return obj is PropertyValue propertyValue && Equals(propertyValue); - } + public override bool Equals(object? obj) => obj is PropertyValue propertyValue && Equals(propertyValue); /// public override int GetHashCode() @@ -115,8 +103,5 @@ public override int GetHashCode() } /// - public override string ToString() - { - return $"{Sender} ({Value})"; - } + public override string ToString() => $"{Sender} ({Value})"; } diff --git a/src/DynamicData/Binding/SortExpression.cs b/src/DynamicData/Binding/SortExpression.cs index bdc7efbc8..87ea7a49c 100644 --- a/src/DynamicData/Binding/SortExpression.cs +++ b/src/DynamicData/Binding/SortExpression.cs @@ -2,34 +2,26 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - namespace DynamicData.Binding; /// /// A value expression with sort direction. /// /// The type of the item. -public class SortExpression +/// +/// Initializes a new instance of the class. +/// +/// The expression. +/// The direction. +public class SortExpression(Func expression, SortDirection direction = SortDirection.Ascending) { - /// - /// Initializes a new instance of the class. - /// - /// The expression. - /// The direction. - public SortExpression(Func expression, SortDirection direction = SortDirection.Ascending) - { - Expression = expression; - Direction = direction; - } - /// /// Gets the direction. /// - public SortDirection Direction { get; } + public SortDirection Direction { get; } = direction; /// /// Gets the expression. /// - public Func Expression { get; } + public Func Expression { get; } = expression; } diff --git a/src/DynamicData/Binding/SortExpressionComparer.cs b/src/DynamicData/Binding/SortExpressionComparer.cs index 9c40213ab..9edfb0364 100644 --- a/src/DynamicData/Binding/SortExpressionComparer.cs +++ b/src/DynamicData/Binding/SortExpressionComparer.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - namespace DynamicData.Binding; /// @@ -18,20 +15,14 @@ public class SortExpressionComparer : List>, IComparer /// /// The expression. /// A comparer in ascending order. - public static SortExpressionComparer Ascending(Func expression) - { - return new SortExpressionComparer { new(expression) }; - } + public static SortExpressionComparer Ascending(Func expression) => new() { new(expression) }; /// /// Create an descending sort expression. /// /// The expression. /// A comparer in descending order. - public static SortExpressionComparer Descending(Func expression) - { - return new SortExpressionComparer { new(expression, SortDirection.Descending) }; - } + public static SortExpressionComparer Descending(Func expression) => new() { new(expression, SortDirection.Descending) }; /// public int Compare(T? x, T? y) @@ -71,7 +62,7 @@ public int Compare(T? x, T? y) return 1; } - int result = xValue.CompareTo(yValue); + var result = xValue.CompareTo(yValue); if (result == 0) { continue; diff --git a/src/DynamicData/Binding/SortedObservableCollectionAdaptor.cs b/src/DynamicData/Binding/SortedObservableCollectionAdaptor.cs index b76e63034..a104b5f9c 100644 --- a/src/DynamicData/Binding/SortedObservableCollectionAdaptor.cs +++ b/src/DynamicData/Binding/SortedObservableCollectionAdaptor.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Linq; - namespace DynamicData.Binding; /// @@ -13,24 +10,15 @@ namespace DynamicData.Binding; /// /// The type of the object. /// The type of the key. -public class SortedObservableCollectionAdaptor : ISortedObservableCollectionAdaptor +/// +/// Initializes a new instance of the class. +/// +/// The number of changes before a Reset event is used. +/// Use replace instead of remove / add for updates. +public class SortedObservableCollectionAdaptor(int refreshThreshold = 25, bool useReplaceForUpdates = true) : ISortedObservableCollectionAdaptor where TObject : notnull where TKey : notnull { - private readonly int _refreshThreshold; - private readonly bool _useReplaceForUpdates; - - /// - /// Initializes a new instance of the class. - /// - /// The number of changes before a Reset event is used. - /// Use replace instead of remove / add for updates. - public SortedObservableCollectionAdaptor(int refreshThreshold = 25, bool useReplaceForUpdates = true) - { - _refreshThreshold = refreshThreshold; - _useReplaceForUpdates = useReplaceForUpdates; - } - /// /// Maintains the specified collection from the changes. /// @@ -61,7 +49,7 @@ public void Adapt(ISortedChangeSet changes, IObservableCollection break; case SortReason.DataChanged: - if (changes.Count - changes.Refreshes > _refreshThreshold) + if (changes.Count - changes.Refreshes > refreshThreshold) { using (collection.SuspendNotifications()) { @@ -111,7 +99,7 @@ private void DoUpdate(ISortedChangeSet updates, IObservableCollec break; case ChangeReason.Update: - if (!_useReplaceForUpdates || update.PreviousIndex != update.CurrentIndex) + if (!useReplaceForUpdates || update.PreviousIndex != update.CurrentIndex) { list.RemoveAt(update.PreviousIndex); list.Insert(update.CurrentIndex, update.Current); diff --git a/src/DynamicData/Cache/Change.cs b/src/DynamicData/Cache/Change.cs index 04cdc5f33..1f1d3a58b 100644 --- a/src/DynamicData/Cache/Change.cs +++ b/src/DynamicData/Cache/Change.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - using DynamicData.Kernel; // ReSharper disable once CheckNamespace @@ -157,10 +154,7 @@ public Change(ChangeReason reason, TKey key, TObject current, Optional } /// - public bool Equals(Change other) - { - return EqualityComparer.Default.Equals(Key, other.Key) && Reason == other.Reason && EqualityComparer.Default.Equals(Current, other.Current) && CurrentIndex == other.CurrentIndex && Previous.Equals(other.Previous) && PreviousIndex == other.PreviousIndex; - } + public bool Equals(Change other) => EqualityComparer.Default.Equals(Key, other.Key) && Reason == other.Reason && EqualityComparer.Default.Equals(Current, other.Current) && CurrentIndex == other.CurrentIndex && Previous.Equals(other.Previous) && PreviousIndex == other.PreviousIndex; /// public override bool Equals(object? obj) @@ -189,8 +183,5 @@ public override int GetHashCode() } /// - public override string ToString() - { - return $"{Reason}, Key: {Key}, Current: {Current}, Previous: {Previous}"; - } + public override string ToString() => $"{Reason}, Key: {Key}, Current: {Current}, Previous: {Previous}"; } diff --git a/src/DynamicData/Cache/ChangeAwareCache.cs b/src/DynamicData/Cache/ChangeAwareCache.cs index f84c553c2..fe1a05103 100644 --- a/src/DynamicData/Cache/ChangeAwareCache.cs +++ b/src/DynamicData/Cache/ChangeAwareCache.cs @@ -2,10 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; - using DynamicData.Cache; using DynamicData.Kernel; @@ -31,8 +27,8 @@ public sealed class ChangeAwareCache : ICache /// public ChangeAwareCache() { - _changes = new ChangeSet(); - _data = new Dictionary(); + _changes = []; + _data = []; } /// @@ -52,7 +48,7 @@ public ChangeAwareCache(int capacity) public ChangeAwareCache(Dictionary data) { _data = data ?? throw new ArgumentNullException(nameof(data)); - _changes = new ChangeSet(); + _changes = []; } /// @@ -94,11 +90,11 @@ public ChangeSet CaptureChanges() { if (_changes.Count == 0) { - return ChangeSet.Empty; + return []; } var copy = _changes; - _changes = new ChangeSet(); + _changes = []; return copy; } @@ -175,10 +171,7 @@ public void Refresh(IEnumerable keys) /// /// Raises an evaluate change for all items in the cache. /// - public void Refresh() - { - _changes.AddRange(_data.Select(t => new Change(ChangeReason.Refresh, t.Key, t.Value))); - } + public void Refresh() => _changes.AddRange(_data.Select(t => new Change(ChangeReason.Refresh, t.Key, t.Value))); /// /// Raises an evaluate change for the specified key. diff --git a/src/DynamicData/Cache/ChangeSet.cs b/src/DynamicData/Cache/ChangeSet.cs index 095609e0c..1a1a961f5 100644 --- a/src/DynamicData/Cache/ChangeSet.cs +++ b/src/DynamicData/Cache/ChangeSet.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; -using System.Linq; - // ReSharper disable once CheckNamespace namespace DynamicData; @@ -63,8 +60,5 @@ public ChangeSet(int capacity) public int Updates => this.Count(c => c.Reason == ChangeReason.Update); /// - public override string ToString() - { - return $"ChangeSet<{typeof(TObject).Name}.{typeof(TKey).Name}>. Count={Count}"; - } + public override string ToString() => $"ChangeSet<{typeof(TObject).Name}.{typeof(TKey).Name}>. Count={Count}"; } diff --git a/src/DynamicData/Cache/DistinctChangeSet.cs b/src/DynamicData/Cache/DistinctChangeSet.cs index 844932797..85df7c997 100644 --- a/src/DynamicData/Cache/DistinctChangeSet.cs +++ b/src/DynamicData/Cache/DistinctChangeSet.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/Cache/GroupChangeSet.cs b/src/DynamicData/Cache/GroupChangeSet.cs index 41f0b2fa8..4340552cd 100644 --- a/src/DynamicData/Cache/GroupChangeSet.cs +++ b/src/DynamicData/Cache/GroupChangeSet.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/Cache/ICache.cs b/src/DynamicData/Cache/ICache.cs index fa0233697..2c0c96c78 100644 --- a/src/DynamicData/Cache/ICache.cs +++ b/src/DynamicData/Cache/ICache.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/Cache/ICacheUpdater.cs b/src/DynamicData/Cache/ICacheUpdater.cs index 14a9f055c..4d8cf8629 100644 --- a/src/DynamicData/Cache/ICacheUpdater.cs +++ b/src/DynamicData/Cache/ICacheUpdater.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/Cache/IChangeSet.cs b/src/DynamicData/Cache/IChangeSet.cs index 1d3e9b775..1c7f3a249 100644 --- a/src/DynamicData/Cache/IChangeSet.cs +++ b/src/DynamicData/Cache/IChangeSet.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/Cache/IConnectableCache.cs b/src/DynamicData/Cache/IConnectableCache.cs index a04bb0d70..e3c6a66be 100644 --- a/src/DynamicData/Cache/IConnectableCache.cs +++ b/src/DynamicData/Cache/IConnectableCache.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - // ReSharper disable CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/Cache/IGrouping.cs b/src/DynamicData/Cache/IGrouping.cs index 2d8b5060b..d62fb68a9 100644 --- a/src/DynamicData/Cache/IGrouping.cs +++ b/src/DynamicData/Cache/IGrouping.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - using DynamicData.Kernel; // ReSharper disable once CheckNamespace diff --git a/src/DynamicData/Cache/IIntermediateCache.cs b/src/DynamicData/Cache/IIntermediateCache.cs index 44046e084..b7278af68 100644 --- a/src/DynamicData/Cache/IIntermediateCache.cs +++ b/src/DynamicData/Cache/IIntermediateCache.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/Cache/IKeyValueCollection.cs b/src/DynamicData/Cache/IKeyValueCollection.cs index a5b0d61a0..e28bd7a36 100644 --- a/src/DynamicData/Cache/IKeyValueCollection.cs +++ b/src/DynamicData/Cache/IKeyValueCollection.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/Cache/IObservableCache.cs b/src/DynamicData/Cache/IObservableCache.cs index a78be532c..1ffb3e18b 100644 --- a/src/DynamicData/Cache/IObservableCache.cs +++ b/src/DynamicData/Cache/IObservableCache.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - using DynamicData.Kernel; // ReSharper disable once CheckNamespace diff --git a/src/DynamicData/Cache/IQuery.cs b/src/DynamicData/Cache/IQuery.cs index ce97a7068..7e9cebbeb 100644 --- a/src/DynamicData/Cache/IQuery.cs +++ b/src/DynamicData/Cache/IQuery.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - using DynamicData.Kernel; // ReSharper disable once CheckNamespace diff --git a/src/DynamicData/Cache/ISourceCache.cs b/src/DynamicData/Cache/ISourceCache.cs index fab6245f0..c2755ffeb 100644 --- a/src/DynamicData/Cache/ISourceCache.cs +++ b/src/DynamicData/Cache/ISourceCache.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/Cache/ISourceUpdater.cs b/src/DynamicData/Cache/ISourceUpdater.cs index 2444115a9..590ea5a34 100644 --- a/src/DynamicData/Cache/ISourceUpdater.cs +++ b/src/DynamicData/Cache/ISourceUpdater.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/Cache/IndexedItem.cs b/src/DynamicData/Cache/IndexedItem.cs index 816ce8358..c695a0693 100644 --- a/src/DynamicData/Cache/IndexedItem.cs +++ b/src/DynamicData/Cache/IndexedItem.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; @@ -13,41 +10,31 @@ namespace DynamicData; /// /// The type of the object. /// The type of the key. -public sealed class IndexedItem : IEquatable> // : IIndexedItem +/// +/// Initializes a new instance of the class. +/// +/// The value. +/// The key. +/// The index. +public sealed class IndexedItem(TObject value, TKey key, int index) : IEquatable> // : IIndexedItem { - /// - /// Initializes a new instance of the class. - /// - /// The value. - /// The key. - /// The index. - public IndexedItem(TObject value, TKey key, int index) - { - Index = index; - Value = value; - Key = key; - } - /// /// Gets the index. /// - public int Index { get; } + public int Index { get; } = index; /// /// Gets the key. /// - public TKey Key { get; } + public TKey Key { get; } = key; /// /// Gets the value. /// - public TObject Value { get; } + public TObject Value { get; } = value; /// - public override bool Equals(object? obj) - { - return obj is IndexedItem key && Equals(key); - } + public override bool Equals(object? obj) => obj is IndexedItem key && Equals(key); /// public override int GetHashCode() diff --git a/src/DynamicData/Cache/IntermediateCache.cs b/src/DynamicData/Cache/IntermediateCache.cs index ebd1e719d..769e38be3 100644 --- a/src/DynamicData/Cache/IntermediateCache.cs +++ b/src/DynamicData/Cache/IntermediateCache.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Diagnostics; using DynamicData.Kernel; diff --git a/src/DynamicData/Cache/Internal/AbstractFilter.cs b/src/DynamicData/Cache/Internal/AbstractFilter.cs index 34db2d95a..5fac8e86d 100644 --- a/src/DynamicData/Cache/Internal/AbstractFilter.cs +++ b/src/DynamicData/Cache/Internal/AbstractFilter.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - using DynamicData.Kernel; namespace DynamicData.Cache.Internal; @@ -67,7 +64,7 @@ public IChangeSet Update(IChangeSet updates) protected abstract IEnumerable> Refresh(IEnumerable> items, Func, Optional>> factory); - private IChangeSet ProcessResult(IEnumerable source) + private ChangeSet ProcessResult(IEnumerable source) { // Have to process one item at a time as an item can be included multiple // times in any batch @@ -137,22 +134,16 @@ private IChangeSet ProcessResult(IEnumerable so return _cache.CaptureChanges(); } - protected readonly struct UpdateWithFilter + /// + /// Initializes a new instance of the struct. + /// Initializes a new instance of the class. + /// + /// If the filter is a match. + /// The change. + protected readonly struct UpdateWithFilter(bool isMatch, Change change) { - /// - /// Initializes a new instance of the struct. - /// Initializes a new instance of the class. - /// - /// If the filter is a match. - /// The change. - public UpdateWithFilter(bool isMatch, Change change) - { - IsMatch = isMatch; - Change = change; - } - - public Change Change { get; } + public Change Change { get; } = change; - public bool IsMatch { get; } + public bool IsMatch { get; } = isMatch; } } diff --git a/src/DynamicData/Cache/Internal/AnonymousQuery.cs b/src/DynamicData/Cache/Internal/AnonymousQuery.cs index 8cbb8c7ed..22a54cc61 100644 --- a/src/DynamicData/Cache/Internal/AnonymousQuery.cs +++ b/src/DynamicData/Cache/Internal/AnonymousQuery.cs @@ -2,19 +2,15 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - using DynamicData.Kernel; namespace DynamicData.Cache.Internal; -internal sealed class AnonymousQuery : IQuery +internal sealed class AnonymousQuery(Cache cache) : IQuery where TObject : notnull where TKey : notnull { - private readonly Cache _cache; - - public AnonymousQuery(Cache cache) => _cache = cache.Clone(); + private readonly Cache _cache = cache.Clone(); public int Count => _cache.Count; diff --git a/src/DynamicData/Cache/Internal/AutoRefresh.cs b/src/DynamicData/Cache/Internal/AutoRefresh.cs index 0d2afec69..51651ff1e 100644 --- a/src/DynamicData/Cache/Internal/AutoRefresh.cs +++ b/src/DynamicData/Cache/Internal/AutoRefresh.cs @@ -2,47 +2,34 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Concurrency; using System.Reactive.Disposables; using System.Reactive.Linq; namespace DynamicData.Cache.Internal; -internal class AutoRefresh +internal class AutoRefresh(IObservable> source, Func> reEvaluator, TimeSpan? buffer = null, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull { - private readonly TimeSpan? _buffer; + private readonly Func> _reEvaluator = reEvaluator ?? throw new ArgumentNullException(nameof(reEvaluator)); - private readonly Func> _reEvaluator; + private readonly IScheduler _scheduler = scheduler ?? Scheduler.Default; - private readonly IScheduler _scheduler; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly IObservable> _source; - - public AutoRefresh(IObservable> source, Func> reEvaluator, TimeSpan? buffer = null, IScheduler? scheduler = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _reEvaluator = reEvaluator ?? throw new ArgumentNullException(nameof(reEvaluator)); - _buffer = buffer; - _scheduler = scheduler ?? Scheduler.Default; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var shared = _source.Publish(); // monitor each item observable and create change - var changes = shared.MergeMany((t, k) => { return _reEvaluator(t, k).Select(_ => new Change(ChangeReason.Refresh, k, t)); }); + var changes = shared.MergeMany((t, k) => _reEvaluator(t, k).Select(_ => new Change(ChangeReason.Refresh, k, t))); // create a change set, either buffered or one item at the time - IObservable> refreshChanges = _buffer is null ? + IObservable> refreshChanges = buffer is null ? changes.Select(c => new ChangeSet(new[] { c })) : - changes.Buffer(_buffer.Value, _scheduler).Where(list => list.Count > 0).Select(items => new ChangeSet(items)); + changes.Buffer(buffer.Value, _scheduler).Where(list => list.Count > 0).Select(items => new ChangeSet(items)); // publish refreshes and underlying changes var locker = new object(); @@ -50,5 +37,4 @@ public IObservable> Run() return new CompositeDisposable(publisher, shared.Connect()); }); - } } diff --git a/src/DynamicData/Cache/Internal/BatchIf.cs b/src/DynamicData/Cache/Internal/BatchIf.cs index 5d14ee9ee..5e907a753 100644 --- a/src/DynamicData/Cache/Internal/BatchIf.cs +++ b/src/DynamicData/Cache/Internal/BatchIf.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive; using System.Reactive.Concurrency; using System.Reactive.Disposables; @@ -12,40 +9,22 @@ namespace DynamicData.Cache.Internal; -internal sealed class BatchIf +internal sealed class BatchIf(IObservable> source, IObservable pauseIfTrueSelector, TimeSpan? timeOut, bool initialPauseState = false, IObservable? intervalTimer = null, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull { - private readonly bool _initialPauseState; + private readonly IObservable _pauseIfTrueSelector = pauseIfTrueSelector ?? throw new ArgumentNullException(nameof(pauseIfTrueSelector)); - private readonly IObservable? _intervalTimer; + private readonly IScheduler _scheduler = scheduler ?? Scheduler.Default; - private readonly IObservable _pauseIfTrueSelector; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly IScheduler _scheduler; - - private readonly IObservable> _source; - - private readonly TimeSpan? _timeOut; - - public BatchIf(IObservable> source, IObservable pauseIfTrueSelector, TimeSpan? timeOut, bool initialPauseState = false, IObservable? intervalTimer = null, IScheduler? scheduler = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _pauseIfTrueSelector = pauseIfTrueSelector ?? throw new ArgumentNullException(nameof(pauseIfTrueSelector)); - _timeOut = timeOut; - _initialPauseState = initialPauseState; - _intervalTimer = intervalTimer; - _scheduler = scheduler ?? Scheduler.Default; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var batchedChanges = new List>(); var locker = new object(); - var paused = _initialPauseState; + var paused = initialPauseState; var timeoutDisposer = new SerialDisposable(); var intervalTimerDisposer = new SerialDisposable(); @@ -66,21 +45,19 @@ void ResumeAction() batchedChanges.Clear(); } - IDisposable IntervalFunction() - { - return _intervalTimer.Synchronize(locker).Finally(() => paused = false).Subscribe( + IDisposable IntervalFunction() => + intervalTimer.Synchronize(locker).Finally(() => paused = false).Subscribe( _ => { paused = false; ResumeAction(); - if (_intervalTimer is not null) + if (intervalTimer is not null) { paused = true; } }); - } - if (_intervalTimer is not null) + if (intervalTimer is not null) { intervalTimerDisposer.Disposable = IntervalFunction(); } @@ -92,7 +69,7 @@ IDisposable IntervalFunction() if (!p) { // pause window has closed, so reset timer - if (_timeOut.HasValue) + if (timeOut.HasValue) { timeoutDisposer.Disposable = Disposable.Empty; } @@ -101,9 +78,9 @@ IDisposable IntervalFunction() } else { - if (_timeOut.HasValue) + if (timeOut.HasValue) { - timeoutDisposer.Disposable = Observable.Timer(_timeOut.Value, _scheduler).Synchronize(locker).Subscribe( + timeoutDisposer.Disposable = Observable.Timer(timeOut.Value, _scheduler).Synchronize(locker).Subscribe( _ => { paused = false; @@ -127,5 +104,4 @@ IDisposable IntervalFunction() return new CompositeDisposable(publisher, pausedHandler, timeoutDisposer, intervalTimerDisposer); }); - } } diff --git a/src/DynamicData/Cache/Internal/Cache.cs b/src/DynamicData/Cache/Internal/Cache.cs index 623b28e75..a52126980 100644 --- a/src/DynamicData/Cache/Internal/Cache.cs +++ b/src/DynamicData/Cache/Internal/Cache.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Diagnostics; using DynamicData.Kernel; @@ -19,10 +17,8 @@ internal class Cache : ICache private readonly Dictionary _data; - public Cache(int capacity = -1) - { - _data = capacity > 1 ? new Dictionary(capacity) : new Dictionary(); - } + public Cache(int capacity = -1) => + _data = capacity > 1 ? new Dictionary(capacity) : []; public Cache(Dictionary data) => _data = data; @@ -66,10 +62,7 @@ public void Clone(IChangeSet changes) } } - public Optional Lookup(TKey key) - { - return _data.Lookup(key); - } + public Optional Lookup(TKey key) => _data.Lookup(key); /// /// Sends a signal for operators to recalculate it's state. @@ -112,11 +105,5 @@ public void Remove(IEnumerable keys) } } - public void Remove(TKey key) - { - if (_data.ContainsKey(key)) - { - _data.Remove(key); - } - } + public void Remove(TKey key) => _data.Remove(key); } diff --git a/src/DynamicData/Cache/Internal/CacheEx.cs b/src/DynamicData/Cache/Internal/CacheEx.cs index 678825ca1..a80f9bd41 100644 --- a/src/DynamicData/Cache/Internal/CacheEx.cs +++ b/src/DynamicData/Cache/Internal/CacheEx.cs @@ -2,10 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; - namespace DynamicData.Cache.Internal; internal static class CacheEx diff --git a/src/DynamicData/Cache/Internal/CacheUpdater.cs b/src/DynamicData/Cache/Internal/CacheUpdater.cs index 3f31705f4..4c05ea3b9 100644 --- a/src/DynamicData/Cache/Internal/CacheUpdater.cs +++ b/src/DynamicData/Cache/Internal/CacheUpdater.cs @@ -2,10 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; - using DynamicData.Kernel; namespace DynamicData.Cache.Internal; @@ -154,25 +150,13 @@ public void AddOrUpdate(IEnumerable> itemsPairs) } } - public void AddOrUpdate(KeyValuePair item) - { - _cache.AddOrUpdate(item.Value, item.Key); - } + public void AddOrUpdate(KeyValuePair item) => _cache.AddOrUpdate(item.Value, item.Key); - public void AddOrUpdate(TObject item, TKey key) - { - _cache.AddOrUpdate(item, key); - } + public void AddOrUpdate(TObject item, TKey key) => _cache.AddOrUpdate(item, key); - public void Clear() - { - _cache.Clear(); - } + public void Clear() => _cache.Clear(); - public void Clone(IChangeSet changes) - { - _cache.Clone(changes); - } + public void Clone(IChangeSet changes) => _cache.Clone(changes); [Obsolete(Constants.EvaluateIsDead)] public void Evaluate(IEnumerable keys) => Refresh(keys); @@ -184,16 +168,10 @@ public void Clone(IChangeSet changes) public void Evaluate(TObject item) => Refresh(item); [Obsolete(Constants.EvaluateIsDead)] - public void Evaluate() - { - Refresh(); - } + public void Evaluate() => Refresh(); [Obsolete(Constants.EvaluateIsDead)] - public void Evaluate(TKey key) - { - Refresh(key); - } + public void Evaluate(TKey key) => Refresh(key); public TKey GetKey(TObject item) { @@ -239,14 +217,11 @@ public Optional Lookup(TObject item) throw new KeySelectorException("A key selector must be specified"); } - TKey key = _keySelector(item); + var key = _keySelector(item); return Lookup(key); } - public void Refresh() - { - _cache.Refresh(); - } + public void Refresh() => _cache.Refresh(); public void Refresh(IEnumerable items) { @@ -307,10 +282,7 @@ public void Refresh(TObject item) _cache.Refresh(key); } - public void Refresh(TKey key) - { - _cache.Refresh(key); - } + public void Refresh(TKey key) => _cache.Refresh(key); public void Remove(IEnumerable items) { @@ -371,10 +343,7 @@ public void Remove(TObject item) _cache.Remove(key); } - public void Remove(TKey key) - { - _cache.Remove(key); - } + public void Remove(TKey key) => _cache.Remove(key); public void Remove(IEnumerable> items) { @@ -400,15 +369,9 @@ public void Remove(IEnumerable> items) } } - public void Remove(KeyValuePair item) - { - Remove(item.Key); - } + public void Remove(KeyValuePair item) => Remove(item.Key); - public void RemoveKey(TKey key) - { - Remove(key); - } + public void RemoveKey(TKey key) => Remove(key); public void RemoveKeys(IEnumerable keys) { @@ -420,8 +383,5 @@ public void RemoveKeys(IEnumerable keys) _cache.Remove(keys); } - public void Update(IChangeSet changes) - { - _cache.Clone(changes); - } + public void Update(IChangeSet changes) => _cache.Clone(changes); } diff --git a/src/DynamicData/Cache/Internal/Cast.cs b/src/DynamicData/Cache/Internal/Cast.cs index 051be77f1..36f64bd19 100644 --- a/src/DynamicData/Cache/Internal/Cast.cs +++ b/src/DynamicData/Cache/Internal/Cast.cs @@ -2,36 +2,25 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Linq; using System.Reactive.Linq; using DynamicData.Kernel; namespace DynamicData.Cache.Internal; -internal class Cast +internal class Cast(IObservable> source, Func converter) where TSource : notnull where TKey : notnull where TDestination : notnull { - private readonly Func _converter; + private readonly Func _converter = converter ?? throw new ArgumentNullException(nameof(converter)); - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public Cast(IObservable> source, Func converter) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _converter = converter ?? throw new ArgumentNullException(nameof(converter)); - } - - public IObservable> Run() - { - return _source.Select( + public IObservable> Run() => _source.Select( changes => { var transformed = changes.ToConcreteType().Select(change => new Change(change.Reason, change.Key, _converter(change.Current), change.Previous.Convert(_converter), change.CurrentIndex, change.PreviousIndex)); return new ChangeSet(transformed); }); - } } diff --git a/src/DynamicData/Cache/Internal/ChangeSetCache.cs b/src/DynamicData/Cache/Internal/ChangeSetCache.cs index 17991f317..4945883eb 100644 --- a/src/DynamicData/Cache/Internal/ChangeSetCache.cs +++ b/src/DynamicData/Cache/Internal/ChangeSetCache.cs @@ -15,10 +15,8 @@ internal class ChangeSetCache where TObject : notnull where TKey : notnull { - public ChangeSetCache(IObservable> source) - { + public ChangeSetCache(IObservable> source) => Source = source.IgnoreSameReferenceUpdate().Do(Cache.Clone); - } public Cache Cache { get; } = new(); diff --git a/src/DynamicData/Cache/Internal/ChangeSetMergeTracker.cs b/src/DynamicData/Cache/Internal/ChangeSetMergeTracker.cs index e5b7aeaba..5a96d6ad5 100644 --- a/src/DynamicData/Cache/Internal/ChangeSetMergeTracker.cs +++ b/src/DynamicData/Cache/Internal/ChangeSetMergeTracker.cs @@ -7,26 +7,15 @@ namespace DynamicData.Cache.Internal; -internal class ChangeSetMergeTracker +internal class ChangeSetMergeTracker(Func>> selectCaches, IComparer? comparer, IEqualityComparer? equalityComparer) where TObject : notnull where TKey : notnull { - private readonly ChangeAwareCache _resultCache; - private readonly Func>> _selectCaches; - private readonly IComparer? _comparer; - private readonly IEqualityComparer? _equalityComparer; - - public ChangeSetMergeTracker(Func>> selectCaches, IComparer? comparer, IEqualityComparer? equalityComparer) - { - _resultCache = new ChangeAwareCache(); - _selectCaches = selectCaches; - _comparer = comparer; - _equalityComparer = equalityComparer; - } + private readonly ChangeAwareCache _resultCache = new(); public void RemoveItems(IEnumerable> items, IObserver> observer) { - var sourceCaches = _selectCaches().ToArray(); + var sourceCaches = selectCaches().ToArray(); // Update the Published Value for each item being removed if (items is IList> list) @@ -50,7 +39,7 @@ public void RemoveItems(IEnumerable> items, IObserve public void RefreshItems(IEnumerable keys, IObserver> observer) { - var sourceCaches = _selectCaches().ToArray(); + var sourceCaches = selectCaches().ToArray(); // Update the Published Value for each item being removed if (keys is IList list) @@ -74,7 +63,7 @@ public void RefreshItems(IEnumerable keys, IObserver changes, IObserver> observer) { - var sourceCaches = _selectCaches().ToArray(); + var sourceCaches = selectCaches().ToArray(); foreach (var change in changes.ToConcreteType()) { @@ -152,7 +141,7 @@ private void OnItemUpdated(ChangeSetCache[] sources, TObject item // If the Previous value is missing or is the same as the current value bool isUpdatingCurrent = !prev.HasValue || CheckEquality(prev.Value, cached.Value); - if (_comparer is null) + if (comparer is null) { // If not using the comparer and the current value is being replaced by a different value if (isUpdatingCurrent && !CheckEquality(item, cached.Value)) @@ -195,7 +184,7 @@ private void OnItemRefreshed(ChangeSetCache[] sources, TObject it // In the sorting case, a refresh requires doing a full update because any change could alter what the best value is // If we don't care about sorting OR if we do care, but re-selecting the best value didn't change anything // AND the current value is the exact one being refreshed, then emit the refresh downstream - if (((_comparer is null) || !UpdateToBestValue(sources, key, cached)) && ReferenceEquals(cached.Value, item)) + if (((comparer is null) || !UpdateToBestValue(sources, key, cached)) && ReferenceEquals(cached.Value, item)) { _resultCache.Refresh(key); } @@ -253,18 +242,18 @@ private Optional LookupBestValue(ChangeSetCache[] source var values = sources.Select(s => s.Cache.Lookup(key)).Where(opt => opt.HasValue); - if (_comparer is not null) + if (comparer is not null) { - values = values.OrderBy(opt => opt.Value, _comparer); + values = values.OrderBy(opt => opt.Value, comparer); } return values.FirstOrDefault(); } private bool CheckEquality(TObject left, TObject right) => - ReferenceEquals(left, right) || (_equalityComparer?.Equals(left, right) ?? false); + ReferenceEquals(left, right) || (equalityComparer?.Equals(left, right) ?? false); // Return true if candidate should replace current as the observed downstream value private bool ShouldReplace(TObject candidate, TObject current) => - !ReferenceEquals(candidate, current) && (_comparer?.Compare(candidate, current) < 0); + !ReferenceEquals(candidate, current) && (comparer?.Compare(candidate, current) < 0); } diff --git a/src/DynamicData/Cache/Internal/Combiner.cs b/src/DynamicData/Cache/Internal/Combiner.cs index 5b9e0d648..0739e17d6 100644 --- a/src/DynamicData/Cache/Internal/Combiner.cs +++ b/src/DynamicData/Cache/Internal/Combiner.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Disposables; using DynamicData.Kernel; @@ -14,7 +11,7 @@ namespace DynamicData.Cache.Internal; /// /// Combines multiple caches using logical operators. /// -internal sealed class Combiner +internal sealed class Combiner(CombineOperator type, Action> updatedCallback) where TObject : notnull where TKey : notnull { @@ -24,16 +21,6 @@ internal sealed class Combiner private readonly IList> _sourceCaches = new List>(); - private readonly CombineOperator _type; - - private readonly Action> _updatedCallback; - - public Combiner(CombineOperator type, Action> updatedCallback) - { - _type = type; - _updatedCallback = updatedCallback; - } - public IDisposable Subscribe(IObservable>[] source) { // subscribe @@ -55,7 +42,7 @@ public IDisposable Subscribe(IObservable>[] source) private bool MatchesConstraint(TKey key) { - switch (_type) + switch (type) { case CombineOperator.And: { @@ -99,7 +86,7 @@ private void Update(Cache cache, IChangeSet update if (notifications.Count != 0) { - _updatedCallback(notifications); + updatedCallback(notifications); } } diff --git a/src/DynamicData/Cache/Internal/DeferUntilLoaded.cs b/src/DynamicData/Cache/Internal/DeferUntilLoaded.cs index 33a9ac26f..bc1608a4e 100644 --- a/src/DynamicData/Cache/Internal/DeferUntilLoaded.cs +++ b/src/DynamicData/Cache/Internal/DeferUntilLoaded.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Linq; using DynamicData.Kernel; @@ -30,8 +29,5 @@ public DeferUntilLoaded(IObservable> source) _result = source.MonitorStatus().Where(status => status == ConnectionStatus.Loaded).Take(1).Select(_ => new ChangeSet()).Concat(source).NotEmpty(); } - public IObservable> Run() - { - return _result; - } + public IObservable> Run() => _result; } diff --git a/src/DynamicData/Cache/Internal/DictionaryExtensions.cs b/src/DynamicData/Cache/Internal/DictionaryExtensions.cs index 597f6872c..3904f4456 100644 --- a/src/DynamicData/Cache/Internal/DictionaryExtensions.cs +++ b/src/DynamicData/Cache/Internal/DictionaryExtensions.cs @@ -2,18 +2,15 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; -using System.Linq; - namespace DynamicData.Cache.Internal; internal static class DictionaryExtensions { internal static IEnumerable GetOrEmpty(this IDictionary> dict, TDictKey key) { - if (dict.ContainsKey(key)) + if (dict.TryGetValue(key, out var value)) { - return dict[key]; + return value; } return Enumerable.Empty(); diff --git a/src/DynamicData/Cache/Internal/DisposeMany.cs b/src/DynamicData/Cache/Internal/DisposeMany.cs index 2b0091c58..4f8d57ff4 100644 --- a/src/DynamicData/Cache/Internal/DisposeMany.cs +++ b/src/DynamicData/Cache/Internal/DisposeMany.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -10,23 +9,15 @@ namespace DynamicData.Cache.Internal; -internal sealed class DisposeMany +internal sealed class DisposeMany(IObservable> source, Action removeAction) where TObject : notnull where TKey : notnull { - private readonly Action _removeAction; + private readonly Action _removeAction = removeAction ?? throw new ArgumentNullException(nameof(removeAction)); - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public DisposeMany(IObservable> source, Action removeAction) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _removeAction = removeAction ?? throw new ArgumentNullException(nameof(removeAction)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -45,7 +36,6 @@ public IObservable> Run() } }); }); - } private void RegisterForRemoval(IChangeSet changes, Cache cache) { diff --git a/src/DynamicData/Cache/Internal/DistinctCalculator.cs b/src/DynamicData/Cache/Internal/DistinctCalculator.cs index f387a33aa..61ae45a06 100644 --- a/src/DynamicData/Cache/Internal/DistinctCalculator.cs +++ b/src/DynamicData/Cache/Internal/DistinctCalculator.cs @@ -2,15 +2,13 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Linq; using DynamicData.Kernel; namespace DynamicData.Cache.Internal; -internal sealed class DistinctCalculator +internal sealed class DistinctCalculator(IObservable> source, Func valueSelector) where TObject : notnull where TKey : notnull where TValue : notnull @@ -18,23 +16,11 @@ internal sealed class DistinctCalculator private readonly IDictionary _itemCache = new Dictionary(); private readonly IDictionary _keyCounters = new Dictionary(); - - private readonly IObservable> _source; - private readonly IDictionary _valueCounters = new Dictionary(); - private readonly Func _valueSelector; + private readonly Func _valueSelector = valueSelector ?? throw new ArgumentNullException(nameof(valueSelector)); - public DistinctCalculator(IObservable> source, Func valueSelector) - { - _source = source; - _valueSelector = valueSelector ?? throw new ArgumentNullException(nameof(valueSelector)); - } - - public IObservable> Run() - { - return _source.Select(Calculate).Where(updates => updates.Count != 0); - } + public IObservable> Run() => source.Select(Calculate).Where(updates => updates.Count != 0); private DistinctChangeSet Calculate(IChangeSet changes) { diff --git a/src/DynamicData/Cache/Internal/DynamicCombiner.cs b/src/DynamicData/Cache/Internal/DynamicCombiner.cs index 615a7d080..e289b80ee 100644 --- a/src/DynamicData/Cache/Internal/DynamicCombiner.cs +++ b/src/DynamicData/Cache/Internal/DynamicCombiner.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -12,23 +9,13 @@ namespace DynamicData.Cache.Internal; -internal sealed class DynamicCombiner +internal sealed class DynamicCombiner(IObservableList>> source, CombineOperator type) where TObject : notnull where TKey : notnull { - private readonly IObservableList>> _source; + private readonly IObservableList>> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly CombineOperator _type; - - public DynamicCombiner(IObservableList>> source, CombineOperator type) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _type = type; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -63,7 +50,7 @@ public IObservable> Run() // Remove items if required ProcessChanges(resultCache, sourceLists.Items.AsArray(), mc.Cache.KeyValues); - if (_type == CombineOperator.And || _type == CombineOperator.Except) + if (type == CombineOperator.And || type == CombineOperator.Except) { var itemsToCheck = sourceLists.Items.SelectMany(mc2 => mc2.Cache.KeyValues); ProcessChanges(resultCache, sourceLists.Items.AsArray(), itemsToCheck); @@ -82,7 +69,7 @@ public IObservable> Run() { ProcessChanges(resultCache, sourceLists.Items.AsArray(), mc.Current.Cache.KeyValues); - if (_type == CombineOperator.And || _type == CombineOperator.Except) + if (type == CombineOperator.And || type == CombineOperator.Except) { ProcessChanges(resultCache, sourceLists.Items.AsArray(), resultCache.KeyValues.ToArray()); } @@ -96,7 +83,6 @@ public IObservable> Run() return new CompositeDisposable(sourceLists, allChanges, removedItem, sourceChanged, sharedLists.Connect()); }); - } private bool MatchesConstraint(MergeContainer[] sources, TKey key) { @@ -105,7 +91,7 @@ private bool MatchesConstraint(MergeContainer[] sources, TKey key) return false; } - switch (_type) + switch (type) { case CombineOperator.And: { @@ -198,9 +184,6 @@ public MergeContainer(IObservable> source) public IObservable> Source { get; } - private void Clone(IChangeSet changes) - { - Cache.Clone(changes); - } + private void Clone(IChangeSet changes) => Cache.Clone(changes); } } diff --git a/src/DynamicData/Cache/Internal/DynamicFilter.cs b/src/DynamicData/Cache/Internal/DynamicFilter.cs index 1a235d30f..2028962a4 100644 --- a/src/DynamicData/Cache/Internal/DynamicFilter.cs +++ b/src/DynamicData/Cache/Internal/DynamicFilter.cs @@ -2,35 +2,20 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive; using System.Reactive.Disposables; using System.Reactive.Linq; namespace DynamicData.Cache.Internal; -internal class DynamicFilter +internal class DynamicFilter(IObservable> source, IObservable> predicateChanged, IObservable? refilterObservable = null, bool suppressEmptyChangeSets = true) where TObject : notnull where TKey : notnull { - private readonly IObservable> _predicateChanged; + private readonly IObservable> _predicateChanged = predicateChanged ?? throw new ArgumentNullException(nameof(predicateChanged)); + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly IObservable? _refilterObservable; - private readonly bool _suppressEmptyChangeSets; - - private readonly IObservable> _source; - - public DynamicFilter(IObservable> source, IObservable> predicateChanged, IObservable? refilterObservable = null, bool suppressEmptyChangeSets = true) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _predicateChanged = predicateChanged ?? throw new ArgumentNullException(nameof(predicateChanged)); - _refilterObservable = refilterObservable; - _suppressEmptyChangeSets = suppressEmptyChangeSets; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var allData = new Cache(); @@ -63,16 +48,13 @@ public IObservable> Run() }); var source = refresher.Merge(dataChanged); - if (_suppressEmptyChangeSets) + if (suppressEmptyChangeSets) source = source.NotEmpty(); return source.SubscribeSafe(observer); }); - } - private IObservable> LatestPredicateObservable() - { - return Observable.Create>( + private IObservable> LatestPredicateObservable() => Observable.Create>( observable => { Func latest = _ => false; @@ -86,9 +68,8 @@ private IObservable> LatestPredicateObservable() observable.OnNext(latest); }); - var reapplier = _refilterObservable is null ? Disposable.Empty : _refilterObservable.Subscribe(_ => observable.OnNext(latest)); + var reapplier = refilterObservable is null ? Disposable.Empty : refilterObservable.Subscribe(_ => observable.OnNext(latest)); return new CompositeDisposable(predicateChanged, reapplier); }); - } } diff --git a/src/DynamicData/Cache/Internal/EditDiff.cs b/src/DynamicData/Cache/Internal/EditDiff.cs index 0d14974b7..83ec01b51 100644 --- a/src/DynamicData/Cache/Internal/EditDiff.cs +++ b/src/DynamicData/Cache/Internal/EditDiff.cs @@ -6,25 +6,17 @@ namespace DynamicData.Cache.Internal; -internal class EditDiff +internal class EditDiff(ISourceCache source, Func areEqual) where TObject : notnull where TKey : notnull { - private readonly Func _areEqual; + private readonly Func _areEqual = areEqual ?? throw new ArgumentNullException(nameof(areEqual)); private readonly IEqualityComparer> _keyComparer = new KeyComparer(); - private readonly ISourceCache _source; + private readonly ISourceCache _source = source ?? throw new ArgumentNullException(nameof(source)); - public EditDiff(ISourceCache source, Func areEqual) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _areEqual = areEqual ?? throw new ArgumentNullException(nameof(areEqual)); - } - - public void Edit(IEnumerable items) - { - _source.Edit( + public void Edit(IEnumerable items) => _source.Edit( innerCache => { var originalItems = innerCache.KeyValues.AsArray(); @@ -39,5 +31,4 @@ public void Edit(IEnumerable items) innerCache.Remove(removes.Select(kvp => kvp.Key)); innerCache.AddOrUpdate(adds.Union(intersect)); }); - } } diff --git a/src/DynamicData/Cache/Internal/EditDiffChangeSet.cs b/src/DynamicData/Cache/Internal/EditDiffChangeSet.cs index 3f7654c12..d0570b2ec 100644 --- a/src/DynamicData/Cache/Internal/EditDiffChangeSet.cs +++ b/src/DynamicData/Cache/Internal/EditDiffChangeSet.cs @@ -2,28 +2,19 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Reactive.Disposables; using System.Reactive.Linq; -using DynamicData.Kernel; namespace DynamicData.Cache.Internal; -internal sealed class EditDiffChangeSet +internal sealed class EditDiffChangeSet(IObservable> source, Func keySelector, IEqualityComparer? equalityComparer) where TObject : notnull where TKey : notnull { - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly IEqualityComparer _equalityComparer; + private readonly IEqualityComparer _equalityComparer = equalityComparer ?? EqualityComparer.Default; - private readonly Func _keySelector; - - public EditDiffChangeSet(IObservable> source, Func keySelector, IEqualityComparer? equalityComparer) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _keySelector = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); - _equalityComparer = equalityComparer ?? EqualityComparer.Default; - } + private readonly Func _keySelector = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); public IObservable> Run() => ObservableChangeSet.Create( diff --git a/src/DynamicData/Cache/Internal/EditDiffChangeSetOptional.cs b/src/DynamicData/Cache/Internal/EditDiffChangeSetOptional.cs index 6b59f11d2..30ca56dae 100644 --- a/src/DynamicData/Cache/Internal/EditDiffChangeSetOptional.cs +++ b/src/DynamicData/Cache/Internal/EditDiffChangeSetOptional.cs @@ -7,54 +7,44 @@ namespace DynamicData.Cache.Internal; -internal sealed class EditDiffChangeSetOptional +internal sealed class EditDiffChangeSetOptional(IObservable> source, Func keySelector, IEqualityComparer? equalityComparer) where TObject : notnull where TKey : notnull { - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly IEqualityComparer _equalityComparer; + private readonly IEqualityComparer _equalityComparer = equalityComparer ?? EqualityComparer.Default; - private readonly Func _keySelector; + private readonly Func _keySelector = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); - public EditDiffChangeSetOptional(IObservable> source, Func keySelector, IEqualityComparer? equalityComparer) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _keySelector = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); - _equalityComparer = equalityComparer ?? EqualityComparer.Default; - } + public IObservable> Run() => Observable.Create>(observer => + { + var previous = Optional.None(); - public IObservable> Run() - { - return Observable.Create>(observer => - { - var previous = Optional.None(); + return _source.Synchronize().Subscribe( + nextValue => + { + var current = nextValue.Convert(val => new ValueContainer(val, _keySelector(val))); - return _source.Synchronize().Subscribe( - nextValue => - { - var current = nextValue.Convert(val => new ValueContainer(val, _keySelector(val))); + // Determine the changes + var changes = (previous.HasValue, current.HasValue) switch + { + (true, true) => CreateUpdateChanges(previous.Value, current.Value), + (false, true) => new[] { new Change(ChangeReason.Add, current.Value.Key, current.Value.Object) }, + (true, false) => new[] { new Change(ChangeReason.Remove, previous.Value.Key, previous.Value.Object) }, + (false, false) => Array.Empty>(), + }; - // Determine the changes - var changes = (previous.HasValue, current.HasValue) switch - { - (true, true) => CreateUpdateChanges(previous.Value, current.Value), - (false, true) => new[] { new Change(ChangeReason.Add, current.Value.Key, current.Value.Object) }, - (true, false) => new[] { new Change(ChangeReason.Remove, previous.Value.Key, previous.Value.Object) }, - (false, false) => Array.Empty>(), - }; + // Save the value for the next round + previous = current; - // Save the value for the next round - previous = current; - - // If there are changes, emit as a ChangeSet - if (changes.Length > 0) - { - observer.OnNext(new ChangeSet(changes)); - } - }, observer.OnError, observer.OnCompleted); - }); - } + // If there are changes, emit as a ChangeSet + if (changes.Length > 0) + { + observer.OnNext(new ChangeSet(changes)); + } + }, observer.OnError, observer.OnCompleted); + }); private Change[] CreateUpdateChanges(in ValueContainer prev, in ValueContainer curr) { @@ -77,16 +67,10 @@ private Change[] CreateUpdateChanges(in ValueContainer prev, in V }; } - private readonly struct ValueContainer + private readonly struct ValueContainer(TObject obj, TKey key) { - public ValueContainer(TObject obj, TKey key) - { - Object = obj; - Key = key; - } - - public TObject Object { get; } + public TObject Object { get; } = obj; - public TKey Key { get; } + public TKey Key { get; } = key; } } diff --git a/src/DynamicData/Cache/Internal/ExpirableItem.cs b/src/DynamicData/Cache/Internal/ExpirableItem.cs index a961b7602..91674a05e 100644 --- a/src/DynamicData/Cache/Internal/ExpirableItem.cs +++ b/src/DynamicData/Cache/Internal/ExpirableItem.cs @@ -2,28 +2,17 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - namespace DynamicData.Cache.Internal; -internal readonly struct ExpirableItem : IEquatable> +internal readonly struct ExpirableItem(TObject value, TKey key, DateTime dateTime, long index = 0) : IEquatable> { - public ExpirableItem(TObject value, TKey key, DateTime dateTime, long index = 0) - { - Value = value; - Key = key; - ExpireAt = dateTime; - Index = index; - } + public TObject Value { get; } = value; - public TObject Value { get; } + public TKey Key { get; } = key; - public TKey Key { get; } + public DateTime ExpireAt { get; } = dateTime; - public DateTime ExpireAt { get; } - - public long Index { get; } + public long Index { get; } = index; public static bool operator ==(ExpirableItem left, ExpirableItem right) { @@ -36,16 +25,10 @@ public ExpirableItem(TObject value, TKey key, DateTime dateTime, long index = 0) } /// - public bool Equals(ExpirableItem other) - { - return EqualityComparer.Default.Equals(Key, other.Key) && ExpireAt.Equals(other.ExpireAt); - } + public bool Equals(ExpirableItem other) => EqualityComparer.Default.Equals(Key, other.Key) && ExpireAt.Equals(other.ExpireAt); /// - public override bool Equals(object? obj) - { - return obj is ExpirableItem value && Equals(value); - } + public override bool Equals(object? obj) => obj is ExpirableItem value && Equals(value); /// public override int GetHashCode() @@ -56,8 +39,5 @@ public override int GetHashCode() } } - public override string ToString() - { - return $"Key: {Key}, Expire At: {ExpireAt}"; - } + public override string ToString() => $"Key: {Key}, Expire At: {ExpireAt}"; } diff --git a/src/DynamicData/Cache/Internal/FilterEx.cs b/src/DynamicData/Cache/Internal/FilterEx.cs index c7f2bc164..255a17a5d 100644 --- a/src/DynamicData/Cache/Internal/FilterEx.cs +++ b/src/DynamicData/Cache/Internal/FilterEx.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - namespace DynamicData.Cache.Internal; internal static class FilterEx diff --git a/src/DynamicData/Cache/Internal/FilterOnObservable.cs b/src/DynamicData/Cache/Internal/FilterOnObservable.cs index ee18b7c06..0bde56f66 100644 --- a/src/DynamicData/Cache/Internal/FilterOnObservable.cs +++ b/src/DynamicData/Cache/Internal/FilterOnObservable.cs @@ -7,30 +7,17 @@ namespace DynamicData.Cache.Internal; -internal class FilterOnObservable +internal class FilterOnObservable(IObservable> source, Func> filterFactory, TimeSpan? buffer = null, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull { - private readonly Func> _filterFactory; - private readonly IObservable> _source; - private readonly TimeSpan? _buffer; - private readonly IScheduler? _scheduler; + private readonly Func> _filterFactory = filterFactory ?? throw new ArgumentNullException(nameof(filterFactory)); + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public FilterOnObservable(IObservable> source, Func> filterFactory, TimeSpan? buffer = null, IScheduler? scheduler = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _filterFactory = filterFactory ?? throw new ArgumentNullException(nameof(filterFactory)); - _buffer = buffer; - _scheduler = scheduler; - } - - public IObservable> Run() - { - return _source.Transform((val, key) => new FilterProxy(val, _filterFactory(val, key))) - .AutoRefreshOnObservable(proxy => proxy.FilterObservable, _buffer, _scheduler) + public IObservable> Run() => _source.Transform((val, key) => new FilterProxy(val, _filterFactory(val, key))) + .AutoRefreshOnObservable(proxy => proxy.FilterObservable, buffer, scheduler) .Filter(proxy => proxy.PassesFilter) .Transform(proxy => proxy.Value); - } private class FilterProxy { diff --git a/src/DynamicData/Cache/Internal/FilterOnProperty.cs b/src/DynamicData/Cache/Internal/FilterOnProperty.cs index d7f905bcf..303cfe8d7 100644 --- a/src/DynamicData/Cache/Internal/FilterOnProperty.cs +++ b/src/DynamicData/Cache/Internal/FilterOnProperty.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.ComponentModel; using System.Linq.Expressions; using System.Reactive.Concurrency; @@ -10,31 +9,9 @@ namespace DynamicData.Cache.Internal; [Obsolete("Use AutoRefresh(), followed by Filter() instead")] -internal class FilterOnProperty +internal class FilterOnProperty(IObservable> source, Expression> propertySelector, Func predicate, TimeSpan? throttle = null, IScheduler? scheduler = null) where TObject : INotifyPropertyChanged where TKey : notnull { - private readonly Func _predicate; - - private readonly Expression> _propertySelector; - - private readonly IScheduler? _scheduler; - - private readonly IObservable> _source; - - private readonly TimeSpan? _throttle; - - public FilterOnProperty(IObservable> source, Expression> propertySelector, Func predicate, TimeSpan? throttle = null, IScheduler? scheduler = null) - { - _source = source; - _propertySelector = propertySelector; - _predicate = predicate; - _throttle = throttle; - _scheduler = scheduler; - } - - public IObservable> Run() - { - return _source.AutoRefresh(_propertySelector, propertyChangeThrottle: _throttle, scheduler: _scheduler).Filter(_predicate); - } + public IObservable> Run() => source.AutoRefresh(propertySelector, propertyChangeThrottle: throttle, scheduler: scheduler).Filter(predicate); } diff --git a/src/DynamicData/Cache/Internal/FilteredIndexCalculator.cs b/src/DynamicData/Cache/Internal/FilteredIndexCalculator.cs index 18f121585..8a1a4aa4a 100644 --- a/src/DynamicData/Cache/Internal/FilteredIndexCalculator.cs +++ b/src/DynamicData/Cache/Internal/FilteredIndexCalculator.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; -using System.Linq; - using DynamicData.Kernel; namespace DynamicData.Cache.Internal; diff --git a/src/DynamicData/Cache/Internal/FinallySafe.cs b/src/DynamicData/Cache/Internal/FinallySafe.cs index e49cb31c4..fb98e1d3c 100644 --- a/src/DynamicData/Cache/Internal/FinallySafe.cs +++ b/src/DynamicData/Cache/Internal/FinallySafe.cs @@ -2,27 +2,18 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; namespace DynamicData.Cache.Internal; -internal class FinallySafe +internal class FinallySafe(IObservable source, Action finallyAction) { - private readonly Action _finallyAction; + private readonly Action _finallyAction = finallyAction ?? throw new ArgumentNullException(nameof(finallyAction)); - private readonly IObservable _source; + private readonly IObservable _source = source ?? throw new ArgumentNullException(nameof(source)); - public FinallySafe(IObservable source, Action finallyAction) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _finallyAction = finallyAction ?? throw new ArgumentNullException(nameof(finallyAction)); - } - - public IObservable Run() - { - return Observable.Create( + public IObservable Run() => Observable.Create( o => { var finallyOnce = Disposable.Create(_finallyAction); @@ -54,5 +45,4 @@ public IObservable Run() return new CompositeDisposable(subscription, finallyOnce); }); - } } diff --git a/src/DynamicData/Cache/Internal/FullJoin.cs b/src/DynamicData/Cache/Internal/FullJoin.cs index b361f075a..f2a89475d 100644 --- a/src/DynamicData/Cache/Internal/FullJoin.cs +++ b/src/DynamicData/Cache/Internal/FullJoin.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -10,32 +9,22 @@ namespace DynamicData.Cache.Internal; -internal class FullJoin +internal class FullJoin(IObservable> left, IObservable> right, Func rightKeySelector, Func, Optional, TDestination> resultSelector) where TLeft : notnull where TLeftKey : notnull where TRight : notnull where TRightKey : notnull where TDestination : notnull { - private readonly IObservable> _left; + private readonly IObservable> _left = left ?? throw new ArgumentNullException(nameof(left)); - private readonly Func, Optional, TDestination> _resultSelector; + private readonly Func, Optional, TDestination> _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - private readonly IObservable> _right; + private readonly IObservable> _right = right ?? throw new ArgumentNullException(nameof(right)); - private readonly Func _rightKeySelector; + private readonly Func _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); - public FullJoin(IObservable> left, IObservable> right, Func rightKeySelector, Func, Optional, TDestination> resultSelector) - { - _left = left ?? throw new ArgumentNullException(nameof(left)); - _right = right ?? throw new ArgumentNullException(nameof(right)); - _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); - _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -131,5 +120,4 @@ public IObservable> Run() return new CompositeDisposable(leftLoader.Merge(rightLoader).SubscribeSafe(observer), leftCache, rightCache); }); - } } diff --git a/src/DynamicData/Cache/Internal/FullJoinMany.cs b/src/DynamicData/Cache/Internal/FullJoinMany.cs index 950fcf342..005f09bc5 100644 --- a/src/DynamicData/Cache/Internal/FullJoinMany.cs +++ b/src/DynamicData/Cache/Internal/FullJoinMany.cs @@ -2,34 +2,24 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - using DynamicData.Kernel; namespace DynamicData.Cache.Internal; -internal class FullJoinMany +internal class FullJoinMany(IObservable> left, IObservable> right, Func rightKeySelector, Func, IGrouping, TDestination> resultSelector) where TLeft : notnull where TLeftKey : notnull where TRight : notnull where TRightKey : notnull where TDestination : notnull { - private readonly IObservable> _left; - - private readonly Func, IGrouping, TDestination> _resultSelector; + private readonly IObservable> _left = left ?? throw new ArgumentNullException(nameof(left)); - private readonly IObservable> _right; + private readonly Func, IGrouping, TDestination> _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - private readonly Func _rightKeySelector; + private readonly IObservable> _right = right ?? throw new ArgumentNullException(nameof(right)); - public FullJoinMany(IObservable> left, IObservable> right, Func rightKeySelector, Func, IGrouping, TDestination> resultSelector) - { - _left = left ?? throw new ArgumentNullException(nameof(left)); - _right = right ?? throw new ArgumentNullException(nameof(right)); - _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); - _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - } + private readonly Func _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); public IObservable> Run() { diff --git a/src/DynamicData/Cache/Internal/GroupOn.cs b/src/DynamicData/Cache/Internal/GroupOn.cs index 1f9d89bcd..76e9221f8 100644 --- a/src/DynamicData/Cache/Internal/GroupOn.cs +++ b/src/DynamicData/Cache/Internal/GroupOn.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -13,27 +10,18 @@ namespace DynamicData.Cache.Internal; -internal sealed class GroupOn +internal sealed class GroupOn(IObservable> source, Func groupSelectorKey, IObservable? regrouper) where TObject : notnull where TKey : notnull where TGroupKey : notnull { - private readonly Func _groupSelectorKey; + private readonly Func _groupSelectorKey = groupSelectorKey ?? throw new ArgumentNullException(nameof(groupSelectorKey)); - private readonly IObservable _regrouper; + private readonly IObservable _regrouper = regrouper ?? Observable.Never(); - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public GroupOn(IObservable> source, Func groupSelectorKey, IObservable? regrouper) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _groupSelectorKey = groupSelectorKey ?? throw new ArgumentNullException(nameof(groupSelectorKey)); - _regrouper = regrouper ?? Observable.Never(); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -57,19 +45,12 @@ public IObservable> Run() subscriber.Dispose(); }); }); - } - private sealed class Grouper + private sealed class Grouper(Func groupSelectorKey) { private readonly Dictionary> _groupCache = new(); - private readonly Func _groupSelectorKey; private readonly Dictionary _itemCache = new(); - public Grouper(Func groupSelectorKey) - { - _groupSelectorKey = groupSelectorKey; - } - public IGroupChangeSet Regroup() { // re-evaluate all items in the group @@ -77,10 +58,7 @@ public IGroupChangeSet Regroup() return HandleUpdates(new ChangeSet(items), true); } - public IGroupChangeSet Update(IChangeSet updates) - { - return HandleUpdates(updates); - } + public IGroupChangeSet Update(IChangeSet updates) => HandleUpdates(updates); private (ManagedGroup group, bool wasCreated) GetCache(TGroupKey key) { @@ -98,7 +76,7 @@ private GroupChangeSet HandleUpdates(IEnumerable, TGroupKey>>(); // Group all items - var grouped = changes.Select(u => new ChangeWithGroup(u, _groupSelectorKey)).GroupBy(c => c.GroupKey); + var grouped = changes.Select(u => new ChangeWithGroup(u, groupSelectorKey)).GroupBy(c => c.GroupKey); // 1. iterate and maintain child caches (_groupCache) // 2. maintain which group each item belongs to (_itemCache) @@ -234,23 +212,15 @@ private GroupChangeSet HandleUpdates(IEnumerable(result); } - private readonly struct ChangeWithGroup : IEquatable + private readonly struct ChangeWithGroup(Change change, Func keySelector) : IEquatable { - public ChangeWithGroup(Change change, Func keySelector) - { - GroupKey = keySelector(change.Current); - Item = change.Current; - Key = change.Key; - Reason = change.Reason; - } - - public TObject Item { get; } + public TObject Item { get; } = change.Current; - public TKey Key { get; } + public TKey Key { get; } = change.Key; - public TGroupKey GroupKey { get; } + public TGroupKey GroupKey { get; } = keySelector(change.Current); - public ChangeReason Reason { get; } + public ChangeReason Reason { get; } = change.Reason; public static bool operator ==(ChangeWithGroup left, ChangeWithGroup right) { @@ -262,20 +232,11 @@ public ChangeWithGroup(Change change, Func ke return !left.Equals(right); } - public bool Equals(ChangeWithGroup other) - { - return EqualityComparer.Default.Equals(Key, other.Key); - } + public bool Equals(ChangeWithGroup other) => EqualityComparer.Default.Equals(Key, other.Key); - public override bool Equals(object? obj) - { - return obj is ChangeWithGroup group && Equals(group); - } + public override bool Equals(object? obj) => obj is ChangeWithGroup group && Equals(group); - public override int GetHashCode() - { - return Key.GetHashCode(); - } + public override int GetHashCode() => Key.GetHashCode(); public override string ToString() => $"Key: {Key}, GroupKey: {GroupKey}, Item: {Item}"; } diff --git a/src/DynamicData/Cache/Internal/GroupOnImmutable.cs b/src/DynamicData/Cache/Internal/GroupOnImmutable.cs index 652d360ed..891a938f1 100644 --- a/src/DynamicData/Cache/Internal/GroupOnImmutable.cs +++ b/src/DynamicData/Cache/Internal/GroupOnImmutable.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive; using System.Reactive.Linq; @@ -12,27 +9,18 @@ namespace DynamicData.Cache.Internal; -internal sealed class GroupOnImmutable +internal sealed class GroupOnImmutable(IObservable> source, Func groupSelectorKey, IObservable? regrouper) where TObject : notnull where TKey : notnull where TGroupKey : notnull { - private readonly Func _groupSelectorKey; + private readonly Func _groupSelectorKey = groupSelectorKey ?? throw new ArgumentNullException(nameof(groupSelectorKey)); - private readonly IObservable _regrouper; + private readonly IObservable _regrouper = regrouper ?? Observable.Never(); - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public GroupOnImmutable(IObservable> source, Func groupSelectorKey, IObservable? regrouper) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _groupSelectorKey = groupSelectorKey ?? throw new ArgumentNullException(nameof(groupSelectorKey)); - _regrouper = regrouper ?? Observable.Never(); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -44,21 +32,12 @@ public IObservable> Run() return groups.Merge(regroup).SubscribeSafe(observer); }); - } - private sealed class Grouper + private sealed class Grouper(Func groupSelectorKey) { private readonly IDictionary _allGroupings = new Dictionary(); - - private readonly Func _groupSelectorKey; - private readonly IDictionary _itemCache = new Dictionary(); - public Grouper(Func groupSelectorKey) - { - _groupSelectorKey = groupSelectorKey; - } - public IImmutableGroupChangeSet Regroup() { // re-evaluate all items in the group @@ -66,10 +45,7 @@ public IImmutableGroupChangeSet Regroup() return HandleUpdates(new ChangeSet(items)); } - public IImmutableGroupChangeSet Update(IChangeSet updates) - { - return HandleUpdates(updates); - } + public IImmutableGroupChangeSet Update(IChangeSet updates) => HandleUpdates(updates); private static Exception CreateMissingKeyException(ChangeReason reason, TKey key) { @@ -77,15 +53,9 @@ private static Exception CreateMissingKeyException(ChangeReason reason, TKey key return new MissingKeyException(message); } - private static IGrouping GetGroupState(GroupCache grouping) - { - return new ImmutableGroup(grouping.Key, grouping.Cache); - } + private static IGrouping GetGroupState(GroupCache grouping) => new ImmutableGroup(grouping.Key, grouping.Cache); - private static IGrouping GetGroupState(TGroupKey key, ICache cache) - { - return new ImmutableGroup(key, cache); - } + private static IGrouping GetGroupState(TGroupKey key, ICache cache) => new ImmutableGroup(key, cache); private IImmutableGroupChangeSet CreateChangeSet(IDictionary> initialGroupState) { @@ -137,7 +107,7 @@ private IImmutableGroupChangeSet HandleUpdates(IEnumer var initialStateOfGroups = new Dictionary>(); // 1. Group all items - var grouped = changes.Select(u => new ChangeWithGroup(u, _groupSelectorKey)).GroupBy(c => c.GroupKey); + var grouped = changes.Select(u => new ChangeWithGroup(u, groupSelectorKey)).GroupBy(c => c.GroupKey); // 2. iterate and maintain child caches grouped.ForEach( @@ -235,9 +205,7 @@ private IImmutableGroupChangeSet HandleUpdates(IEnumer return CreateChangeSet(initialStateOfGroups); } - private void RemoveFromOldGroup(IDictionary> groupState, TGroupKey groupKey, TKey currentKey) - { - _allGroupings.Lookup(groupKey).IfHasValue( + private void RemoveFromOldGroup(IDictionary> groupState, TGroupKey groupKey, TKey currentKey) => _allGroupings.Lookup(groupKey).IfHasValue( g => { if (!groupState.ContainsKey(g.Key)) @@ -247,25 +215,16 @@ private void RemoveFromOldGroup(IDictionary + private readonly struct ChangeWithGroup(Change change, Func keySelector) : IEquatable { - public ChangeWithGroup(Change change, Func keySelector) - { - GroupKey = keySelector(change.Current); - Item = change.Current; - Key = change.Key; - Reason = change.Reason; - } + public TObject Item { get; } = change.Current; - public TObject Item { get; } + public TKey Key { get; } = change.Key; - public TKey Key { get; } + public TGroupKey GroupKey { get; } = keySelector(change.Current); - public TGroupKey GroupKey { get; } - - public ChangeReason Reason { get; } + public ChangeReason Reason { get; } = change.Reason; public static bool operator ==(ChangeWithGroup left, ChangeWithGroup right) { @@ -277,38 +236,20 @@ public ChangeWithGroup(Change change, Func ke return !left.Equals(right); } - public bool Equals(ChangeWithGroup other) - { - return Key.Equals(other.Key); - } + public bool Equals(ChangeWithGroup other) => Key.Equals(other.Key); - public override bool Equals(object? obj) - { - return obj is ChangeWithGroup changeGroup && Equals(changeGroup); - } + public override bool Equals(object? obj) => obj is ChangeWithGroup changeGroup && Equals(changeGroup); - public override int GetHashCode() - { - return Key.GetHashCode(); - } + public override int GetHashCode() => Key.GetHashCode(); - public override string ToString() - { - return $"Key: {Key}, GroupKey: {GroupKey}, Item: {Item}"; - } + public override string ToString() => $"Key: {Key}, GroupKey: {GroupKey}, Item: {Item}"; } - private class GroupCache + private class GroupCache(TGroupKey key) { - public GroupCache(TGroupKey key) - { - Key = key; - Cache = new Cache(); - } - - public Cache Cache { get; } + public Cache Cache { get; } = new Cache(); - public TGroupKey Key { get; } + public TGroupKey Key { get; } = key; } } } diff --git a/src/DynamicData/Cache/Internal/GroupOnProperty.cs b/src/DynamicData/Cache/Internal/GroupOnProperty.cs index a33143004..094ef7df0 100644 --- a/src/DynamicData/Cache/Internal/GroupOnProperty.cs +++ b/src/DynamicData/Cache/Internal/GroupOnProperty.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.ComponentModel; using System.Linq.Expressions; using System.Reactive.Concurrency; @@ -12,46 +11,27 @@ namespace DynamicData.Cache.Internal; -internal class GroupOnProperty +internal class GroupOnProperty(IObservable> source, Expression> groupSelectorKey, TimeSpan? throttle = null, IScheduler? scheduler = null) where TObject : INotifyPropertyChanged where TKey : notnull where TGroup : notnull { - private readonly Func _groupSelector; + private readonly Func _groupSelector = groupSelectorKey.Compile(); + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly Expression> _propertySelector; - - private readonly IScheduler? _scheduler; - - private readonly IObservable> _source; - - private readonly TimeSpan? _throttle; - - public GroupOnProperty(IObservable> source, Expression> groupSelectorKey, TimeSpan? throttle = null, IScheduler? scheduler = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _groupSelector = groupSelectorKey.Compile(); - _propertySelector = groupSelectorKey; - _throttle = throttle; - _scheduler = scheduler; - } - - public IObservable> Run() - { - return _source.Publish( + public IObservable> Run() => _source.Publish( shared => { // Monitor explicit property changes - var regrouper = shared.WhenValueChanged(_propertySelector, false).ToUnit(); + var regrouper = shared.WhenValueChanged(groupSelectorKey, false).ToUnit(); // add a throttle if specified - if (_throttle is not null) + if (throttle is not null) { - regrouper = regrouper.Throttle(_throttle.Value, _scheduler ?? Scheduler.Default); + regrouper = regrouper.Throttle(throttle.Value, scheduler ?? Scheduler.Default); } // Use property changes as a trigger to re-evaluate Grouping return shared.Group(_groupSelector, regrouper); }); - } } diff --git a/src/DynamicData/Cache/Internal/GroupOnPropertyWithImmutableState.cs b/src/DynamicData/Cache/Internal/GroupOnPropertyWithImmutableState.cs index 7fbf43641..515e1d012 100644 --- a/src/DynamicData/Cache/Internal/GroupOnPropertyWithImmutableState.cs +++ b/src/DynamicData/Cache/Internal/GroupOnPropertyWithImmutableState.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.ComponentModel; using System.Linq.Expressions; using System.Reactive.Concurrency; @@ -12,46 +11,29 @@ namespace DynamicData.Cache.Internal; -internal class GroupOnPropertyWithImmutableState +internal class GroupOnPropertyWithImmutableState(IObservable> source, Expression> groupSelectorKey, TimeSpan? throttle = null, IScheduler? scheduler = null) where TObject : INotifyPropertyChanged where TKey : notnull where TGroup : notnull { - private readonly Func _groupSelector; + private readonly Func _groupSelector = groupSelectorKey.Compile(); + private readonly IScheduler _scheduler = scheduler ?? Scheduler.Default; - private readonly Expression> _propertySelector; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly IScheduler _scheduler; - - private readonly IObservable> _source; - - private readonly TimeSpan? _throttle; - - public GroupOnPropertyWithImmutableState(IObservable> source, Expression> groupSelectorKey, TimeSpan? throttle = null, IScheduler? scheduler = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _groupSelector = groupSelectorKey.Compile(); - _propertySelector = groupSelectorKey; - _throttle = throttle; - _scheduler = scheduler ?? Scheduler.Default; - } - - public IObservable> Run() - { - return _source.Publish( + public IObservable> Run() => _source.Publish( shared => { // Monitor explicit property changes - var regrouper = shared.WhenValueChanged(_propertySelector, false).ToUnit(); + var regrouper = shared.WhenValueChanged(groupSelectorKey, false).ToUnit(); // add a throttle if specified - if (_throttle is not null) + if (throttle is not null) { - regrouper = regrouper.Throttle(_throttle.Value, _scheduler); + regrouper = regrouper.Throttle(throttle.Value, _scheduler); } // Use property changes as a trigger to re-evaluate Grouping return shared.GroupWithImmutableState(_groupSelector, regrouper); }); - } } diff --git a/src/DynamicData/Cache/Internal/IFilter.cs b/src/DynamicData/Cache/Internal/IFilter.cs index 36c4e05a3..1924a226b 100644 --- a/src/DynamicData/Cache/Internal/IFilter.cs +++ b/src/DynamicData/Cache/Internal/IFilter.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - namespace DynamicData.Cache.Internal; /// diff --git a/src/DynamicData/Cache/Internal/ImmutableGroup.cs b/src/DynamicData/Cache/Internal/ImmutableGroup.cs index 077633b9c..0bdaea3da 100644 --- a/src/DynamicData/Cache/Internal/ImmutableGroup.cs +++ b/src/DynamicData/Cache/Internal/ImmutableGroup.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - using DynamicData.Kernel; namespace DynamicData.Cache.Internal; @@ -53,23 +50,11 @@ public bool Equals(ImmutableGroup? other) return other is not null && EqualityComparer.Default.Equals(Key, other.Key); } - public override bool Equals(object? obj) - { - return obj is ImmutableGroup value && Equals(value); - } + public override bool Equals(object? obj) => obj is ImmutableGroup value && Equals(value); - public override int GetHashCode() - { - return EqualityComparer.Default.GetHashCode(Key); - } + public override int GetHashCode() => EqualityComparer.Default.GetHashCode(Key); - public Optional Lookup(TKey key) - { - return _cache.Lookup(key); - } + public Optional Lookup(TKey key) => _cache.Lookup(key); - public override string ToString() - { - return $"Grouping for: {Key} ({Count} items)"; - } + public override string ToString() => $"Grouping for: {Key} ({Count} items)"; } diff --git a/src/DynamicData/Cache/Internal/ImmutableGroupChangeSet.cs b/src/DynamicData/Cache/Internal/ImmutableGroupChangeSet.cs index bdb920945..8a0f9e194 100644 --- a/src/DynamicData/Cache/Internal/ImmutableGroupChangeSet.cs +++ b/src/DynamicData/Cache/Internal/ImmutableGroupChangeSet.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - namespace DynamicData.Cache.Internal; internal sealed class ImmutableGroupChangeSet : ChangeSet, TGroupKey>, IImmutableGroupChangeSet diff --git a/src/DynamicData/Cache/Internal/IndexAndNode.cs b/src/DynamicData/Cache/Internal/IndexAndNode.cs index 924e20868..2546b6ece 100644 --- a/src/DynamicData/Cache/Internal/IndexAndNode.cs +++ b/src/DynamicData/Cache/Internal/IndexAndNode.cs @@ -2,29 +2,19 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace DynamicData.Cache.Internal; internal static class IndexAndNode { - public static IndexAndNode Create(int index, LinkedListNode value) - { - return new(index, value); - } + public static IndexAndNode Create(int index, LinkedListNode value) => new(index, value); } [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Same class name, different generics.")] -internal class IndexAndNode +internal class IndexAndNode(int index, LinkedListNode node) { - public IndexAndNode(int index, LinkedListNode node) - { - Index = index; - Node = node; - } + public int Index { get; } = index; - public int Index { get; } - - public LinkedListNode Node { get; } + public LinkedListNode Node { get; } = node; } diff --git a/src/DynamicData/Cache/Internal/IndexCalculator.cs b/src/DynamicData/Cache/Internal/IndexCalculator.cs index ad42bbdd1..3414348bd 100644 --- a/src/DynamicData/Cache/Internal/IndexCalculator.cs +++ b/src/DynamicData/Cache/Internal/IndexCalculator.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; -using System.Linq; - namespace DynamicData.Cache.Internal; /// @@ -13,29 +10,20 @@ namespace DynamicData.Cache.Internal; /// This enables the binding infrastructure to simply iterate the change set /// and apply indexed changes with no need to apply ant expensive IndexOf() operations. /// -internal sealed class IndexCalculator +/// +/// Initializes a new instance of the class. +/// +/// The comparer to use. +/// Selected indexing optimisations. +internal sealed class IndexCalculator(KeyValueComparer comparer, SortOptimisations optimisations) where TObject : notnull where TKey : notnull { - private readonly SortOptimisations _optimisations; - - private KeyValueComparer _comparer; - - /// - /// Initializes a new instance of the class. - /// - /// The comparer to use. - /// Selected indexing optimisations. - public IndexCalculator(KeyValueComparer comparer, SortOptimisations optimisations) - { - _comparer = comparer; - _optimisations = optimisations; - List = new List>(); - } + private KeyValueComparer _comparer = comparer; public IComparer> Comparer => _comparer; - public List> List { get; private set; } + public List> List { get; private set; } = new List>(); /// /// Dynamic calculation of moved items which produce a result which can be enumerated through in order. @@ -99,7 +87,7 @@ public IChangeSet Calculate(IChangeSet changes) // for evaluates, check whether the change forces a new position var evaluates = refreshes.OrderByDescending(x => new KeyValuePair(x.Key, x.Current), _comparer).ToList(); - if (evaluates.Count != 0 && _optimisations.HasFlag(SortOptimisations.IgnoreEvaluates)) + if (evaluates.Count != 0 && optimisations.HasFlag(SortOptimisations.IgnoreEvaluates)) { // reorder entire sequence and do not calculate moves List = List.OrderBy(kv => kv, _comparer).ToList(); @@ -162,7 +150,7 @@ public IChangeSet Reorder() { var result = new List>(); - if (_optimisations.HasFlag(SortOptimisations.IgnoreEvaluates)) + if (optimisations.HasFlag(SortOptimisations.IgnoreEvaluates)) { // reorder entire sequence and do not calculate moves List = List.OrderBy(kv => kv, _comparer).ToList(); @@ -198,16 +186,13 @@ public IChangeSet Reorder() /// Initialises the specified changes. /// /// The cache. - public void Reset(ChangeAwareCache cache) - { - List = cache.KeyValues.OrderBy(kv => kv, _comparer).ToList(); - } + public void Reset(ChangeAwareCache cache) => List = cache.KeyValues.OrderBy(kv => kv, _comparer).ToList(); private int GetCurrentPosition(KeyValuePair item) { int index; - if (_optimisations.HasFlag(SortOptimisations.ComparesImmutableValuesOnly)) + if (optimisations.HasFlag(SortOptimisations.ComparesImmutableValuesOnly)) { index = List.BinarySearch(item, _comparer); diff --git a/src/DynamicData/Cache/Internal/InnerJoin.cs b/src/DynamicData/Cache/Internal/InnerJoin.cs index 7dcbddbbc..3800da18e 100644 --- a/src/DynamicData/Cache/Internal/InnerJoin.cs +++ b/src/DynamicData/Cache/Internal/InnerJoin.cs @@ -2,38 +2,27 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; namespace DynamicData.Cache.Internal; -internal class InnerJoin +internal class InnerJoin(IObservable> left, IObservable> right, Func rightKeySelector, Func<(TLeftKey leftKey, TRightKey rightKey), TLeft, TRight, TDestination> resultSelector) where TLeft : notnull where TLeftKey : notnull where TRight : notnull where TRightKey : notnull where TDestination : notnull { - private readonly IObservable> _left; + private readonly IObservable> _left = left ?? throw new ArgumentNullException(nameof(left)); - private readonly Func<(TLeftKey leftKey, TRightKey rightKey), TLeft, TRight, TDestination> _resultSelector; + private readonly Func<(TLeftKey leftKey, TRightKey rightKey), TLeft, TRight, TDestination> _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - private readonly IObservable> _right; + private readonly IObservable> _right = right ?? throw new ArgumentNullException(nameof(right)); - private readonly Func _rightKeySelector; + private readonly Func _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); - public InnerJoin(IObservable> left, IObservable> right, Func rightKeySelector, Func<(TLeftKey leftKey, TRightKey rightKey), TLeft, TRight, TDestination> resultSelector) - { - _left = left ?? throw new ArgumentNullException(nameof(left)); - _right = right ?? throw new ArgumentNullException(nameof(right)); - _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); - _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -130,5 +119,4 @@ public InnerJoin(IObservable> left, IObservable +internal class InnerJoinMany(IObservable> left, IObservable> right, Func rightKeySelector, Func, TDestination> resultSelector) where TLeft : notnull where TLeftKey : notnull where TRight : notnull where TRightKey : notnull where TDestination : notnull { - private readonly IObservable> _left; - - private readonly Func, TDestination> _resultSelector; + private readonly IObservable> _left = left ?? throw new ArgumentNullException(nameof(left)); - private readonly IObservable> _right; + private readonly Func, TDestination> _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - private readonly Func _rightKeySelector; + private readonly IObservable> _right = right ?? throw new ArgumentNullException(nameof(right)); - public InnerJoinMany(IObservable> left, IObservable> right, Func rightKeySelector, Func, TDestination> resultSelector) - { - _left = left ?? throw new ArgumentNullException(nameof(left)); - _right = right ?? throw new ArgumentNullException(nameof(right)); - _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); - _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - } + private readonly Func _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); public IObservable> Run() { diff --git a/src/DynamicData/Cache/Internal/KeyComparer.cs b/src/DynamicData/Cache/Internal/KeyComparer.cs index 1e35d7c78..58e268209 100644 --- a/src/DynamicData/Cache/Internal/KeyComparer.cs +++ b/src/DynamicData/Cache/Internal/KeyComparer.cs @@ -2,19 +2,11 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - namespace DynamicData.Cache.Internal; internal sealed class KeyComparer : IEqualityComparer> { - public bool Equals(KeyValuePair x, KeyValuePair y) - { - return x.Key?.Equals(y.Key) ?? false; - } + public bool Equals(KeyValuePair x, KeyValuePair y) => x.Key?.Equals(y.Key) ?? false; - public int GetHashCode(KeyValuePair obj) - { - return obj.Key is null ? 0 : obj.Key.GetHashCode(); - } + public int GetHashCode(KeyValuePair obj) => obj.Key is null ? 0 : obj.Key.GetHashCode(); } diff --git a/src/DynamicData/Cache/Internal/KeySelector.cs b/src/DynamicData/Cache/Internal/KeySelector.cs index a10f94d44..1c642664b 100644 --- a/src/DynamicData/Cache/Internal/KeySelector.cs +++ b/src/DynamicData/Cache/Internal/KeySelector.cs @@ -2,19 +2,13 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Diagnostics.CodeAnalysis; namespace DynamicData.Cache.Internal; -internal sealed class KeySelector : IKeySelector +internal sealed class KeySelector(Func keySelector) : IKeySelector { - private readonly Func _keySelector; - - public KeySelector(Func keySelector) - { - _keySelector = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); - } + private readonly Func _keySelector = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); [SuppressMessage("Design", "CA1822: Member can be static", Justification = "Backwards compatibilty")] public Type Type => typeof(TObject); diff --git a/src/DynamicData/Cache/Internal/KeySelectorException.cs b/src/DynamicData/Cache/Internal/KeySelectorException.cs index cc25e7a5f..6d4f46954 100644 --- a/src/DynamicData/Cache/Internal/KeySelectorException.cs +++ b/src/DynamicData/Cache/Internal/KeySelectorException.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - namespace DynamicData.Cache.Internal; /// @@ -36,14 +34,4 @@ public KeySelectorException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the class. - /// - /// The serialization info. - /// The serialization context. - protected KeySelectorException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) - : base(serializationInfo, streamingContext) - { - } } diff --git a/src/DynamicData/Cache/Internal/KeyValueCollection.cs b/src/DynamicData/Cache/Internal/KeyValueCollection.cs index d7eabd86c..5b2d3c641 100644 --- a/src/DynamicData/Cache/Internal/KeyValueCollection.cs +++ b/src/DynamicData/Cache/Internal/KeyValueCollection.cs @@ -2,10 +2,7 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Collections; -using System.Collections.Generic; -using System.Linq; namespace DynamicData.Cache.Internal; @@ -44,13 +41,7 @@ public KeyValueCollection() public KeyValuePair this[int index] => _items.ElementAt(index); - public IEnumerator> GetEnumerator() - { - return _items.GetEnumerator(); - } + public IEnumerator> GetEnumerator() => _items.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/src/DynamicData/Cache/Internal/KeyValueComparer.cs b/src/DynamicData/Cache/Internal/KeyValueComparer.cs index 99a04bbd3..cae9a83f6 100644 --- a/src/DynamicData/Cache/Internal/KeyValueComparer.cs +++ b/src/DynamicData/Cache/Internal/KeyValueComparer.cs @@ -2,24 +2,15 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - namespace DynamicData.Cache.Internal; -internal class KeyValueComparer : IComparer> +internal class KeyValueComparer(IComparer? comparer = null) : IComparer> { - private readonly IComparer? _comparer; - - public KeyValueComparer(IComparer? comparer = null) - { - _comparer = comparer; - } - public int Compare(KeyValuePair x, KeyValuePair y) { - if (_comparer is not null) + if (comparer is not null) { - int result = _comparer.Compare(x.Value, y.Value); + int result = comparer.Compare(x.Value, y.Value); if (result != 0) { diff --git a/src/DynamicData/Cache/Internal/LeftJoin.cs b/src/DynamicData/Cache/Internal/LeftJoin.cs index 1d67e0612..909453a11 100644 --- a/src/DynamicData/Cache/Internal/LeftJoin.cs +++ b/src/DynamicData/Cache/Internal/LeftJoin.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -10,32 +9,22 @@ namespace DynamicData.Cache.Internal; -internal class LeftJoin +internal class LeftJoin(IObservable> left, IObservable> right, Func rightKeySelector, Func, TDestination> resultSelector) where TLeft : notnull where TLeftKey : notnull where TRight : notnull where TRightKey : notnull where TDestination : notnull { - private readonly IObservable> _left; + private readonly IObservable> _left = left ?? throw new ArgumentNullException(nameof(left)); - private readonly Func, TDestination> _resultSelector; + private readonly Func, TDestination> _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - private readonly IObservable> _right; + private readonly IObservable> _right = right ?? throw new ArgumentNullException(nameof(right)); - private readonly Func _rightKeySelector; + private readonly Func _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); - public LeftJoin(IObservable> left, IObservable> right, Func rightKeySelector, Func, TDestination> resultSelector) - { - _left = left ?? throw new ArgumentNullException(nameof(left)); - _right = right ?? throw new ArgumentNullException(nameof(right)); - _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); - _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -132,5 +121,4 @@ public IObservable> Run() return new CompositeDisposable(leftLoader.Merge(rightLoader).SubscribeSafe(observer), leftCache, rightCache); }); - } } diff --git a/src/DynamicData/Cache/Internal/LeftJoinMany.cs b/src/DynamicData/Cache/Internal/LeftJoinMany.cs index eb5ba33ab..fa5921410 100644 --- a/src/DynamicData/Cache/Internal/LeftJoinMany.cs +++ b/src/DynamicData/Cache/Internal/LeftJoinMany.cs @@ -2,34 +2,24 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - using DynamicData.Kernel; namespace DynamicData.Cache.Internal; -internal class LeftJoinMany +internal class LeftJoinMany(IObservable> left, IObservable> right, Func rightKeySelector, Func, TDestination> resultSelector) where TLeft : notnull where TLeftKey : notnull where TRight : notnull where TRightKey : notnull where TDestination : notnull { - private readonly IObservable> _left; - - private readonly Func, TDestination> _resultSelector; + private readonly IObservable> _left = left ?? throw new ArgumentNullException(nameof(left)); - private readonly IObservable> _right; + private readonly Func, TDestination> _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - private readonly Func _rightKeySelector; + private readonly IObservable> _right = right ?? throw new ArgumentNullException(nameof(right)); - public LeftJoinMany(IObservable> left, IObservable> right, Func rightKeySelector, Func, TDestination> resultSelector) - { - _left = left ?? throw new ArgumentNullException(nameof(left)); - _right = right ?? throw new ArgumentNullException(nameof(right)); - _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); - _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - } + private readonly Func _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); public IObservable> Run() { diff --git a/src/DynamicData/Cache/Internal/LockFreeObservableCache.cs b/src/DynamicData/Cache/Internal/LockFreeObservableCache.cs index 454f87fe3..af5caf8d4 100644 --- a/src/DynamicData/Cache/Internal/LockFreeObservableCache.cs +++ b/src/DynamicData/Cache/Internal/LockFreeObservableCache.cs @@ -2,10 +2,7 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Reactive.Disposables; using System.Reactive.Linq; using System.Reactive.Subjects; @@ -26,13 +23,13 @@ public sealed class LockFreeObservableCache : IObservableCache> _changes = new Subject>(); + private readonly Subject> _changes = new(); [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "Disposed with _cleanUp")] - private readonly Subject> _changesPreview = new Subject>(); + private readonly Subject> _changesPreview = new(); [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "Disposed with _cleanUp")] - private readonly Subject _countChanged = new Subject(); + private readonly Subject _countChanged = new(); private readonly IDisposable _cleanUp; @@ -96,9 +93,7 @@ public LockFreeObservableCache() public IEnumerable> KeyValues => _innerCache.KeyValues; /// - public IObservable> Connect(Func? predicate = null, bool suppressEmptyChangeSets = true) - { - return Observable.Defer( + public IObservable> Connect(Func? predicate = null, bool suppressEmptyChangeSets = true) => Observable.Defer( () => { var initial = InternalEx.Return(() => _innerCache.GetInitialUpdates(predicate)); @@ -115,7 +110,6 @@ public IObservable> Connect(Func? predi return changes; }); - } /// public void Dispose() => _cleanUp.Dispose(); @@ -143,25 +137,17 @@ public void Edit(Action> editAction) /// /// Fast indexed lookup. /// - public Optional Lookup(TKey key) - { - return _innerCache.Lookup(key); - } + public Optional Lookup(TKey key) => _innerCache.Lookup(key); /// - public IObservable> Preview(Func? predicate = null) - { - return predicate is null ? _changesPreview : _changesPreview.Filter(predicate); - } + public IObservable> Preview(Func? predicate = null) => predicate is null ? _changesPreview : _changesPreview.Filter(predicate); /// /// Returns an observable of any changes which match the specified key. The sequence starts with the initial item in the cache (if there is one). /// /// The key. /// An observable that emits the changes. - public IObservable> Watch(TKey key) - { - return Observable.Create>( + public IObservable> Watch(TKey key) => Observable.Create>( observer => { var initial = _innerCache.Lookup(key); @@ -183,5 +169,4 @@ public IObservable> Watch(TKey key) } }); }); - } } diff --git a/src/DynamicData/Cache/Internal/ManagedGroup.cs b/src/DynamicData/Cache/Internal/ManagedGroup.cs index 7f04092dd..71ede3394 100644 --- a/src/DynamicData/Cache/Internal/ManagedGroup.cs +++ b/src/DynamicData/Cache/Internal/ManagedGroup.cs @@ -2,32 +2,21 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - namespace DynamicData.Cache.Internal; -internal sealed class ManagedGroup : IGroup, IDisposable +internal sealed class ManagedGroup(TGroupKey groupKey) : IGroup, IDisposable where TObject : notnull where TKey : notnull { private readonly IntermediateCache _cache = new(); - public ManagedGroup(TGroupKey groupKey) - { - Key = groupKey; - } - public IObservableCache Cache => _cache; - public TGroupKey Key { get; } + public TGroupKey Key { get; } = groupKey; internal int Count => _cache.Count; - public void Dispose() - { - _cache.Dispose(); - } + public void Dispose() => _cache.Dispose(); /// /// Determines whether the specified is equal to the current . @@ -57,10 +46,7 @@ public override bool Equals(object? obj) /// /// A hash code for the current . /// - public override int GetHashCode() - { - return Key is null ? 0 : EqualityComparer.Default.GetHashCode(Key); - } + public override int GetHashCode() => Key is null ? 0 : EqualityComparer.Default.GetHashCode(Key); /// /// Returns a that represents the current . @@ -68,23 +54,11 @@ public override int GetHashCode() /// /// A that represents the current . /// - public override string ToString() - { - return $"Group: {Key}"; - } + public override string ToString() => $"Group: {Key}"; - internal IChangeSet GetInitialUpdates() - { - return _cache.GetInitialUpdates(); - } + internal IChangeSet GetInitialUpdates() => _cache.GetInitialUpdates(); - internal void Update(Action> updateAction) - { - _cache.Edit(updateAction); - } + internal void Update(Action> updateAction) => _cache.Edit(updateAction); - private bool Equals(ManagedGroup other) - { - return EqualityComparer.Default.Equals(Key, other.Key); - } + private bool Equals(ManagedGroup other) => EqualityComparer.Default.Equals(Key, other.Key); } diff --git a/src/DynamicData/Cache/Internal/MergeChangeSets.cs b/src/DynamicData/Cache/Internal/MergeChangeSets.cs index 01c2a339c..aa51a74ce 100644 --- a/src/DynamicData/Cache/Internal/MergeChangeSets.cs +++ b/src/DynamicData/Cache/Internal/MergeChangeSets.cs @@ -38,9 +38,7 @@ private MergeChangeSets(IObservable, in _equalityComparer = equalityComparer; } - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -61,7 +59,6 @@ public IObservable> Run() return new CompositeDisposable(localCache, subscription); }); - } // Can optimize for the Add case because that's the only one that applies private static Change, int> CreateChange(IObservable> source, int index) => diff --git a/src/DynamicData/Cache/Internal/MergeMany.cs b/src/DynamicData/Cache/Internal/MergeMany.cs index bcdc17076..69f23fd5e 100644 --- a/src/DynamicData/Cache/Internal/MergeMany.cs +++ b/src/DynamicData/Cache/Internal/MergeMany.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Reactive; using System.Reactive.Disposables; using System.Reactive.Linq; using System.Reactive.Subjects; @@ -34,9 +33,7 @@ public MergeMany(IObservable> source, Func observableSelector(t); } - public IObservable Run() - { - return Observable.Create( + public IObservable Run() => Observable.Create( observer => { var counter = new SubscriptionCounter(); @@ -51,7 +48,6 @@ public IObservable Run() return new CompositeDisposable(disposable, counter); }); - } private sealed class SubscriptionCounter : IDisposable { diff --git a/src/DynamicData/Cache/Internal/MergeManyCacheChangeSets.cs b/src/DynamicData/Cache/Internal/MergeManyCacheChangeSets.cs index 9634d5510..96df9dd47 100644 --- a/src/DynamicData/Cache/Internal/MergeManyCacheChangeSets.cs +++ b/src/DynamicData/Cache/Internal/MergeManyCacheChangeSets.cs @@ -10,47 +10,29 @@ namespace DynamicData.Cache.Internal; /// /// Operator that is similiar to MergeMany but intelligently handles Cache ChangeSets. /// -internal sealed class MergeManyCacheChangeSets +internal sealed class MergeManyCacheChangeSets(IObservable> source, Func>> selector, IEqualityComparer? equalityComparer, IComparer? comparer) where TObject : notnull where TKey : notnull where TDestination : notnull where TDestinationKey : notnull { - private readonly IObservable> _source; - - private readonly Func>> _changeSetSelector; - - private readonly IComparer? _comparer; - - private readonly IEqualityComparer? _equalityComparer; - - public MergeManyCacheChangeSets(IObservable> source, Func>> selector, IEqualityComparer? equalityComparer, IComparer? comparer) - { - _source = source; - _changeSetSelector = selector; - _comparer = comparer; - _equalityComparer = equalityComparer; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); // Transform to an observable cache of merge containers. - var sourceCacheOfCaches = _source + var sourceCacheOfCaches = source .IgnoreSameReferenceUpdate() .WhereReasonsAre(ChangeReason.Add, ChangeReason.Remove, ChangeReason.Update) - .Transform((obj, key) => new ChangeSetCache(_changeSetSelector(obj, key))) + .Transform((obj, key) => new ChangeSetCache(selector(obj, key))) .Synchronize(locker) .AsObservableCache(); var shared = sourceCacheOfCaches.Connect().Publish(); // this is manages all of the changes - var changeTracker = new ChangeSetMergeTracker(() => sourceCacheOfCaches.Items, _comparer, _equalityComparer); + var changeTracker = new ChangeSetMergeTracker(() => sourceCacheOfCaches.Items, comparer, equalityComparer); // merge the items back together var allChanges = shared.MergeMany(mc => mc.Source) @@ -68,5 +50,4 @@ public IObservable> Run() return new CompositeDisposable(sourceCacheOfCaches, allChanges, removedItems, shared.Connect()); }); - } } diff --git a/src/DynamicData/Cache/Internal/MergeManyCacheChangeSetsSourceCompare.cs b/src/DynamicData/Cache/Internal/MergeManyCacheChangeSetsSourceCompare.cs index c9f56e30b..aa24816f2 100644 --- a/src/DynamicData/Cache/Internal/MergeManyCacheChangeSetsSourceCompare.cs +++ b/src/DynamicData/Cache/Internal/MergeManyCacheChangeSetsSourceCompare.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Diagnostics.CodeAnalysis; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -12,40 +11,25 @@ namespace DynamicData.Cache.Internal; /// Alternate version of MergeManyCacheChangeSets that uses a Comparer of the source, not the destination type /// So that items from the most important source go into the resulting changeset. /// -internal sealed class MergeManyCacheChangeSetsSourceCompare +internal sealed class MergeManyCacheChangeSetsSourceCompare(IObservable> source, Func>> selector, IComparer parentCompare, IEqualityComparer? equalityComparer, IComparer? childCompare, bool reevalOnRefresh = false) where TObject : notnull where TKey : notnull where TDestination : notnull where TDestinationKey : notnull { - private readonly IObservable> _source; + private readonly Func>> _changeSetSelector = (obj, key) => selector(obj, key).Transform(dest => new ParentChildEntry(obj, dest)); - private readonly Func>> _changeSetSelector; + private readonly IComparer? _comparer = (childCompare is null) ? new ParentOnlyCompare(parentCompare) : new ParentChildCompare(parentCompare, childCompare); - private readonly IComparer? _comparer; + private readonly IEqualityComparer? _equalityComparer = (equalityComparer != null) ? new ParentChildEqualityCompare(equalityComparer) : null; - private readonly IEqualityComparer? _equalityComparer; - - private readonly bool _reevalOnRefresh; - - public MergeManyCacheChangeSetsSourceCompare(IObservable> source, Func>> selector, IComparer parentCompare, IEqualityComparer? equalityComparer, IComparer? childCompare, bool reevalOnRefresh = false) - { - _source = source; - _changeSetSelector = (obj, key) => selector(obj, key).Transform(dest => new ParentChildEntry(obj, dest)); - _comparer = (childCompare is null) ? new ParentOnlyCompare(parentCompare) : new ParentChildCompare(parentCompare, childCompare); - _equalityComparer = (equalityComparer != null) ? new ParentChildEqualityCompare(equalityComparer) : null; - _reevalOnRefresh = reevalOnRefresh; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); // Transform to an observable cache of merge containers. - var sourceCacheOfCaches = _source + var sourceCacheOfCaches = source .Transform((obj, key) => new ChangeSetCache(_changeSetSelector(obj, key))) .Synchronize(locker) .AsObservableCache(); @@ -71,43 +55,27 @@ public IObservable> Run() // If requested, when the source sees a refresh event, re-evaluate all the keys associated with that source because the priority may have changed // Because the comparison is based on the parent, which has just been refreshed. - var refreshItems = _reevalOnRefresh + var refreshItems = reevalOnRefresh ? shared.OnItemRefreshed(mc => changeTracker.RefreshItems(mc.Cache.Keys, observer)).Subscribe() : Disposable.Empty; return new CompositeDisposable(sourceCacheOfCaches, allChanges, removedItems, refreshItems, shared.Connect()); }).Transform(entry => entry.Child); - } - private sealed class ParentChildEntry + private sealed class ParentChildEntry(TObject parent, TDestination child) { - public ParentChildEntry(TObject parent, TDestination child) - { - Parent = parent; - Child = child; - } + public TObject Parent { get; } = parent; - public TObject Parent { get; } - - public TDestination Child { get; } + public TDestination Child { get; } = child; } - private sealed class ParentChildCompare : Comparer + private sealed class ParentChildCompare(IComparer comparerParent, IComparer comparerChild) : Comparer { - private readonly IComparer _comparerParent; - private readonly IComparer _comparerChild; - - public ParentChildCompare(IComparer comparerParent, IComparer comparerChild) - { - _comparerParent = comparerParent; - _comparerChild = comparerChild; - } - public override int Compare(ParentChildEntry? x, ParentChildEntry? y) => (x, y) switch { - (not null, not null) => _comparerParent.Compare(x.Parent, y.Parent) switch + (not null, not null) => comparerParent.Compare(x.Parent, y.Parent) switch { - 0 => _comparerChild.Compare(x.Child, y.Child), + 0 => comparerChild.Compare(x.Child, y.Child), int i => i, }, (null, null) => 0, @@ -116,34 +84,26 @@ public ParentChildCompare(IComparer comparerParent, IComparer + private sealed class ParentOnlyCompare(IComparer comparer) : Comparer { - private readonly IComparer _comparerParent; - - public ParentOnlyCompare(IComparer comparer) => _comparerParent = comparer; - public override int Compare(ParentChildEntry? x, ParentChildEntry? y) => (x, y) switch { - (not null, not null) => _comparerParent.Compare(x.Parent, y.Parent), + (not null, not null) => comparer.Compare(x.Parent, y.Parent), (null, null) => 0, (null, not null) => 1, (not null, null) => -1, }; } - private sealed class ParentChildEqualityCompare : EqualityComparer + private sealed class ParentChildEqualityCompare(IEqualityComparer comparer) : EqualityComparer { - private readonly IEqualityComparer _comparer; - - public ParentChildEqualityCompare(IEqualityComparer comparer) => _comparer = comparer; - public override bool Equals(ParentChildEntry? x, ParentChildEntry? y) => (x, y) switch { - (not null, not null) => _comparer.Equals(x.Child, y.Child), + (not null, not null) => comparer.Equals(x.Child, y.Child), (null, null) => true, _ => false, }; - public override int GetHashCode(ParentChildEntry obj) => _comparer.GetHashCode(obj.Child); + public override int GetHashCode(ParentChildEntry obj) => comparer.GetHashCode(obj.Child); } } diff --git a/src/DynamicData/Cache/Internal/MergeManyItems.cs b/src/DynamicData/Cache/Internal/MergeManyItems.cs index 7ce490c80..cbb484355 100644 --- a/src/DynamicData/Cache/Internal/MergeManyItems.cs +++ b/src/DynamicData/Cache/Internal/MergeManyItems.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Linq; using DynamicData.Kernel; @@ -34,8 +33,5 @@ public MergeManyItems(IObservable> source, Func observableSelector(t); } - public IObservable> Run() - { - return Observable.Create>(observer => _source.SubscribeMany((t, v) => _observableSelector(t, v).Select(z => new ItemWithValue(t, z)).SubscribeSafe(observer)).Subscribe()); - } + public IObservable> Run() => Observable.Create>(observer => _source.SubscribeMany((t, v) => _observableSelector(t, v).Select(z => new ItemWithValue(t, z)).SubscribeSafe(observer)).Subscribe()); } diff --git a/src/DynamicData/Cache/Internal/ObservableWithValue.cs b/src/DynamicData/Cache/Internal/ObservableWithValue.cs index 72cb0313b..6adef008c 100644 --- a/src/DynamicData/Cache/Internal/ObservableWithValue.cs +++ b/src/DynamicData/Cache/Internal/ObservableWithValue.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Linq; using DynamicData.Kernel; diff --git a/src/DynamicData/Cache/Internal/OnBeingRemoved.cs b/src/DynamicData/Cache/Internal/OnBeingRemoved.cs index 5ae6952f7..cc695a20e 100644 --- a/src/DynamicData/Cache/Internal/OnBeingRemoved.cs +++ b/src/DynamicData/Cache/Internal/OnBeingRemoved.cs @@ -9,25 +9,14 @@ namespace DynamicData.Cache.Internal; -internal sealed class OnBeingRemoved +internal sealed class OnBeingRemoved(IObservable> source, Action removeAction, bool invokeOnUnsubscribe) where TObject : notnull where TKey : notnull { - private readonly Action _removeAction; - private readonly bool _invokeOnUnsubscribe; + private readonly Action _removeAction = removeAction ?? throw new ArgumentNullException(nameof(removeAction)); + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly IObservable> _source; - - public OnBeingRemoved(IObservable> source, Action removeAction, bool invokeOnUnsubscribe) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _removeAction = removeAction ?? throw new ArgumentNullException(nameof(removeAction)); - _invokeOnUnsubscribe = invokeOnUnsubscribe; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -41,7 +30,7 @@ public IObservable> Run() lock (locker) { - if (_invokeOnUnsubscribe) + if (invokeOnUnsubscribe) { cache.Items.ForEach(t => _removeAction(t)); } @@ -50,7 +39,6 @@ public IObservable> Run() } }); }); - } private void RegisterForRemoval(IChangeSet changes, Cache cache) { diff --git a/src/DynamicData/Cache/Internal/Page.cs b/src/DynamicData/Cache/Internal/Page.cs index 755ce48c8..8f9732f94 100644 --- a/src/DynamicData/Cache/Internal/Page.cs +++ b/src/DynamicData/Cache/Internal/Page.cs @@ -2,42 +2,27 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Linq; using System.Reactive.Linq; namespace DynamicData.Cache.Internal; -internal class Page +internal class Page(IObservable> source, IObservable pageRequests) where TObject : notnull where TKey : notnull { - private readonly IObservable _pageRequests; - - private readonly IObservable> _source; - - public Page(IObservable> source, IObservable pageRequests) - { - _source = source; - _pageRequests = pageRequests; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); var paginator = new Paginator(); - var request = _pageRequests.Synchronize(locker).Select(paginator.Paginate); - var dataChange = _source.Synchronize(locker).Select(paginator.Update); + var request = pageRequests.Synchronize(locker).Select(paginator.Paginate); + var dataChange = source.Synchronize(locker).Select(paginator.Update); return request.Merge(dataChange) .Where(updates => updates is not null) .Select(x => x!) .SubscribeSafe(observer); }); - } private sealed class Paginator { diff --git a/src/DynamicData/Cache/Internal/QueryWhenChanged.cs b/src/DynamicData/Cache/Internal/QueryWhenChanged.cs index ebd39e4e3..c401d1d9d 100644 --- a/src/DynamicData/Cache/Internal/QueryWhenChanged.cs +++ b/src/DynamicData/Cache/Internal/QueryWhenChanged.cs @@ -2,28 +2,19 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Linq; namespace DynamicData.Cache.Internal; -internal class QueryWhenChanged +internal class QueryWhenChanged(IObservable> source, Func>? itemChangedTrigger = null) where TObject : notnull where TKey : notnull { - private readonly Func>? _itemChangedTrigger; - - private readonly IObservable> _source; - - public QueryWhenChanged(IObservable> source, Func>? itemChangedTrigger = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _itemChangedTrigger = itemChangedTrigger; - } + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); public IObservable> Run() { - if (_itemChangedTrigger is null) + if (itemChangedTrigger is null) { return Observable.Defer(() => { @@ -46,7 +37,7 @@ public IObservable> Run() var locker = new object(); var state = new Cache(); - var inlineChange = shared.MergeMany(_itemChangedTrigger).Synchronize(locker).Select(_ => new AnonymousQuery(state)); + var inlineChange = shared.MergeMany(itemChangedTrigger).Synchronize(locker).Select(_ => new AnonymousQuery(state)); var sourceChanged = shared.Synchronize(locker).Scan( state, diff --git a/src/DynamicData/Cache/Internal/ReaderWriter.cs b/src/DynamicData/Cache/Internal/ReaderWriter.cs index 75016ddab..4b036f23a 100644 --- a/src/DynamicData/Cache/Internal/ReaderWriter.cs +++ b/src/DynamicData/Cache/Internal/ReaderWriter.cs @@ -2,27 +2,20 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - using DynamicData.Kernel; namespace DynamicData.Cache.Internal; -internal sealed class ReaderWriter +internal sealed class ReaderWriter(Func? keySelector = null) where TObject : notnull where TKey : notnull { - private readonly Func? _keySelector; - private readonly object _locker = new(); private CacheUpdater? _activeUpdater; private Dictionary _data = new(); // could do with priming this on first time load - public ReaderWriter(Func? keySelector = null) => _keySelector = keySelector; - public int Count { get @@ -164,7 +157,7 @@ private ChangeSet DoUpdate(Action> up var copy = new Dictionary(_data); var changeAwareCache = new ChangeAwareCache(_data); - _activeUpdater = new CacheUpdater(changeAwareCache, _keySelector); + _activeUpdater = new CacheUpdater(changeAwareCache, keySelector); updateAction(_activeUpdater); _activeUpdater = null; @@ -181,14 +174,14 @@ private ChangeSet DoUpdate(Action> up { var changeAwareCache = new ChangeAwareCache(_data); - _activeUpdater = new CacheUpdater(changeAwareCache, _keySelector); + _activeUpdater = new CacheUpdater(changeAwareCache, keySelector); updateAction(_activeUpdater); _activeUpdater = null; return changeAwareCache.CaptureChanges(); } - _activeUpdater = new CacheUpdater(_data, _keySelector); + _activeUpdater = new CacheUpdater(_data, keySelector); updateAction(_activeUpdater); _activeUpdater = null; diff --git a/src/DynamicData/Cache/Internal/RefCount.cs b/src/DynamicData/Cache/Internal/RefCount.cs index 11547ec44..875916095 100644 --- a/src/DynamicData/Cache/Internal/RefCount.cs +++ b/src/DynamicData/Cache/Internal/RefCount.cs @@ -2,32 +2,24 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; namespace DynamicData.Cache.Internal; -internal class RefCount +internal class RefCount(IObservable> source) where TObject : notnull where TKey : notnull { private readonly object _locker = new(); - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); private IObservableCache? _cache; private int _refCount; - public RefCount(IObservable> source) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { lock (_locker) @@ -61,5 +53,4 @@ public IObservable> Run() cacheToDispose?.Dispose(); }); }); - } } diff --git a/src/DynamicData/Cache/Internal/RemoveKeyEnumerator.cs b/src/DynamicData/Cache/Internal/RemoveKeyEnumerator.cs index 19676413d..aa29cd4b6 100644 --- a/src/DynamicData/Cache/Internal/RemoveKeyEnumerator.cs +++ b/src/DynamicData/Cache/Internal/RemoveKeyEnumerator.cs @@ -2,31 +2,21 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Collections; -using System.Collections.Generic; namespace DynamicData.Cache.Internal; -internal class RemoveKeyEnumerator : IEnumerable> +/// Initializes a new instance of the class.Converts a to . +/// The change set with a key. +/// +/// An optional list, if provided it allows the refresh from a key based cache to find the index for the resulting list based refresh. +/// If not provided a refresh will dropdown to a replace which may ultimately result in a remove+add change downstream. +/// +internal class RemoveKeyEnumerator(IChangeSet source, IExtendedList? list = null) : IEnumerable> where TObject : notnull where TKey : notnull { - private readonly IExtendedList? _list; - - private readonly IChangeSet _source; - - /// Initializes a new instance of the class.Converts a to . - /// The change set with a key. - /// - /// An optional list, if provided it allows the refresh from a key based cache to find the index for the resulting list based refresh. - /// If not provided a refresh will dropdown to a replace which may ultimately result in a remove+add change downstream. - /// - public RemoveKeyEnumerator(IChangeSet source, IExtendedList? list = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _list = list; - } + private readonly IChangeSet _source = source ?? throw new ArgumentNullException(nameof(source)); /// /// Returns an enumerator that iterates through the collection. @@ -52,7 +42,7 @@ public IEnumerator> GetEnumerator() // Thus, currentIndex will not be available here where as other changes like add and remove do have indexes if coming from a sorted change set. // In order to properly handle a refresh and map to an index on a list, we need to use the source list (within the edit method so that it's thread safe) - var index = _list?.IndexOf(change.Current); + var index = list?.IndexOf(change.Current); if (index >= 0) { yield return new Change(ListChangeReason.Refresh, change.Current, index.Value); @@ -82,8 +72,5 @@ public IEnumerator> GetEnumerator() } } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/src/DynamicData/Cache/Internal/RightJoin.cs b/src/DynamicData/Cache/Internal/RightJoin.cs index 34169eb0b..1f56f6c74 100644 --- a/src/DynamicData/Cache/Internal/RightJoin.cs +++ b/src/DynamicData/Cache/Internal/RightJoin.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -10,32 +9,22 @@ namespace DynamicData.Cache.Internal; -internal class RightJoin +internal class RightJoin(IObservable> left, IObservable> right, Func rightKeySelector, Func, TRight, TDestination> resultSelector) where TLeft : notnull where TLeftKey : notnull where TRight : notnull where TRightKey : notnull where TDestination : notnull { - private readonly IObservable> _left; + private readonly IObservable> _left = left ?? throw new ArgumentNullException(nameof(left)); - private readonly Func, TRight, TDestination> _resultSelector; + private readonly Func, TRight, TDestination> _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - private readonly IObservable> _right; + private readonly IObservable> _right = right ?? throw new ArgumentNullException(nameof(right)); - private readonly Func _rightKeySelector; + private readonly Func _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); - public RightJoin(IObservable> left, IObservable> right, Func rightKeySelector, Func, TRight, TDestination> resultSelector) - { - _left = left ?? throw new ArgumentNullException(nameof(left)); - _right = right ?? throw new ArgumentNullException(nameof(right)); - _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); - _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -125,5 +114,4 @@ public IObservable> Run() return new CompositeDisposable(leftLoader.Merge(rightLoader).SubscribeSafe(observer), leftCache, rightCache, rightShare.Connect()); }); - } } diff --git a/src/DynamicData/Cache/Internal/RightJoinMany.cs b/src/DynamicData/Cache/Internal/RightJoinMany.cs index df48b33a9..cbb7ef519 100644 --- a/src/DynamicData/Cache/Internal/RightJoinMany.cs +++ b/src/DynamicData/Cache/Internal/RightJoinMany.cs @@ -2,34 +2,24 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - using DynamicData.Kernel; namespace DynamicData.Cache.Internal; -internal class RightJoinMany +internal class RightJoinMany(IObservable> left, IObservable> right, Func rightKeySelector, Func, IGrouping, TDestination> resultSelector) where TLeft : notnull where TLeftKey : notnull where TRight : notnull where TRightKey : notnull where TDestination : notnull { - private readonly IObservable> _left; - - private readonly Func, IGrouping, TDestination> _resultSelector; + private readonly IObservable> _left = left ?? throw new ArgumentNullException(nameof(left)); - private readonly IObservable> _right; + private readonly Func, IGrouping, TDestination> _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - private readonly Func _rightKeySelector; + private readonly IObservable> _right = right ?? throw new ArgumentNullException(nameof(right)); - public RightJoinMany(IObservable> left, IObservable> right, Func rightKeySelector, Func, IGrouping, TDestination> resultSelector) - { - _left = left ?? throw new ArgumentNullException(nameof(left)); - _right = right ?? throw new ArgumentNullException(nameof(right)); - _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); - _resultSelector = resultSelector ?? throw new ArgumentNullException(nameof(resultSelector)); - } + private readonly Func _rightKeySelector = rightKeySelector ?? throw new ArgumentNullException(nameof(rightKeySelector)); public IObservable> Run() { diff --git a/src/DynamicData/Cache/Internal/SizeExpirer.cs b/src/DynamicData/Cache/Internal/SizeExpirer.cs index 39c7b2fe5..d719453b2 100644 --- a/src/DynamicData/Cache/Internal/SizeExpirer.cs +++ b/src/DynamicData/Cache/Internal/SizeExpirer.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Linq; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -30,9 +28,7 @@ public SizeExpirer(IObservable> source, int size) _size = size; } - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var sizeLimiter = new SizeLimiter(_size); @@ -55,5 +51,4 @@ public IObservable> Run() root.Dispose(); }); }); - } } diff --git a/src/DynamicData/Cache/Internal/SizeLimiter.cs b/src/DynamicData/Cache/Internal/SizeLimiter.cs index b2eb836a2..32cba2129 100644 --- a/src/DynamicData/Cache/Internal/SizeLimiter.cs +++ b/src/DynamicData/Cache/Internal/SizeLimiter.cs @@ -2,31 +2,21 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; -using System.Linq; - using DynamicData.Kernel; namespace DynamicData.Cache.Internal; -internal sealed class SizeLimiter +internal sealed class SizeLimiter(int size) where TObject : notnull where TKey : notnull { private readonly ChangeAwareCache, TKey> _cache = new(); - private readonly int _sizeLimit; - - public SizeLimiter(int size) - { - _sizeLimit = size; - } - public IChangeSet Change(IChangeSet, TKey> updates) { _cache.Clone(updates); - var itemsToExpire = _cache.KeyValues.OrderByDescending(exp => exp.Value.ExpireAt).Skip(_sizeLimit).Select(exp => new Change(ChangeReason.Remove, exp.Key, exp.Value.Value)).ToList(); + var itemsToExpire = _cache.KeyValues.OrderByDescending(exp => exp.Value.ExpireAt).Skip(size).Select(exp => new Change(ChangeReason.Remove, exp.Key, exp.Value.Value)).ToList(); if (itemsToExpire.Count > 0) { @@ -44,6 +34,6 @@ public KeyValuePair[] CloneAndReturnExpiredOnly(IChangeSet exp.Value.Index).Skip(_sizeLimit).Select(kvp => new KeyValuePair(kvp.Key, kvp.Value.Value)).ToArray(); + return _cache.KeyValues.OrderByDescending(exp => exp.Value.Index).Skip(size).Select(kvp => new KeyValuePair(kvp.Key, kvp.Value.Value)).ToArray(); } } diff --git a/src/DynamicData/Cache/Internal/Sort.cs b/src/DynamicData/Cache/Internal/Sort.cs index 8a40063f8..7f61a1e0a 100644 --- a/src/DynamicData/Cache/Internal/Sort.cs +++ b/src/DynamicData/Cache/Internal/Sort.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive; using System.Reactive.Linq; @@ -41,9 +38,7 @@ public Sort(IObservable> source, IComparer? c _resetThreshold = resetThreshold; } - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var sorter = new Sorter(_sortOptimisations, _comparer, _resetThreshold); @@ -63,19 +58,13 @@ public IObservable> Run() return comparerChanged.Merge(dataChanged).Merge(sortAgain).Where(result => result is not null).Select(x => x!).SubscribeSafe(observer); }); - } - private class Sorter + private class Sorter(SortOptimisations optimisations, IComparer? comparer = null, int resetThreshold = -1) { private readonly ChangeAwareCache _cache = new(); - - private readonly SortOptimisations _optimisations; - - private readonly int _resetThreshold; - private IndexCalculator? _calculator; - private KeyValueComparer _comparer; + private KeyValueComparer _comparer = new(comparer); private bool _haveReceivedData; @@ -83,13 +72,6 @@ private class Sorter private IKeyValueCollection _sorted = new KeyValueCollection(); - public Sorter(SortOptimisations optimisations, IComparer? comparer = null, int resetThreshold = -1) - { - _optimisations = optimisations; - _resetThreshold = resetThreshold; - _comparer = new KeyValueComparer(comparer); - } - /// /// Sorts the specified changes. Will return null if there are no changes. /// @@ -140,7 +122,7 @@ public Sorter(SortOptimisations optimisations, IComparer? comparer = nu sortReason = SortReason.InitialLoad; _initialised = true; } - else if (changes is not null && (_resetThreshold > 0 && changes.Count >= _resetThreshold)) + else if (changes is not null && (resetThreshold > 0 && changes.Count >= resetThreshold)) { sortReason = SortReason.Reset; } @@ -152,7 +134,7 @@ public Sorter(SortOptimisations optimisations, IComparer? comparer = nu { // For the first batch, changes may have arrived before the comparer was set. // therefore infer the first batch of changes from the cache - _calculator = new IndexCalculator(_comparer, _optimisations); + _calculator = new IndexCalculator(_comparer, optimisations); changeSet = _calculator.Load(_cache); } @@ -196,7 +178,7 @@ public Sorter(SortOptimisations optimisations, IComparer? comparer = nu } changeSet = _calculator.ChangeComparer(_comparer); - if (_resetThreshold > 0 && _cache.Count >= _resetThreshold) + if (resetThreshold > 0 && _cache.Count >= resetThreshold) { sortReason = SortReason.Reset; _calculator.Reset(_cache); @@ -241,7 +223,7 @@ public Sorter(SortOptimisations optimisations, IComparer? comparer = nu return null; } - _sorted = new KeyValueCollection(_calculator.List.ToList(), _comparer, sortReason, _optimisations); + _sorted = new KeyValueCollection(_calculator.List.ToList(), _comparer, sortReason, optimisations); return new SortedChangeSet(_sorted, changeSet); } } diff --git a/src/DynamicData/Cache/Internal/SpecifiedGrouper.cs b/src/DynamicData/Cache/Internal/SpecifiedGrouper.cs index 0982b0ec5..ba6bd9753 100644 --- a/src/DynamicData/Cache/Internal/SpecifiedGrouper.cs +++ b/src/DynamicData/Cache/Internal/SpecifiedGrouper.cs @@ -2,34 +2,23 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Linq; using System.Reactive.Disposables; using System.Reactive.Linq; namespace DynamicData.Cache.Internal; -internal class SpecifiedGrouper +internal class SpecifiedGrouper(IObservable> source, Func groupSelector, IObservable> resultGroupSource) where TObject : notnull where TKey : notnull where TGroupKey : notnull { - private readonly Func _groupSelector; + private readonly Func _groupSelector = groupSelector ?? throw new ArgumentNullException(nameof(groupSelector)); - private readonly IObservable> _resultGroupSource; + private readonly IObservable> _resultGroupSource = resultGroupSource ?? throw new ArgumentNullException(nameof(resultGroupSource)); - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public SpecifiedGrouper(IObservable> source, Func groupSelector, IObservable> resultGroupSource) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _groupSelector = groupSelector ?? throw new ArgumentNullException(nameof(groupSelector)); - _resultGroupSource = resultGroupSource ?? throw new ArgumentNullException(nameof(resultGroupSource)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -82,5 +71,4 @@ public IObservable> Run() updatesFromChildren.Dispose(); }); }); - } } diff --git a/src/DynamicData/Cache/Internal/StaticFilter.cs b/src/DynamicData/Cache/Internal/StaticFilter.cs index f9697f9a1..f2fea8379 100644 --- a/src/DynamicData/Cache/Internal/StaticFilter.cs +++ b/src/DynamicData/Cache/Internal/StaticFilter.cs @@ -2,44 +2,28 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Linq; namespace DynamicData.Cache.Internal; -internal class StaticFilter +internal class StaticFilter(IObservable> source, Func filter, bool suppressEmptyChangeSets) where TObject : notnull where TKey : notnull { - private readonly Func _filter; - private readonly bool _suppressEmptyChangeSets; + public IObservable> Run() => Observable.Create>(observer => + { + ChangeAwareCache? cache = null; - private readonly IObservable> _source; + return source.Subscribe(changes => + { + cache ??= new ChangeAwareCache(changes.Count); - public StaticFilter(IObservable> source, Func filter, bool suppressEmptyChangeSets) - { - _source = source; - _filter = filter; - _suppressEmptyChangeSets = suppressEmptyChangeSets; - } + cache.FilterChanges(changes, filter); + var filtered = cache.CaptureChanges(); - public IObservable> Run() - { - return Observable.Create>(observer => - { - ChangeAwareCache? cache = null; + if (filtered.Count != 0 || !suppressEmptyChangeSets) + observer.OnNext(filtered); - return _source.Subscribe(changes => - { - cache ??= new ChangeAwareCache(changes.Count); - - cache.FilterChanges(changes, _filter); - var filtered = cache.CaptureChanges(); - - if (filtered.Count != 0 || !_suppressEmptyChangeSets) - observer.OnNext(filtered); - - }, observer.OnError, observer.OnCompleted); - }); - } + }, observer.OnError, observer.OnCompleted); + }); } diff --git a/src/DynamicData/Cache/Internal/StatusMonitor.cs b/src/DynamicData/Cache/Internal/StatusMonitor.cs index 8a3e79d33..ff9bb23e7 100644 --- a/src/DynamicData/Cache/Internal/StatusMonitor.cs +++ b/src/DynamicData/Cache/Internal/StatusMonitor.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; using System.Reactive.Subjects; @@ -11,18 +10,9 @@ namespace DynamicData.Cache.Internal; -internal class StatusMonitor +internal class StatusMonitor(IObservable source) { - private readonly IObservable _source; - - public StatusMonitor(IObservable source) - { - _source = source; - } - - public IObservable Run() - { - return Observable.Create( + public IObservable Run() => Observable.Create( observer => { var statusSubject = new Subject(); @@ -57,7 +47,7 @@ void Updated() statusSubject.OnNext(status); } - var monitor = _source.Subscribe(_ => Updated(), Error, Completion); + var monitor = source.Subscribe(_ => Updated(), Error, Completion); var subscriber = statusSubject.StartWith(status).DistinctUntilChanged().SubscribeSafe(observer); @@ -69,5 +59,4 @@ void Updated() subscriber.Dispose(); }); }); - } } diff --git a/src/DynamicData/Cache/Internal/SubscribeMany.cs b/src/DynamicData/Cache/Internal/SubscribeMany.cs index ceba68998..ac2cc1796 100644 --- a/src/DynamicData/Cache/Internal/SubscribeMany.cs +++ b/src/DynamicData/Cache/Internal/SubscribeMany.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -33,9 +32,7 @@ public SubscribeMany(IObservable> source, Func> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var published = _source.Publish(); @@ -43,5 +40,4 @@ public IObservable> Run() return new CompositeDisposable(subscriptions, published.SubscribeSafe(observer), published.Connect()); }); - } } diff --git a/src/DynamicData/Cache/Internal/Switch.cs b/src/DynamicData/Cache/Internal/Switch.cs index 0bc31a463..a6bd08910 100644 --- a/src/DynamicData/Cache/Internal/Switch.cs +++ b/src/DynamicData/Cache/Internal/Switch.cs @@ -2,26 +2,18 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; namespace DynamicData.Cache.Internal; -internal sealed class Switch +internal sealed class Switch(IObservable>> sources) where TObject : notnull where TKey : notnull { - private readonly IObservable>> _sources; + private readonly IObservable>> _sources = sources ?? throw new ArgumentNullException(nameof(sources)); - public Switch(IObservable>> sources) - { - _sources = sources ?? throw new ArgumentNullException(nameof(sources)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -40,5 +32,4 @@ public IObservable> Run() return new CompositeDisposable(destination, populator, destination.Connect().SubscribeSafe(observer)); }); - } } diff --git a/src/DynamicData/Cache/Internal/TimeExpirer.cs b/src/DynamicData/Cache/Internal/TimeExpirer.cs index 9f4bf54e2..da0ef4f2b 100644 --- a/src/DynamicData/Cache/Internal/TimeExpirer.cs +++ b/src/DynamicData/Cache/Internal/TimeExpirer.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Concurrency; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -13,29 +10,15 @@ namespace DynamicData.Cache.Internal; -internal class TimeExpirer +internal class TimeExpirer(IObservable> source, Func timeSelector, TimeSpan? interval, IScheduler scheduler) where TObject : notnull where TKey : notnull { - private readonly TimeSpan? _interval; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly IScheduler _scheduler; + private readonly Func _timeSelector = timeSelector ?? throw new ArgumentNullException(nameof(timeSelector)); - private readonly IObservable> _source; - - private readonly Func _timeSelector; - - public TimeExpirer(IObservable> source, Func timeSelector, TimeSpan? interval, IScheduler scheduler) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _timeSelector = timeSelector ?? throw new ArgumentNullException(nameof(timeSelector)); - _interval = interval; - _scheduler = scheduler; - } - - public IObservable> ExpireAfter() - { - return Observable.Create>( + public IObservable> ExpireAfter() => Observable.Create>( observer => { var cache = new IntermediateCache(_source); @@ -43,7 +26,7 @@ public IObservable> ExpireAfter() var published = cache.Connect().Publish(); var subscriber = published.SubscribeSafe(observer); - var autoRemover = published.ForExpiry(_timeSelector, _interval, _scheduler).Finally(observer.OnCompleted).Subscribe( + var autoRemover = published.ForExpiry(_timeSelector, interval, scheduler).Finally(observer.OnCompleted).Subscribe( keys => { try @@ -67,16 +50,13 @@ public IObservable> ExpireAfter() cache.Dispose(); }); }); - } - public IObservable>> ForExpiry() - { - return Observable.Create>>( + public IObservable>> ForExpiry() => Observable.Create>>( observer => { var dateTime = DateTime.Now; - var autoRemover = _source.Do(_ => dateTime = _scheduler.Now.UtcDateTime).Transform( + var autoRemover = _source.Do(_ => dateTime = scheduler.Now.UtcDateTime).Transform( (t, v) => { var removeAt = _timeSelector(t); @@ -88,7 +68,7 @@ void RemovalAction() { try { - var toRemove = autoRemover.KeyValues.Where(kv => kv.Value.ExpireAt <= _scheduler.Now.UtcDateTime).ToList(); + var toRemove = autoRemover.KeyValues.Where(kv => kv.Value.ExpireAt <= scheduler.Now.UtcDateTime).ToList(); observer.OnNext(toRemove.Select(kv => new KeyValuePair(kv.Key, kv.Value.Value)).ToList()); } @@ -99,10 +79,10 @@ void RemovalAction() } var removalSubscription = new SingleAssignmentDisposable(); - if (_interval.HasValue) + if (interval.HasValue) { // use polling - removalSubscription.Disposable = _scheduler.ScheduleRecurringAction(_interval.Value, RemovalAction); + removalSubscription.Disposable = scheduler.ScheduleRecurringAction(interval.Value, RemovalAction); } else { @@ -110,8 +90,8 @@ void RemovalAction() removalSubscription.Disposable = autoRemover.Connect().DistinctValues(ei => ei.ExpireAt).SubscribeMany( datetime => { - var expireAt = datetime.Subtract(_scheduler.Now.UtcDateTime); - return Observable.Timer(expireAt, _scheduler).Take(1).Subscribe(_ => RemovalAction()); + var expireAt = datetime.Subtract(scheduler.Now.UtcDateTime); + return Observable.Timer(expireAt, scheduler).Take(1).Subscribe(_ => RemovalAction()); }).Subscribe(); } @@ -122,5 +102,4 @@ void RemovalAction() autoRemover.Dispose(); }); }); - } } diff --git a/src/DynamicData/Cache/Internal/ToObservableChangeSet.cs b/src/DynamicData/Cache/Internal/ToObservableChangeSet.cs index 31cac2814..d9d7cdeaf 100644 --- a/src/DynamicData/Cache/Internal/ToObservableChangeSet.cs +++ b/src/DynamicData/Cache/Internal/ToObservableChangeSet.cs @@ -8,15 +8,17 @@ namespace DynamicData.Cache.Internal; -internal class ToObservableChangeSet +internal class ToObservableChangeSet(IObservable> source, + Func keySelector, + Func? expireAfter, + int limitSizeTo, + IScheduler? scheduler = null) where TObject : notnull where TKey : notnull { - private readonly IObservable> _source; - private readonly Func _keySelector; - private readonly Func? _expireAfter; - private readonly int _limitSizeTo; - private readonly IScheduler _scheduler; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); + private readonly Func _keySelector = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); + private readonly IScheduler _scheduler = scheduler ?? Scheduler.Default; public ToObservableChangeSet(IObservable source, Func keySelector, @@ -27,96 +29,80 @@ public ToObservableChangeSet(IObservable source, { } - public ToObservableChangeSet(IObservable> source, - Func keySelector, - Func? expireAfter, - int limitSizeTo, - IScheduler? scheduler = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _keySelector = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); - _expireAfter = expireAfter; - _limitSizeTo = limitSizeTo; - _scheduler = scheduler ?? Scheduler.Default; - } - - public IObservable> Run() - { - return Observable.Create>(observer => - { - var locker = new object(); - - var dataSource = new SourceCache(_keySelector); - - // load local data source with current items - var populator = _source.Synchronize(locker) - .Subscribe(items => dataSource.AddOrUpdate(items), observer.OnError); - - // handle size expiration - var sizeExpiryDisposer = new CompositeDisposable(); - - if (_limitSizeTo > 0) - { - long orderItemWasAdded = -1; - - var transformed = dataSource.Connect() - .Transform(t => (Item: t, Order: Interlocked.Increment(ref orderItemWasAdded))) - .AsObservableCache(); - - var transformedRemoved = transformed.Connect() - .Subscribe(_ => - { - if (transformed.Count <= _limitSizeTo) return; - - // remove oldest items - var itemsToRemove = transformed.KeyValues - .OrderBy(exp => exp.Value.Order) - .Take(transformed.Count - _limitSizeTo) - .Select(x => x.Key) - .ToArray(); - - // schedule, otherwise we can get a deadlock when removing due to re-entrancey - _scheduler.Schedule(() => dataSource.Remove(itemsToRemove)); - }); - sizeExpiryDisposer.Add(transformed); - sizeExpiryDisposer.Add(transformedRemoved); - } - - // handle time expiration - var timeExpiryDisposer = new CompositeDisposable(); - - DateTime Trim(DateTime date, long ticks) => new(date.Ticks - (date.Ticks % ticks), date.Kind); - - if (_expireAfter is not null) - { - var expiry = dataSource.Connect() - .Transform(t => - { - var removeAt = _expireAfter?.Invoke(t); - - if (removeAt is null) - return (Item: t, ExpireAt: DateTime.MaxValue); - - // get absolute expiry, and round by milliseconds to we can attempt to batch as many items into a single group - var expireTime = Trim(_scheduler.Now.UtcDateTime.Add(removeAt.Value), TimeSpan.TicksPerMillisecond); - - return (Item: t, ExpireAt: expireTime); - }) - .Filter(ei => ei.ExpireAt != DateTime.MaxValue) - .GroupWithImmutableState(ei => ei.ExpireAt) - .MergeMany(grouping => Observable.Timer(grouping.Key, _scheduler).Select(_ => grouping)) - .Synchronize(locker) - .Subscribe(grouping => dataSource.Remove(grouping.Keys)); - - timeExpiryDisposer.Add(expiry); - } - - return new CompositeDisposable( - dataSource, - populator, - sizeExpiryDisposer, - timeExpiryDisposer, - dataSource.Connect().SubscribeSafe(observer)); - }); - } + public IObservable> Run() => Observable.Create>(observer => + { + var locker = new object(); + + var dataSource = new SourceCache(_keySelector); + + // load local data source with current items + var populator = _source.Synchronize(locker) + .Subscribe(items => dataSource.AddOrUpdate(items), observer.OnError); + + // handle size expiration + var sizeExpiryDisposer = new CompositeDisposable(); + + if (limitSizeTo > 0) + { + long orderItemWasAdded = -1; + + var transformed = dataSource.Connect() + .Transform(t => (Item: t, Order: Interlocked.Increment(ref orderItemWasAdded))) + .AsObservableCache(); + + var transformedRemoved = transformed.Connect() + .Subscribe(_ => + { + if (transformed.Count <= limitSizeTo) return; + + // remove oldest items + var itemsToRemove = transformed.KeyValues + .OrderBy(exp => exp.Value.Order) + .Take(transformed.Count - limitSizeTo) + .Select(x => x.Key) + .ToArray(); + + // schedule, otherwise we can get a deadlock when removing due to re-entrancey + _scheduler.Schedule(() => dataSource.Remove(itemsToRemove)); + }); + sizeExpiryDisposer.Add(transformed); + sizeExpiryDisposer.Add(transformedRemoved); + } + + // handle time expiration + var timeExpiryDisposer = new CompositeDisposable(); + + DateTime Trim(DateTime date, long ticks) => new(date.Ticks - (date.Ticks % ticks), date.Kind); + + if (expireAfter is not null) + { + var expiry = dataSource.Connect() + .Transform(t => + { + var removeAt = expireAfter?.Invoke(t); + + if (removeAt is null) + return (Item: t, ExpireAt: DateTime.MaxValue); + + // get absolute expiry, and round by milliseconds to we can attempt to batch as many items into a single group + var expireTime = Trim(_scheduler.Now.UtcDateTime.Add(removeAt.Value), TimeSpan.TicksPerMillisecond); + + return (Item: t, ExpireAt: expireTime); + }) + .Filter(ei => ei.ExpireAt != DateTime.MaxValue) + .GroupWithImmutableState(ei => ei.ExpireAt) + .MergeMany(grouping => Observable.Timer(grouping.Key, _scheduler).Select(_ => grouping)) + .Synchronize(locker) + .Subscribe(grouping => dataSource.Remove(grouping.Keys)); + + timeExpiryDisposer.Add(expiry); + } + + return new CompositeDisposable( + dataSource, + populator, + sizeExpiryDisposer, + timeExpiryDisposer, + dataSource.Connect().SubscribeSafe(observer)); + }); } diff --git a/src/DynamicData/Cache/Internal/ToObservableOptional.cs b/src/DynamicData/Cache/Internal/ToObservableOptional.cs index 2cfa9440f..cd47c8d93 100644 --- a/src/DynamicData/Cache/Internal/ToObservableOptional.cs +++ b/src/DynamicData/Cache/Internal/ToObservableOptional.cs @@ -7,33 +7,20 @@ namespace DynamicData.Cache.Internal; -internal class ToObservableOptional +internal class ToObservableOptional(IObservable> source, TKey key, IEqualityComparer? equalityComparer = null) where TObject : notnull where TKey : notnull { - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); + private readonly TKey _key = key; - private readonly IEqualityComparer? _equalityComparer; - - private readonly TKey _key; - - public ToObservableOptional(IObservable> source, TKey key, IEqualityComparer? equalityComparer = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _equalityComparer = equalityComparer; - _key = key; - } - - public IObservable> Run() - { - return Observable.Create>(observer => - _source.Subscribe(changes => - changes.Where(ShouldEmitChange).ForEach(change => observer.OnNext(change switch - { - { Reason: ChangeReason.Remove } => Optional.None(), - _ => Optional.Some(change.Current), - })), observer.OnError, observer.OnCompleted)); - } + public IObservable> Run() => Observable.Create>(observer => + _source.Subscribe(changes => + changes.Where(ShouldEmitChange).ForEach(change => observer.OnNext(change switch + { + { Reason: ChangeReason.Remove } => Optional.None(), + _ => Optional.Some(change.Current), + })), observer.OnError, observer.OnCompleted)); private bool ShouldEmitChange(Change change) => change switch { @@ -41,7 +28,7 @@ public IObservable> Run() { Reason: ChangeReason.Add } => true, { Reason: ChangeReason.Remove } => true, { Reason: ChangeReason.Update, Previous.HasValue: false } => true, - { Reason: ChangeReason.Update } when _equalityComparer is not null => !_equalityComparer.Equals(change.Current, change.Previous.Value), + { Reason: ChangeReason.Update } when equalityComparer is not null => !equalityComparer.Equals(change.Current, change.Previous.Value), { Reason: ChangeReason.Update } => !ReferenceEquals(change.Current, change.Previous.Value), _ => false, }; diff --git a/src/DynamicData/Cache/Internal/Transform.cs b/src/DynamicData/Cache/Internal/Transform.cs index b535abce9..b94620e75 100644 --- a/src/DynamicData/Cache/Internal/Transform.cs +++ b/src/DynamicData/Cache/Internal/Transform.cs @@ -2,39 +2,20 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Linq; using DynamicData.Kernel; namespace DynamicData.Cache.Internal; -internal sealed class Transform +internal sealed class Transform(IObservable> source, Func, TKey, TDestination> transformFactory, Action>? exceptionCallback = null, bool transformOnRefresh = false) where TDestination : notnull where TSource : notnull where TKey : notnull { - private readonly Action>? _exceptionCallback; - - private readonly IObservable> _source; - - private readonly Func, TKey, TDestination> _transformFactory; - - private readonly bool _transformOnRefresh; - - public Transform(IObservable> source, Func, TKey, TDestination> transformFactory, Action>? exceptionCallback = null, bool transformOnRefresh = false) - { - _source = source; - _exceptionCallback = exceptionCallback; - _transformOnRefresh = transformOnRefresh; - _transformFactory = transformFactory; - } - public IObservable> Run() => Observable.Defer(RunImpl); - private IObservable> RunImpl() - { - return _source.Scan( + private IObservable> RunImpl() => source.Scan( (ChangeAwareCache?)null, (cache, changes) => { @@ -48,21 +29,21 @@ private IObservable> RunImpl() case ChangeReason.Update: { TDestination transformed; - if (_exceptionCallback is not null) + if (exceptionCallback is not null) { try { - transformed = _transformFactory(change.Current, change.Previous, change.Key); + transformed = transformFactory(change.Current, change.Previous, change.Key); cache.AddOrUpdate(transformed, change.Key); } catch (Exception ex) { - _exceptionCallback(new Error(ex, change.Current, change.Key)); + exceptionCallback(new Error(ex, change.Current, change.Key)); } } else { - transformed = _transformFactory(change.Current, change.Previous, change.Key); + transformed = transformFactory(change.Current, change.Previous, change.Key); cache.AddOrUpdate(transformed, change.Key); } } @@ -75,9 +56,9 @@ private IObservable> RunImpl() case ChangeReason.Refresh: { - if (_transformOnRefresh) + if (transformOnRefresh) { - var transformed = _transformFactory(change.Current, change.Previous, change.Key); + var transformed = transformFactory(change.Current, change.Previous, change.Key); cache.AddOrUpdate(transformed, change.Key); } else @@ -98,5 +79,4 @@ private IObservable> RunImpl() }) .Where(x => x is not null) .Select(cache => cache!.CaptureChanges()); - } } diff --git a/src/DynamicData/Cache/Internal/TransformAsync.cs b/src/DynamicData/Cache/Internal/TransformAsync.cs index 87459e21c..306446c1c 100644 --- a/src/DynamicData/Cache/Internal/TransformAsync.cs +++ b/src/DynamicData/Cache/Internal/TransformAsync.cs @@ -8,70 +8,51 @@ namespace DynamicData.Cache.Internal; -internal class TransformAsync +internal class TransformAsync(IObservable> source, Func, TKey, Task> transformFactory, Action>? exceptionCallback, IObservable>? forceTransform = null) where TDestination : notnull where TSource : notnull where TKey : notnull { - private readonly Action>? _exceptionCallback; - - private readonly IObservable>? _forceTransform; - - private readonly IObservable> _source; - - private readonly Func, TKey, Task> _transformFactory; - - public TransformAsync(IObservable> source, Func, TKey, Task> transformFactory, Action>? exceptionCallback, IObservable>? forceTransform = null) - { - _source = source; - _exceptionCallback = exceptionCallback; - _transformFactory = transformFactory; - _forceTransform = forceTransform; - } - - public IObservable> Run() - { - return Observable.Create>(observer => - { - var cache = new ChangeAwareCache(); - var asyncLock = new SemaphoreSlim(1, 1); - - var transformer = _source.Select(async changes => - { - try - { - await asyncLock.WaitAsync(); - return await DoTransform(cache, changes).ConfigureAwait(false); - } - finally - { - asyncLock.Release(); - } - }).Concat(); - - if (_forceTransform is not null) - { - var locker = new object(); - var forced = _forceTransform.Synchronize(locker) - .Select(async shouldTransform => - { - try - { - await asyncLock.WaitAsync(); - return await DoTransform(cache, shouldTransform).ConfigureAwait(false); - } - finally - { - asyncLock.Release(); - } - }).Concat(); - - transformer = transformer.Synchronize(locker).Merge(forced); - } - - return transformer.SubscribeSafe(observer); - }); - } + public IObservable> Run() => Observable.Create>(observer => + { + var cache = new ChangeAwareCache(); + var asyncLock = new SemaphoreSlim(1, 1); + + var transformer = source.Select(async changes => + { + try + { + await asyncLock.WaitAsync(); + return await DoTransform(cache, changes).ConfigureAwait(false); + } + finally + { + asyncLock.Release(); + } + }).Concat(); + + if (forceTransform is not null) + { + var locker = new object(); + var forced = forceTransform.Synchronize(locker) + .Select(async shouldTransform => + { + try + { + await asyncLock.WaitAsync(); + return await DoTransform(cache, shouldTransform).ConfigureAwait(false); + } + finally + { + asyncLock.Release(); + } + }).Concat(); + + transformer = transformer.Synchronize(locker).Merge(forced); + } + + return transformer.SubscribeSafe(observer); + }); private async Task> DoTransform(ChangeAwareCache cache, Func shouldTransform) { @@ -95,7 +76,7 @@ private IChangeSet ProcessUpdates(ChangeAwareCache !t.Success).ToArray(); if (errors.Length > 0) { - errors.ForEach(t => _exceptionCallback?.Invoke(new Error(t.Error, t.Change.Current, t.Change.Key))); + errors.ForEach(t => exceptionCallback?.Invoke(new Error(t.Error, t.Change.Current, t.Change.Key))); } foreach (var result in transformedItems.Where(t => t.Success)) @@ -130,7 +111,7 @@ private async Task Transform(Change change) { if (change.Reason == ChangeReason.Add || change.Reason == ChangeReason.Update) { - var destination = await _transformFactory(change.Current, change.Previous, change.Key).ConfigureAwait(false); + var destination = await transformFactory(change.Current, change.Previous, change.Key).ConfigureAwait(false); return new TransformResult(change, new TransformedItemContainer(change.Current, destination)); } @@ -139,7 +120,7 @@ private async Task Transform(Change change) catch (Exception ex) { // only handle errors if a handler has been specified - if (_exceptionCallback is not null) + if (exceptionCallback is not null) { return new TransformResult(change, ex); } @@ -148,17 +129,11 @@ private async Task Transform(Change change) } } - private readonly struct TransformedItemContainer + private readonly struct TransformedItemContainer(TSource source, TDestination destination) { - public TransformedItemContainer(TSource source, TDestination destination) - { - Source = source; - Destination = destination; - } - - public TDestination Destination { get; } + public TDestination Destination { get; } = destination; - public TSource Source { get; } + public TSource Source { get; } = source; } private sealed class TransformResult diff --git a/src/DynamicData/Cache/Internal/TransformMany.cs b/src/DynamicData/Cache/Internal/TransformMany.cs index 31cf4e83a..5c1e5189d 100644 --- a/src/DynamicData/Cache/Internal/TransformMany.cs +++ b/src/DynamicData/Cache/Internal/TransformMany.cs @@ -2,11 +2,8 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Collections; -using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -15,20 +12,12 @@ namespace DynamicData.Cache.Internal; -internal class TransformMany +internal class TransformMany(IObservable> source, Func> manySelector, Func keySelector, Func>>? childChanges = null) where TDestination : notnull where TDestinationKey : notnull where TSource : notnull where TSourceKey : notnull { - private readonly Func>>? _childChanges; - - private readonly Func _keySelector; - - private readonly Func> _manySelector; - - private readonly IObservable> _source; - public TransformMany(IObservable> source, Func> manySelector, Func keySelector) : this( source, @@ -88,33 +77,19 @@ public TransformMany(IObservable> source, Func> source, Func> manySelector, Func keySelector, Func>>? childChanges = null) - { - _source = source; - _manySelector = manySelector; - _keySelector = keySelector; - _childChanges = childChanges; - } + public IObservable> Run() => childChanges is null ? Create() : CreateWithChangeSet(); - public IObservable> Run() - { - return _childChanges is null ? Create() : CreateWithChangeSet(); - } - - private IObservable> Create() - { - return _source.Transform( + private IObservable> Create() => source.Transform( (t, _) => { - var destination = _manySelector(t).Select(m => new DestinationContainer(m, _keySelector(m))).ToArray(); + var destination = manySelector(t).Select(m => new DestinationContainer(m, keySelector(m))).ToArray(); return new ManyContainer(() => destination); }, true).Select(changes => new ChangeSet(new DestinationEnumerator(changes))); - } private IObservable> CreateWithChangeSet() { - if (_childChanges is null) + if (childChanges is null) { throw new InvalidOperationException("The childChanges is null and should not be."); } @@ -124,19 +99,19 @@ private IObservable> CreateWithChangeS { var result = new ChangeAwareCache(); - var transformed = _source.Transform( + var transformed = source.Transform( (t, _) => { // Only skip initial for first time Adds where there is initial data records var locker = new object(); - var changes = _childChanges(t).Synchronize(locker).Skip(1); + var changes = childChanges(t).Synchronize(locker).Skip(1); return new ManyContainer( () => { - var collection = _manySelector(t); + var collection = manySelector(t); lock (locker) { - return collection.Select(m => new DestinationContainer(m, _keySelector(m))).ToArray(); + return collection.Select(m => new DestinationContainer(m, keySelector(m))).ToArray(); } }, changes); @@ -158,19 +133,13 @@ private IObservable> CreateWithChangeS }); } - private sealed class DestinationContainer + private sealed class DestinationContainer(TDestination item, TDestinationKey key) { - public DestinationContainer(TDestination item, TDestinationKey key) - { - Item = item; - Key = key; - } - public static IEqualityComparer KeyComparer { get; } = new KeyEqualityComparer(); - public TDestination Item { get; } + public TDestination Item { get; } = item; - public TDestinationKey Key { get; } + public TDestinationKey Key { get; } = key; private sealed class KeyEqualityComparer : IEqualityComparer { @@ -189,25 +158,15 @@ public bool Equals(DestinationContainer? x, DestinationContainer? y) return EqualityComparer.Default.Equals(x.Key, y.Key); } - public int GetHashCode(DestinationContainer obj) - { - return EqualityComparer.Default.GetHashCode(obj.Key); - } + public int GetHashCode(DestinationContainer obj) => EqualityComparer.Default.GetHashCode(obj.Key); } } - private sealed class DestinationEnumerator : IEnumerable> + private sealed class DestinationEnumerator(IChangeSet changes) : IEnumerable> { - private readonly IChangeSet _changes; - - public DestinationEnumerator(IChangeSet changes) - { - _changes = changes; - } - public IEnumerator> GetEnumerator() { - foreach (var change in _changes.ToConcreteType()) + foreach (var change in changes.ToConcreteType()) { switch (change.Reason) { @@ -259,24 +218,13 @@ public IEnumerator> GetEnumerator() } } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } - private sealed class ManyContainer + private sealed class ManyContainer(Func> initial, IObservable>? changes = null) { - private readonly Func> _initial; - - public ManyContainer(Func> initial, IObservable>? changes = null) - { - _initial = initial; - Changes = changes ?? Observable.Empty>(); - } - - public IObservable> Changes { get; } + public IObservable> Changes { get; } = changes ?? Observable.Empty>(); - public IEnumerable Destination => _initial(); + public IEnumerable Destination => initial(); } } diff --git a/src/DynamicData/Cache/Internal/TransformWithForcedTransform.cs b/src/DynamicData/Cache/Internal/TransformWithForcedTransform.cs index f14778671..59f9ffc5c 100644 --- a/src/DynamicData/Cache/Internal/TransformWithForcedTransform.cs +++ b/src/DynamicData/Cache/Internal/TransformWithForcedTransform.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -11,50 +9,31 @@ namespace DynamicData.Cache.Internal; -internal sealed class TransformWithForcedTransform +internal sealed class TransformWithForcedTransform(IObservable> source, Func, TKey, TDestination> transformFactory, IObservable> forceTransform, Action>? exceptionCallback = null) where TDestination : notnull where TSource : notnull where TKey : notnull { - private readonly Action>? _exceptionCallback; - - private readonly IObservable> _forceTransform; - - private readonly IObservable> _source; - - private readonly Func, TKey, TDestination> _transformFactory; - - public TransformWithForcedTransform(IObservable> source, Func, TKey, TDestination> transformFactory, IObservable> forceTransform, Action>? exceptionCallback = null) - { - _source = source; - _exceptionCallback = exceptionCallback; - _transformFactory = transformFactory; - _forceTransform = forceTransform; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); - var shared = _source.Synchronize(locker).Publish(); + var shared = source.Synchronize(locker).Publish(); // capture all items so we can apply a forced transform var cache = new Cache(); var cacheLoader = shared.Subscribe(changes => cache.Clone(changes)); // create change set of items where force refresh is applied - var refresher = _forceTransform.Synchronize(locker).Select(selector => CaptureChanges(cache, selector)).Select(changes => new ChangeSet(changes)).NotEmpty(); + var refresher = forceTransform.Synchronize(locker).Select(selector => CaptureChanges(cache, selector)).Select(changes => new ChangeSet(changes)).NotEmpty(); var sourceAndRefreshes = shared.Merge(refresher); // do raw transform - var transform = new Transform(sourceAndRefreshes, _transformFactory, _exceptionCallback, true).Run(); + var transform = new Transform(sourceAndRefreshes, transformFactory, exceptionCallback, true).Run(); return new CompositeDisposable(cacheLoader, transform.SubscribeSafe(observer), shared.Connect()); }); - } private static IEnumerable> CaptureChanges(Cache cache, Func shouldTransform) { diff --git a/src/DynamicData/Cache/Internal/TransformWithInlineUpdate.cs b/src/DynamicData/Cache/Internal/TransformWithInlineUpdate.cs index 5b71e2b42..ae589bbfa 100644 --- a/src/DynamicData/Cache/Internal/TransformWithInlineUpdate.cs +++ b/src/DynamicData/Cache/Internal/TransformWithInlineUpdate.cs @@ -5,39 +5,20 @@ using System.Reactive.Linq; using DynamicData.Kernel; -using DynamicData.List.Internal; namespace DynamicData.Cache.Internal; -internal sealed class TransformWithInlineUpdate +internal sealed class TransformWithInlineUpdate(IObservable> source, + Func transformFactory, + Action updateAction, + Action>? exceptionCallback = null) where TDestination : class where TSource : notnull where TKey : notnull { - private readonly Action>? _exceptionCallback; - - private readonly IObservable> _source; - - private readonly Func _transformFactory; - - private readonly Action _updateAction; - - public TransformWithInlineUpdate(IObservable> source, - Func transformFactory, - Action updateAction, - Action>? exceptionCallback = null) - { - _source = source; - _exceptionCallback = exceptionCallback; - _updateAction = updateAction; - _transformFactory = transformFactory; - } - public IObservable> Run() => Observable.Defer(RunImpl); - private IObservable> RunImpl() - { - return _source.Scan( + private IObservable> RunImpl() => source.Scan( (ChangeAwareCache?)null, (cache, changes) => { @@ -73,26 +54,25 @@ private IObservable> RunImpl() }) .Where(x => x is not null) .Select(cache => cache!.CaptureChanges()); - } private void Transform(ChangeAwareCache cache, Change change) { TDestination transformed; - if (_exceptionCallback is not null) + if (exceptionCallback is not null) { try { - transformed = _transformFactory(change.Current); + transformed = transformFactory(change.Current); cache.AddOrUpdate(transformed, change.Key); } catch (Exception ex) { - _exceptionCallback(new Error(ex, change.Current, change.Key)); + exceptionCallback(new Error(ex, change.Current, change.Key)); } } else { - transformed = _transformFactory(change.Current); + transformed = transformFactory(change.Current); cache.AddOrUpdate(transformed, change.Key); } } @@ -101,20 +81,20 @@ private void InlineUpdate(ChangeAwareCache cache, Change new MissingKeyException($"{change.Key} is not found.")); - if (_exceptionCallback is not null) + if (exceptionCallback is not null) { try { - _updateAction(previous, change.Current); + updateAction(previous, change.Current); } catch (Exception ex) { - _exceptionCallback(new Error(ex, change.Current, change.Key)); + exceptionCallback(new Error(ex, change.Current, change.Key)); } } else { - _updateAction(previous, change.Current); + updateAction(previous, change.Current); } cache.Refresh(change.Key); diff --git a/src/DynamicData/Cache/Internal/TreeBuilder.cs b/src/DynamicData/Cache/Internal/TreeBuilder.cs index fb84da689..72f903e41 100644 --- a/src/DynamicData/Cache/Internal/TreeBuilder.cs +++ b/src/DynamicData/Cache/Internal/TreeBuilder.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Linq; using System.Reactive; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -13,28 +11,19 @@ namespace DynamicData.Cache.Internal; -internal class TreeBuilder +internal class TreeBuilder(IObservable> source, Func pivotOn, IObservable, bool>>? predicateChanged) where TObject : class where TKey : notnull { - private readonly Func _pivotOn; + private readonly Func _pivotOn = pivotOn ?? throw new ArgumentNullException(nameof(pivotOn)); - private readonly IObservable, bool>> _predicateChanged; + private readonly IObservable, bool>> _predicateChanged = predicateChanged ?? Observable.Return(DefaultPredicate); - private readonly IObservable> _source; - - public TreeBuilder(IObservable> source, Func pivotOn, IObservable, bool>>? predicateChanged) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _pivotOn = pivotOn ?? throw new ArgumentNullException(nameof(pivotOn)); - _predicateChanged = predicateChanged ?? Observable.Return(DefaultPredicate); - } + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); private static Func, bool> DefaultPredicate => node => node.IsRoot; - public IObservable, TKey>> Run() - { - return Observable.Create, TKey>>( + public IObservable, TKey>> Run() => Observable.Create, TKey>>( observer => { var locker = new object(); @@ -224,5 +213,4 @@ void UpdateChildren(Node parentNode) reFilterObservable.OnCompleted(); }); }); - } } diff --git a/src/DynamicData/Cache/Internal/TrueFor.cs b/src/DynamicData/Cache/Internal/TrueFor.cs index 445e68628..5c7c7b54a 100644 --- a/src/DynamicData/Cache/Internal/TrueFor.cs +++ b/src/DynamicData/Cache/Internal/TrueFor.cs @@ -2,34 +2,23 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Disposables; using System.Reactive.Linq; namespace DynamicData.Cache.Internal; -internal class TrueFor +internal class TrueFor(IObservable> source, Func> observableSelector, Func>, bool> collectionMatcher) where TObject : notnull where TKey : notnull where TValue : notnull { - private readonly Func>, bool> _collectionMatcher; + private readonly Func>, bool> _collectionMatcher = collectionMatcher ?? throw new ArgumentNullException(nameof(collectionMatcher)); - private readonly Func> _observableSelector; + private readonly Func> _observableSelector = observableSelector ?? throw new ArgumentNullException(nameof(observableSelector)); - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public TrueFor(IObservable> source, Func> observableSelector, Func>, bool> collectionMatcher) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _observableSelector = observableSelector ?? throw new ArgumentNullException(nameof(observableSelector)); - _collectionMatcher = collectionMatcher ?? throw new ArgumentNullException(nameof(collectionMatcher)); - } - - public IObservable Run() - { - return Observable.Create( + public IObservable Run() => Observable.Create( observer => { var transformed = _source.Transform(t => new ObservableWithValue(t, _observableSelector(t))).Publish(); @@ -41,5 +30,4 @@ public IObservable Run() return new CompositeDisposable(publisher, transformed.Connect()); }); - } } diff --git a/src/DynamicData/Cache/Internal/UniquenessEnforcer.cs b/src/DynamicData/Cache/Internal/UniquenessEnforcer.cs index 8329d6342..e86c2d1a1 100644 --- a/src/DynamicData/Cache/Internal/UniquenessEnforcer.cs +++ b/src/DynamicData/Cache/Internal/UniquenessEnforcer.cs @@ -6,24 +6,19 @@ namespace DynamicData.Cache.Internal; -internal class UniquenessEnforcer +internal class UniquenessEnforcer(IObservable> source) where TObject : notnull where TKey : notnull { - private readonly IObservable> _source; - - public UniquenessEnforcer(IObservable> source) => _source = source; - - public IObservable> Run() - { + public IObservable> Run() => /* - * If we handle refreshes, we cannot use .Last() as the last in the groupd may be a refresh, - * and a previous in the group may add or update. Suddenly this scenario becomes very complicated - * so for this phase we'll ignore these. - * - */ +* If we handle refreshes, we cannot use .Last() as the last in the groupd may be a refresh, +* and a previous in the group may add or update. Suddenly this scenario becomes very complicated +* so for this phase we'll ignore these. +* +*/ - return _source + source .WhereReasonsAreNot(ChangeReason.Refresh, ChangeReason.Moved) .Scan( new ChangeAwareCache(), @@ -48,5 +43,4 @@ public IObservable> Run() return cache; }) .Select(state => state.CaptureChanges()); - } } diff --git a/src/DynamicData/Cache/Internal/Virtualise.cs b/src/DynamicData/Cache/Internal/Virtualise.cs index 1550e7403..a1b9c45fc 100644 --- a/src/DynamicData/Cache/Internal/Virtualise.cs +++ b/src/DynamicData/Cache/Internal/Virtualise.cs @@ -2,29 +2,19 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Linq; using System.Reactive.Linq; namespace DynamicData.Cache.Internal; -internal sealed class Virtualise +internal sealed class Virtualise(IObservable> source, IObservable virtualRequests) where TObject : notnull where TKey : notnull { - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly IObservable _virtualRequests; + private readonly IObservable _virtualRequests = virtualRequests ?? throw new ArgumentNullException(nameof(virtualRequests)); - public Virtualise(IObservable> source, IObservable virtualRequests) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _virtualRequests = virtualRequests ?? throw new ArgumentNullException(nameof(virtualRequests)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var virtualiser = new Virtualiser(); @@ -34,9 +24,8 @@ public IObservable> Run() var dataChange = _source.Synchronize(locker).Select(virtualiser.Update).Where(x => x is not null).Select(x => x!); return request.Merge(dataChange).Where(updates => updates is not null).SubscribeSafe(observer); }); - } - private sealed class Virtualiser + private sealed class Virtualiser(VirtualRequest? request = null) { private IKeyValueCollection _all = new KeyValueCollection(); @@ -44,12 +33,7 @@ private sealed class Virtualiser private bool _isLoaded; - private IVirtualRequest _parameters; - - public Virtualiser(VirtualRequest? request = null) - { - _parameters = request ?? new VirtualRequest(); - } + private IVirtualRequest _parameters = request ?? new VirtualRequest(); public IVirtualChangeSet? Update(ISortedChangeSet updates) { diff --git a/src/DynamicData/Cache/MissingKeyException.cs b/src/DynamicData/Cache/MissingKeyException.cs index 54e6d8d9e..18ae1126e 100644 --- a/src/DynamicData/Cache/MissingKeyException.cs +++ b/src/DynamicData/Cache/MissingKeyException.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - // ReSharper disable once CheckNamespace namespace DynamicData; @@ -38,14 +36,4 @@ public MissingKeyException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the class. - /// - /// The serialization info. - /// The serialization context. - protected MissingKeyException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) - : base(serializationInfo, streamingContext) - { - } } diff --git a/src/DynamicData/Cache/Node.cs b/src/DynamicData/Cache/Node.cs index b1e3eb712..675badf98 100644 --- a/src/DynamicData/Cache/Node.cs +++ b/src/DynamicData/Cache/Node.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Disposables; using DynamicData.Kernel; @@ -181,10 +179,7 @@ public override bool Equals(object? obj) /// Serves as the default hash function. /// A hash code for the current object. /// 2. - public override int GetHashCode() - { - return EqualityComparer.Default.GetHashCode(Key); - } + public override int GetHashCode() => EqualityComparer.Default.GetHashCode(Key); /// /// Returns a that represents this instance. @@ -198,10 +193,7 @@ public override string ToString() return $"{Item}{count}"; } - internal void Update(Action, TKey>> updateAction) - { - _children.Edit(updateAction); - } + internal void Update(Action, TKey>> updateAction) => _children.Edit(updateAction); /// /// Disposes any managed or unmanaged resources. diff --git a/src/DynamicData/Cache/ObservableCache.cs b/src/DynamicData/Cache/ObservableCache.cs index 820286a54..9943b1ab7 100644 --- a/src/DynamicData/Cache/ObservableCache.cs +++ b/src/DynamicData/Cache/ObservableCache.cs @@ -130,10 +130,7 @@ public IObservable> Connect(Func? predi public Optional Lookup(TKey key) => _readerWriter.Lookup(key); - public IObservable> Preview(Func? predicate = null) - { - return predicate is null ? _changesPreview : _changesPreview.Filter(predicate); - } + public IObservable> Preview(Func? predicate = null) => predicate is null ? _changesPreview : _changesPreview.Filter(predicate); public IObservable> Watch(TKey key) => Observable.Create>( diff --git a/src/DynamicData/Cache/ObservableCacheEx.cs b/src/DynamicData/Cache/ObservableCacheEx.cs index 368f490f1..48d0de534 100644 --- a/src/DynamicData/Cache/ObservableCacheEx.cs +++ b/src/DynamicData/Cache/ObservableCacheEx.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; @@ -440,10 +438,7 @@ public static IObservable> AutoRefreshAn observable change set with additional refresh changes. public static IObservable> AutoRefreshOnObservable(this IObservable> source, Func> reevaluator, TimeSpan? changeSetBuffer = null, IScheduler? scheduler = null) where TObject : notnull - where TKey : notnull - { - return source.AutoRefreshOnObservable((t, _) => reevaluator(t), changeSetBuffer, scheduler); - } + where TKey : notnull => source.AutoRefreshOnObservable((t, _) => reevaluator(t), changeSetBuffer, scheduler); /// /// Automatically refresh downstream operator. The refresh is triggered when the observable receives a notification. @@ -510,10 +505,7 @@ public static IObservable> Batch(this I /// source. public static IObservable> BatchIf(this IObservable> source, IObservable pauseIfTrueSelector, IScheduler? scheduler = null) where TObject : notnull - where TKey : notnull - { - return BatchIf(source, pauseIfTrueSelector, false, scheduler); - } + where TKey : notnull => BatchIf(source, pauseIfTrueSelector, false, scheduler); /// /// Batches the underlying updates if a pause signal (i.e when the buffer selector return true) has been received. @@ -529,10 +521,7 @@ public static IObservable> BatchIf(this /// source. public static IObservable> BatchIf(this IObservable> source, IObservable pauseIfTrueSelector, bool initialPauseState = false, IScheduler? scheduler = null) where TObject : notnull - where TKey : notnull - { - return new BatchIf(source, pauseIfTrueSelector, null, initialPauseState, scheduler: scheduler).Run(); - } + where TKey : notnull => new BatchIf(source, pauseIfTrueSelector, null, initialPauseState, scheduler: scheduler).Run(); /// /// Batches the underlying updates if a pause signal (i.e when the buffer selector return true) has been received. @@ -548,10 +537,7 @@ public static IObservable> BatchIf(this /// source. public static IObservable> BatchIf(this IObservable> source, IObservable pauseIfTrueSelector, TimeSpan? timeOut = null, IScheduler? scheduler = null) where TObject : notnull - where TKey : notnull - { - return BatchIf(source, pauseIfTrueSelector, false, timeOut, scheduler); - } + where TKey : notnull => BatchIf(source, pauseIfTrueSelector, false, timeOut, scheduler); /// /// Batches the underlying updates if a pause signal (i.e when the buffer selector return true) has been received. @@ -598,10 +584,7 @@ public static IObservable> BatchIf(this /// source. public static IObservable> BatchIf(this IObservable> source, IObservable pauseIfTrueSelector, bool initialPauseState = false, IObservable? timer = null, IScheduler? scheduler = null) where TObject : notnull - where TKey : notnull - { - return new BatchIf(source, pauseIfTrueSelector, null, initialPauseState, timer, scheduler).Run(); - } + where TKey : notnull => new BatchIf(source, pauseIfTrueSelector, null, initialPauseState, timer, scheduler).Run(); /// /// Binds the results to the specified observable collection using the default update algorithm. @@ -878,16 +861,13 @@ public static IObservable> Bind(this IO /// An observable which emits change sets. public static IObservable> BufferInitial(this IObservable> source, TimeSpan initialBuffer, IScheduler? scheduler = null) where TObject : notnull - where TKey : notnull - { - return source.DeferUntilLoaded().Publish( + where TKey : notnull => source.DeferUntilLoaded().Publish( shared => { var initial = shared.Buffer(initialBuffer, scheduler ?? Scheduler.Default).FlattenBufferResult().Take(1); return initial.Concat(shared); }); - } /// /// Cast the object to the specified type. @@ -1531,10 +1511,7 @@ public static IObservable> Except(this /// public static IObservable> ExpireAfter(this IObservable> source, Func timeSelector) where TObject : notnull - where TKey : notnull - { - return ExpireAfter(source, timeSelector, Scheduler.Default); - } + where TKey : notnull => ExpireAfter(source, timeSelector, Scheduler.Default); /// /// Automatically removes items from the stream after the time specified by @@ -1585,10 +1562,7 @@ public static IObservable> ExpireAfter( /// timeSelector. public static IObservable> ExpireAfter(this IObservable> source, Func timeSelector, TimeSpan? pollingInterval) where TObject : notnull - where TKey : notnull - { - return ExpireAfter(source, timeSelector, pollingInterval, Scheduler.Default); - } + where TKey : notnull => ExpireAfter(source, timeSelector, pollingInterval, Scheduler.Default); /// /// Automatically removes items from the stream on the next poll after the time specified by @@ -1638,10 +1612,7 @@ public static IObservable> ExpireAfter( /// timeSelector. public static IObservable>> ExpireAfter(this ISourceCache source, Func timeSelector, IScheduler? scheduler = null) where TObject : notnull - where TKey : notnull - { - return source.ExpireAfter(timeSelector, null, scheduler); - } + where TKey : notnull => source.ExpireAfter(timeSelector, null, scheduler); /// /// Automatically removes items from the cache after the time specified by @@ -1660,10 +1631,7 @@ public static IObservable>> ExpireAfter< /// timeSelector. public static IObservable>> ExpireAfter(this ISourceCache source, Func timeSelector, TimeSpan? interval = null) where TObject : notnull - where TKey : notnull - { - return ExpireAfter(source, timeSelector, interval, Scheduler.Default); - } + where TKey : notnull => ExpireAfter(source, timeSelector, interval, Scheduler.Default); /// /// Ensures there are no duplicated keys in the observable changeset. @@ -2374,10 +2342,7 @@ public static IObservable> Gr /// An observable which emits change sets and ignores equal value changes. public static IObservable> IgnoreSameReferenceUpdate(this IObservable> source) where TObject : notnull - where TKey : notnull - { - return source.IgnoreUpdateWhen((c, p) => ReferenceEquals(c, p)); - } + where TKey : notnull => source.IgnoreUpdateWhen((c, p) => ReferenceEquals(c, p)); /// /// Ignores the update when the condition is met. @@ -2390,9 +2355,7 @@ public static IObservable> IgnoreSameReferenceUpdateAn observable which emits change sets and ignores updates equal to the lambda. public static IObservable> IgnoreUpdateWhen(this IObservable> source, Func ignoreFunction) where TObject : notnull - where TKey : notnull - { - return source.Select( + where TKey : notnull => source.Select( updates => { var result = updates.Where( @@ -2407,7 +2370,6 @@ public static IObservable> IgnoreUpdateWhen(result); }).NotEmpty(); - } /// /// Only includes the update when the condition is met. @@ -2625,10 +2587,7 @@ public static IObservable> InnerJoinManyAn observable which emits change sets. public static IObservable> InvokeEvaluate(this IObservable> source) where TObject : IEvaluateAware - where TKey : notnull - { - return source.Do(changes => changes.Where(u => u.Reason == ChangeReason.Refresh).ForEach(u => u.Current.Evaluate())); - } + where TKey : notnull => source.Do(changes => changes.Where(u => u.Reason == ChangeReason.Refresh).ForEach(u => u.Current.Evaluate())); /// /// Joins the left and right observable data sources, taking all left values and combining any matching right values. @@ -3424,10 +3383,7 @@ public static IObservable> MergeManyCh where TObject : notnull where TKey : notnull where TDestination : notnull - where TDestinationKey : notnull - { - return source.MergeManyChangeSets(observableSelector, sourceComparer, DefaultResortOnSourceRefresh, equalityComparer: null, childComparer); - } + where TDestinationKey : notnull => source.MergeManyChangeSets(observableSelector, sourceComparer, DefaultResortOnSourceRefresh, equalityComparer: null, childComparer); /// /// Overload of that @@ -3474,10 +3430,7 @@ public static IObservable> MergeManyCh where TObject : notnull where TKey : notnull where TDestination : notnull - where TDestinationKey : notnull - { - return source.MergeManyChangeSets(observableSelector, sourceComparer, resortOnSourceRefresh, equalityComparer: null, childComparer); - } + where TDestinationKey : notnull => source.MergeManyChangeSets(observableSelector, sourceComparer, resortOnSourceRefresh, equalityComparer: null, childComparer); /// /// Overload of that @@ -3524,10 +3477,7 @@ public static IObservable> MergeManyCh where TObject : notnull where TKey : notnull where TDestination : notnull - where TDestinationKey : notnull - { - return source.MergeManyChangeSets(observableSelector, sourceComparer, DefaultResortOnSourceRefresh, equalityComparer, childComparer); - } + where TDestinationKey : notnull => source.MergeManyChangeSets(observableSelector, sourceComparer, DefaultResortOnSourceRefresh, equalityComparer, childComparer); /// /// Overload of that @@ -3652,10 +3602,7 @@ public static IObservable> MergeManyItemsThe source. /// An observable which monitors the status of the observable. /// source. - public static IObservable MonitorStatus(this IObservable source) - { - return new StatusMonitor(source).Run(); - } + public static IObservable MonitorStatus(this IObservable source) => new StatusMonitor(source).Run(); /// /// Suppresses updates which are empty. @@ -4763,10 +4710,7 @@ public static IObservable> SortBy /// An observable which emits change sets. public static IObservable> StartWithEmpty(this IObservable> source) where TObject : notnull - where TKey : notnull - { - return source.StartWith(ChangeSet.Empty); - } + where TKey : notnull => source.StartWith(ChangeSet.Empty); /// /// Prepends an empty change set to the source. @@ -4777,10 +4721,7 @@ public static IObservable> StartWithEmptyAn observable which emits sorted change sets. public static IObservable> StartWithEmpty(this IObservable> source) where TObject : notnull - where TKey : notnull - { - return source.StartWith(SortedChangeSet.Empty); - } + where TKey : notnull => source.StartWith(SortedChangeSet.Empty); /// /// Prepends an empty change set to the source. @@ -4791,10 +4732,7 @@ public static IObservable> StartWithEmptyAn observable which emits virtual change sets. public static IObservable> StartWithEmpty(this IObservable> source) where TObject : notnull - where TKey : notnull - { - return source.StartWith(VirtualChangeSet.Empty); - } + where TKey : notnull => source.StartWith(VirtualChangeSet.Empty); /// /// Prepends an empty change set to the source. @@ -4805,10 +4743,7 @@ public static IObservable> StartWithEmptyAn observable which emits paged change sets. public static IObservable> StartWithEmpty(this IObservable> source) where TObject : notnull - where TKey : notnull - { - return source.StartWith(PagedChangeSet.Empty); - } + where TKey : notnull => source.StartWith(PagedChangeSet.Empty); /// /// Prepends an empty change set to the source. @@ -4821,10 +4756,7 @@ public static IObservable> StartWithEmpty> StartWithEmpty(this IObservable> source) where TObject : notnull where TKey : notnull - where TGroupKey : notnull - { - return source.StartWith(GroupChangeSet.Empty); - } + where TGroupKey : notnull => source.StartWith(GroupChangeSet.Empty); /// /// Prepends an empty change set to the source. @@ -4837,10 +4769,7 @@ public static IObservable> StartWithEm public static IObservable> StartWithEmpty(this IObservable> source) where TObject : notnull where TKey : notnull - where TGroupKey : notnull - { - return source.StartWith(ImmutableGroupChangeSet.Empty); - } + where TGroupKey : notnull => source.StartWith(ImmutableGroupChangeSet.Empty); /// /// Prepends an empty change set to the source. @@ -4848,10 +4777,7 @@ public static IObservable> St /// The type of the item. /// The source read only collection. /// A read only collection. - public static IObservable> StartWithEmpty(this IObservable> source) - { - return source.StartWith(ReadOnlyCollectionLight.Empty); - } + public static IObservable> StartWithEmpty(this IObservable> source) => source.StartWith(ReadOnlyCollectionLight.Empty); /// /// The equivalent of rx StartsWith operator, but wraps the item in a change where reason is ChangeReason.Add. @@ -4966,10 +4892,7 @@ public static IObservable> SubscribeManyAn observable which emits change sets. public static IObservable> SuppressRefresh(this IObservable> source) where TObject : notnull - where TKey : notnull - { - return source.WhereReasonsAreNot(ChangeReason.Refresh); - } + where TKey : notnull => source.WhereReasonsAreNot(ChangeReason.Refresh); /// /// Transforms an observable sequence of observable caches into a single sequence @@ -5028,10 +4951,7 @@ public static IObservable> Switch(this /// An observable which emits the read only collection. public static IObservable> ToCollection(this IObservable> source) where TObject : notnull - where TKey : notnull - { - return source.QueryWhenChanged(query => new ReadOnlyCollectionLight(query.Items)); - } + where TKey : notnull => source.QueryWhenChanged(query => new ReadOnlyCollectionLight(query.Items)); /// /// Converts the observable to an observable change set. @@ -5221,10 +5141,7 @@ public static IObservable> Top(t public static IObservable> ToSortedCollection(this IObservable> source, Func sort, SortDirection sortOrder = SortDirection.Ascending) where TObject : notnull where TKey : notnull - where TSortKey : notnull - { - return source.QueryWhenChanged(query => sortOrder == SortDirection.Ascending ? new ReadOnlyCollectionLight(query.Items.OrderBy(sort)) : new ReadOnlyCollectionLight(query.Items.OrderByDescending(sort))); - } + where TSortKey : notnull => source.QueryWhenChanged(query => sortOrder == SortDirection.Ascending ? new ReadOnlyCollectionLight(query.Items.OrderBy(sort)) : new ReadOnlyCollectionLight(query.Items.OrderByDescending(sort))); /// /// Converts the change set into a fully formed sorted collection. Each change in the source results in a new sorted collection. @@ -5236,16 +5153,13 @@ public static IObservable> ToSortedCollectionAn observable which emits the read only collection. public static IObservable> ToSortedCollection(this IObservable> source, IComparer comparer) where TObject : notnull - where TKey : notnull - { - return source.QueryWhenChanged( + where TKey : notnull => source.QueryWhenChanged( query => { var items = query.Items.AsList(); items.Sort(comparer); return new ReadOnlyCollectionLight(items); }); - } /// /// Projects each update item to a new form using the specified transform function. @@ -5468,10 +5382,7 @@ public static IObservable> Transform> Transform(this IObservable> source, Func transformFactory, IObservable forceTransform) where TDestination : notnull where TSource : notnull - where TKey : notnull - { - return source.Transform((cur, _, _) => transformFactory(cur), forceTransform.ForForced()); - } + where TKey : notnull => source.Transform((cur, _, _) => transformFactory(cur), forceTransform.ForForced()); /// /// Projects each update item to a new form using the specified transform function. @@ -5663,10 +5574,7 @@ public static IObservable> TransformMa where TDestination : notnull where TDestinationKey : notnull where TSource : notnull - where TSourceKey : notnull - { - return new TransformMany(source, manySelector, keySelector).Run(); - } + where TSourceKey : notnull => new TransformMany(source, manySelector, keySelector).Run(); /// /// Flatten the nested observable collection, and subsequently observe observable collection changes. @@ -5683,10 +5591,7 @@ public static IObservable> TransformMa where TDestination : notnull where TDestinationKey : notnull where TSource : notnull - where TSourceKey : notnull - { - return new TransformMany(source, manySelector, keySelector).Run(); - } + where TSourceKey : notnull => new TransformMany(source, manySelector, keySelector).Run(); /// /// Flatten the nested observable collection, and subsequently observe observable collection changes. @@ -5703,10 +5608,7 @@ public static IObservable> TransformMa where TDestination : notnull where TDestinationKey : notnull where TSource : notnull - where TSourceKey : notnull - { - return new TransformMany(source, manySelector, keySelector).Run(); - } + where TSourceKey : notnull => new TransformMany(source, manySelector, keySelector).Run(); /// /// Flatten the nested observable cache, and subsequently observe observable cache changes. @@ -5723,10 +5625,7 @@ public static IObservable> TransformMa where TDestination : notnull where TDestinationKey : notnull where TSource : notnull - where TSourceKey : notnull - { - return new TransformMany(source, manySelector, keySelector).Run(); - } + where TSourceKey : notnull => new TransformMany(source, manySelector, keySelector).Run(); /// /// Projects each update item to a new form using the specified transform function, @@ -5873,10 +5772,7 @@ public static IObservable> TransformSafe> TransformSafe(this IObservable> source, Func transformFactory, Action> errorHandler, IObservable forceTransform) where TDestination : notnull where TSource : notnull - where TKey : notnull - { - return source.TransformSafe((cur, _, _) => transformFactory(cur), errorHandler, forceTransform.ForForced()); - } + where TKey : notnull => source.TransformSafe((cur, _, _) => transformFactory(cur), errorHandler, forceTransform.ForForced()); /// /// Projects each update item to a new form using the specified transform function, @@ -6237,10 +6133,7 @@ IEnumerable> ReplaceMoves(IChangeSet items) public static IObservable TrueForAll(this IObservable> source, Func> observableSelector, Func equalityCondition) where TObject : notnull where TKey : notnull - where TValue : notnull - { - return source.TrueFor(observableSelector, items => items.All(o => o.LatestValue.HasValue && equalityCondition(o.LatestValue.Value))); - } + where TValue : notnull => source.TrueFor(observableSelector, items => items.All(o => o.LatestValue.HasValue && equalityCondition(o.LatestValue.Value))); /// /// Produces a boolean observable indicating whether the latest resulting value from all of the specified observables matches @@ -6260,10 +6153,7 @@ public static IObservable TrueForAll(this IObservab public static IObservable TrueForAll(this IObservable> source, Func> observableSelector, Func equalityCondition) where TObject : notnull where TKey : notnull - where TValue : notnull - { - return source.TrueFor(observableSelector, items => items.All(o => o.LatestValue.HasValue && equalityCondition(o.Item, o.LatestValue.Value))); - } + where TValue : notnull => source.TrueFor(observableSelector, items => items.All(o => o.LatestValue.HasValue && equalityCondition(o.Item, o.LatestValue.Value))); /// /// Produces a boolean observable indicating whether the resulting value of whether any of the specified observables matches @@ -6288,10 +6178,7 @@ public static IObservable TrueForAll(this IObservab public static IObservable TrueForAny(this IObservable> source, Func> observableSelector, Func equalityCondition) where TObject : notnull where TKey : notnull - where TValue : notnull - { - return source.TrueFor(observableSelector, items => items.Any(o => o.LatestValue.HasValue && equalityCondition(o.Item, o.LatestValue.Value))); - } + where TValue : notnull => source.TrueFor(observableSelector, items => items.Any(o => o.LatestValue.HasValue && equalityCondition(o.Item, o.LatestValue.Value))); /// /// Produces a boolean observable indicating whether the resulting value of whether any of the specified observables matches @@ -6345,10 +6232,7 @@ public static IObservable TrueForAny(this IObservab /// An observable which emits the sorted change set. public static IObservable> UpdateIndex(this IObservable> source) where TObject : IIndexAware - where TKey : notnull - { - return source.Do(changes => changes.SortedItems.Select((update, index) => new { update, index }).ForEach(u => u.update.Value.Index = u.index)); - } + where TKey : notnull => source.Do(changes => changes.SortedItems.Select((update, index) => new { update, index }).ForEach(u => u.update.Value.Index = u.index)); /// /// Virtualises the underlying data from the specified source. @@ -6704,10 +6588,7 @@ public static IObservable> Xor(this IOb /// timeSelector. internal static IObservable>> ForExpiry(this IObservable> source, Func timeSelector, TimeSpan? interval, IScheduler scheduler) where TObject : notnull - where TKey : notnull - { - return new TimeExpirer(source, timeSelector, interval, scheduler).ForExpiry(); - } + where TKey : notnull => new TimeExpirer(source, timeSelector, interval, scheduler).ForExpiry(); private static IObservable> Combine(this IObservableList> source, CombineOperator type) where TObject : notnull @@ -6842,32 +6723,23 @@ void UpdateAction(IChangeSet updates) } private static IObservable>? ForForced(this IObservable? source) - where TKey : notnull - { - return source?.Select( + where TKey : notnull => source?.Select( _ => { bool Transformer(TSource item, TKey key) => true; return (Func)Transformer; }); - } private static IObservable>? ForForced(this IObservable>? source) - where TKey : notnull - { - return source?.Select( + where TKey : notnull => source?.Select( condition => { bool Transformer(TSource item, TKey key) => condition(item); return (Func)Transformer; }); - } private static IObservable TrueFor(this IObservable> source, Func> observableSelector, Func>, bool> collectionMatcher) where TObject : notnull where TKey : notnull - where TValue : notnull - { - return new TrueFor(source, observableSelector, collectionMatcher).Run(); - } + where TValue : notnull => new TrueFor(source, observableSelector, collectionMatcher).Run(); } diff --git a/src/DynamicData/Cache/PageRequest.cs b/src/DynamicData/Cache/PageRequest.cs index 9b95a13f1..3f105410f 100644 --- a/src/DynamicData/Cache/PageRequest.cs +++ b/src/DynamicData/Cache/PageRequest.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; // ReSharper disable once CheckNamespace @@ -74,16 +72,10 @@ public PageRequest() public int Size { get; } = 25; /// - public bool Equals(IPageRequest? other) - { - return DefaultComparer.Equals(this, other); - } + public bool Equals(IPageRequest? other) => DefaultComparer.Equals(this, other); /// - public override bool Equals(object? obj) - { - return obj is IPageRequest value && Equals(value); - } + public override bool Equals(object? obj) => obj is IPageRequest value && Equals(value); /// public override int GetHashCode() diff --git a/src/DynamicData/Cache/PageResponse.cs b/src/DynamicData/Cache/PageResponse.cs index 3a6619b0f..e438f508f 100644 --- a/src/DynamicData/Cache/PageResponse.cs +++ b/src/DynamicData/Cache/PageResponse.cs @@ -2,33 +2,22 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - using DynamicData.Operators; // ReSharper disable once CheckNamespace namespace DynamicData; -internal sealed class PageResponse : IEquatable, IPageResponse +internal sealed class PageResponse(int pageSize, int totalSize, int page, int pages) : IEquatable, IPageResponse { - public PageResponse(int pageSize, int totalSize, int page, int pages) - { - PageSize = pageSize; - TotalSize = totalSize; - Page = page; - Pages = pages; - } - public static IEqualityComparer DefaultComparer { get; } = new PageResponseEqualityComparer(); - public int Page { get; } + public int Page { get; } = page; - public int Pages { get; } + public int Pages { get; } = pages; - public int PageSize { get; } + public int PageSize { get; } = pageSize; - public int TotalSize { get; } + public int TotalSize { get; } = totalSize; /// /// Indicates whether the current object is equal to another object of the same type. @@ -37,10 +26,7 @@ public PageResponse(int pageSize, int totalSize, int page, int pages) /// true if the current object is equal to the parameter; otherwise, false. /// /// An object to compare with this object. - public bool Equals(IPageResponse? other) - { - return DefaultComparer.Equals(this, other); - } + public bool Equals(IPageResponse? other) => DefaultComparer.Equals(this, other); /// /// Determines whether the specified is equal to the current . @@ -88,10 +74,7 @@ public override int GetHashCode() /// /// A that represents the current . /// - public override string ToString() - { - return $"Page: {Page}, PageSize: {PageSize}, Pages: {Pages}, TotalSize: {TotalSize}"; - } + public override string ToString() => $"Page: {Page}, PageSize: {PageSize}, Pages: {Pages}, TotalSize: {TotalSize}"; private sealed class PageResponseEqualityComparer : IEqualityComparer { diff --git a/src/DynamicData/Cache/PagedChangeSet.cs b/src/DynamicData/Cache/PagedChangeSet.cs index ca05f1f66..35ad97031 100644 --- a/src/DynamicData/Cache/PagedChangeSet.cs +++ b/src/DynamicData/Cache/PagedChangeSet.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; -using System.Linq; - using DynamicData.Cache.Internal; using DynamicData.Operators; @@ -39,20 +36,11 @@ private PagedChangeSet() /// /// The other. /// If the page change set equals the other. - public bool Equals(PagedChangeSet other) - { - return SortedItems.SequenceEqual(other.SortedItems); - } + public bool Equals(PagedChangeSet other) => SortedItems.SequenceEqual(other.SortedItems); - public override bool Equals(object? obj) - { - return obj is PagedChangeSet value && Equals(value); - } + public override bool Equals(object? obj) => obj is PagedChangeSet value && Equals(value); - public override int GetHashCode() - { - return SortedItems.GetHashCode(); - } + public override int GetHashCode() => SortedItems.GetHashCode(); /// /// Returns a that represents the SortedItems . @@ -60,8 +48,5 @@ public override int GetHashCode() /// /// A that represents the SortedItems . /// - public override string ToString() - { - return $"{base.ToString()}, Response: {Response}, SortedItems: {SortedItems}"; - } + public override string ToString() => $"{base.ToString()}, Response: {Response}, SortedItems: {SortedItems}"; } diff --git a/src/DynamicData/Cache/SortOptimisations.cs b/src/DynamicData/Cache/SortOptimisations.cs index 5dc286fa7..56b1a3284 100644 --- a/src/DynamicData/Cache/SortOptimisations.cs +++ b/src/DynamicData/Cache/SortOptimisations.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/Cache/SortedChangeSet.cs b/src/DynamicData/Cache/SortedChangeSet.cs index 2ddc1c243..ffe203975 100644 --- a/src/DynamicData/Cache/SortedChangeSet.cs +++ b/src/DynamicData/Cache/SortedChangeSet.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; -using System.Linq; - using DynamicData.Cache.Internal; // ReSharper disable once CheckNamespace @@ -29,23 +26,11 @@ private SortedChangeSet() public IKeyValueCollection SortedItems { get; } - public bool Equals(SortedChangeSet other) - { - return SortedItems.SequenceEqual(other.SortedItems); - } + public bool Equals(SortedChangeSet other) => SortedItems.SequenceEqual(other.SortedItems); - public override bool Equals(object? obj) - { - return obj is SortedChangeSet value && Equals(value); - } + public override bool Equals(object? obj) => obj is SortedChangeSet value && Equals(value); - public override int GetHashCode() - { - return SortedItems.GetHashCode(); - } + public override int GetHashCode() => SortedItems.GetHashCode(); - public override string ToString() - { - return $"SortedChangeSet. Count= {SortedItems.Count}. Updates = {Count}"; - } + public override string ToString() => $"SortedChangeSet. Count= {SortedItems.Count}. Updates = {Count}"; } diff --git a/src/DynamicData/Cache/SourceCache.cs b/src/DynamicData/Cache/SourceCache.cs index 606acfef3..52a7edd43 100644 --- a/src/DynamicData/Cache/SourceCache.cs +++ b/src/DynamicData/Cache/SourceCache.cs @@ -14,23 +14,17 @@ namespace DynamicData; /// /// The type of the object. /// The type of the key. +/// +/// Initializes a new instance of the class. +/// +/// The key selector. +/// keySelector. [DebuggerDisplay("SourceCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Items)")] -public sealed class SourceCache : ISourceCache +public sealed class SourceCache(Func keySelector) : ISourceCache where TObject : notnull where TKey : notnull { - private readonly ObservableCache _innerCache; - - /// - /// Initializes a new instance of the class. - /// - /// The key selector. - /// keySelector. - public SourceCache(Func keySelector) - { - KeySelector = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); - _innerCache = new ObservableCache(keySelector); - } + private readonly ObservableCache _innerCache = new(keySelector); /// public int Count => _innerCache.Count; @@ -45,7 +39,7 @@ public SourceCache(Func keySelector) public IEnumerable Keys => _innerCache.Keys; /// - public Func KeySelector { get; } + public Func KeySelector { get; } = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); /// public IEnumerable> KeyValues => _innerCache.KeyValues; diff --git a/src/DynamicData/Cache/SourceCacheEx.cs b/src/DynamicData/Cache/SourceCacheEx.cs index c70b54d83..e3a63c3e7 100644 --- a/src/DynamicData/Cache/SourceCacheEx.cs +++ b/src/DynamicData/Cache/SourceCacheEx.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/Cache/Tests/ChangeSetAggregator.cs b/src/DynamicData/Cache/Tests/ChangeSetAggregator.cs index 6e7fc5370..4ffb366d2 100644 --- a/src/DynamicData/Cache/Tests/ChangeSetAggregator.cs +++ b/src/DynamicData/Cache/Tests/ChangeSetAggregator.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Disposables; using System.Reactive.Linq; diff --git a/src/DynamicData/Cache/Tests/DistinctChangeSetAggregator.cs b/src/DynamicData/Cache/Tests/DistinctChangeSetAggregator.cs index 52caee813..e8a620077 100644 --- a/src/DynamicData/Cache/Tests/DistinctChangeSetAggregator.cs +++ b/src/DynamicData/Cache/Tests/DistinctChangeSetAggregator.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Disposables; using System.Reactive.Linq; diff --git a/src/DynamicData/Cache/Tests/PagedChangeSetAggregator.cs b/src/DynamicData/Cache/Tests/PagedChangeSetAggregator.cs index a03b5eef4..e30f44f67 100644 --- a/src/DynamicData/Cache/Tests/PagedChangeSetAggregator.cs +++ b/src/DynamicData/Cache/Tests/PagedChangeSetAggregator.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Disposables; using System.Reactive.Linq; diff --git a/src/DynamicData/Cache/Tests/SortedChangeSetAggregator.cs b/src/DynamicData/Cache/Tests/SortedChangeSetAggregator.cs index 5af493a60..4a6b8d326 100644 --- a/src/DynamicData/Cache/Tests/SortedChangeSetAggregator.cs +++ b/src/DynamicData/Cache/Tests/SortedChangeSetAggregator.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Disposables; using System.Reactive.Linq; diff --git a/src/DynamicData/Cache/Tests/TestEx.cs b/src/DynamicData/Cache/Tests/TestEx.cs index c797b9a05..351f8ae46 100644 --- a/src/DynamicData/Cache/Tests/TestEx.cs +++ b/src/DynamicData/Cache/Tests/TestEx.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - // ReSharper disable once CheckNamespace namespace DynamicData.Tests; @@ -21,10 +19,7 @@ public static class TestEx /// The change set aggregator. public static ChangeSetAggregator AsAggregator(this IObservable> source) where TObject : notnull - where TKey : notnull - { - return new(source); - } + where TKey : notnull => new(source); /// /// Aggregates all events and statistics for a distinct change set to help assertions when testing. diff --git a/src/DynamicData/Cache/Tests/VirtualChangeSetAggregator.cs b/src/DynamicData/Cache/Tests/VirtualChangeSetAggregator.cs index 7f966d9c9..8ee283a80 100644 --- a/src/DynamicData/Cache/Tests/VirtualChangeSetAggregator.cs +++ b/src/DynamicData/Cache/Tests/VirtualChangeSetAggregator.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Disposables; using System.Reactive.Linq; diff --git a/src/DynamicData/Cache/VirtualChangeSet.cs b/src/DynamicData/Cache/VirtualChangeSet.cs index cceed5d98..2a7ef3b1e 100644 --- a/src/DynamicData/Cache/VirtualChangeSet.cs +++ b/src/DynamicData/Cache/VirtualChangeSet.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - using DynamicData.Cache.Internal; // ReSharper disable once CheckNamespace @@ -58,10 +55,7 @@ public bool Equals(VirtualChangeSet? other) return Response.Equals(other.Response) && Equals(SortedItems, other.SortedItems); } - public override bool Equals(object? obj) - { - return obj is VirtualChangeSet item && Equals(item); - } + public override bool Equals(object? obj) => obj is VirtualChangeSet item && Equals(item); public override int GetHashCode() { diff --git a/src/DynamicData/Cache/VirtualRequest.cs b/src/DynamicData/Cache/VirtualRequest.cs index ae3325633..b4d7db9df 100644 --- a/src/DynamicData/Cache/VirtualRequest.cs +++ b/src/DynamicData/Cache/VirtualRequest.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; @@ -55,16 +52,10 @@ public VirtualRequest() public int StartIndex { get; } /// - public bool Equals(IVirtualRequest? other) - { - return StartIndexSizeComparer.Equals(this, other); - } + public bool Equals(IVirtualRequest? other) => StartIndexSizeComparer.Equals(this, other); /// - public override bool Equals(object? obj) - { - return obj is IVirtualRequest item && Equals(item); - } + public override bool Equals(object? obj) => obj is IVirtualRequest item && Equals(item); /// public override int GetHashCode() diff --git a/src/DynamicData/Cache/VirtualResponse.cs b/src/DynamicData/Cache/VirtualResponse.cs index 916f15779..0838b8b86 100644 --- a/src/DynamicData/Cache/VirtualResponse.cs +++ b/src/DynamicData/Cache/VirtualResponse.cs @@ -2,40 +2,30 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; /// /// Defines values used to virtualise the result set. /// -internal sealed class VirtualResponse : IEquatable, IVirtualResponse +internal sealed class VirtualResponse(int size, int startIndex, int totalSize) : IEquatable, IVirtualResponse { - public VirtualResponse(int size, int startIndex, int totalSize) - { - Size = size; - StartIndex = startIndex; - TotalSize = totalSize; - } - public static IEqualityComparer DefaultComparer { get; } = new TotalSizeStartIndexSizeEqualityComparer(); /// /// Gets the requested size of the virtualised data. /// - public int Size { get; } + public int Size { get; } = size; /// /// Gets the starting index. /// - public int StartIndex { get; } + public int StartIndex { get; } = startIndex; /// /// Gets the total size of the underlying cache. /// - public int TotalSize { get; } + public int TotalSize { get; } = totalSize; /// /// Indicates whether the current object is equal to another object of the same type. @@ -44,10 +34,7 @@ public VirtualResponse(int size, int startIndex, int totalSize) /// true if the current object is equal to the parameter; otherwise, false. /// /// An object to compare with this object. - public bool Equals(IVirtualResponse? other) - { - return DefaultComparer.Equals(this, other); - } + public bool Equals(IVirtualResponse? other) => DefaultComparer.Equals(this, other); /// /// Determines whether the specified is equal to the current . @@ -56,10 +43,7 @@ public bool Equals(IVirtualResponse? other) /// true if the specified object is equal to the current object; otherwise, false. /// /// The object to compare with the current object. - public override bool Equals(object? obj) - { - return obj is IVirtualResponse item && Equals(item); - } + public override bool Equals(object? obj) => obj is IVirtualResponse item && Equals(item); /// /// Serves as a hash function for a particular type. @@ -84,10 +68,7 @@ public override int GetHashCode() /// /// A that represents the current . /// - public override string ToString() - { - return $"Size: {Size}, StartIndex: {StartIndex}, TotalSize: {TotalSize}"; - } + public override string ToString() => $"Size: {Size}, StartIndex: {StartIndex}, TotalSize: {TotalSize}"; private sealed class TotalSizeStartIndexSizeEqualityComparer : IEqualityComparer { diff --git a/src/DynamicData/Diagnostics/ChangeStatistics.cs b/src/DynamicData/Diagnostics/ChangeStatistics.cs index 41575acfb..28fb68b0c 100644 --- a/src/DynamicData/Diagnostics/ChangeStatistics.cs +++ b/src/DynamicData/Diagnostics/ChangeStatistics.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - namespace DynamicData.Diagnostics; /// @@ -143,10 +141,7 @@ public bool Equals(ChangeStatistics? other) } /// - public override bool Equals(object? obj) - { - return obj is ChangeStatistics change && Equals(change); - } + public override bool Equals(object? obj) => obj is ChangeStatistics change && Equals(change); /// public override int GetHashCode() @@ -166,8 +161,5 @@ public override int GetHashCode() } /// - public override string ToString() - { - return $"CurrentIndex: {Index}, Adds: {Adds}, Updates: {Updates}, Removes: {Removes}, Refreshes: {Refreshes}, Count: {Count}, Timestamp: {LastUpdated}"; - } + public override string ToString() => $"CurrentIndex: {Index}, Adds: {Adds}, Updates: {Updates}, Removes: {Removes}, Refreshes: {Refreshes}, Count: {Count}, Timestamp: {LastUpdated}"; } diff --git a/src/DynamicData/Diagnostics/ChangeSummary.cs b/src/DynamicData/Diagnostics/ChangeSummary.cs index 537ed1a9d..18e14b7cc 100644 --- a/src/DynamicData/Diagnostics/ChangeSummary.cs +++ b/src/DynamicData/Diagnostics/ChangeSummary.cs @@ -86,8 +86,5 @@ public override int GetHashCode() /// public override string ToString() => $"CurrentIndex: {_index}, Latest Count: {Latest.Count}, Overall Count: {Overall.Count}"; - private bool Equals(ChangeSummary other) - { - return _index == other._index && Equals(Latest, other.Latest) && Equals(Overall, other.Overall); - } + private bool Equals(ChangeSummary other) => _index == other._index && Equals(Latest, other.Latest) && Equals(Overall, other.Overall); } diff --git a/src/DynamicData/Diagnostics/DiagnosticOperators.cs b/src/DynamicData/Diagnostics/DiagnosticOperators.cs index 7316b35e6..f7e9fec2e 100644 --- a/src/DynamicData/Diagnostics/DiagnosticOperators.cs +++ b/src/DynamicData/Diagnostics/DiagnosticOperators.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Linq; namespace DynamicData.Diagnostics; diff --git a/src/DynamicData/DynamicData.csproj b/src/DynamicData/DynamicData.csproj index aab9d623d..292325e23 100644 --- a/src/DynamicData/DynamicData.csproj +++ b/src/DynamicData/DynamicData.csproj @@ -1,10 +1,10 @@ - + - netstandard2.0;net462;net6.0;net7.0 + netstandard2.0;net462;net6.0;net7.0;net8.0 true true enable - latest + preview enable diff --git a/src/DynamicData/EnumerableEx.cs b/src/DynamicData/EnumerableEx.cs index 5f7cf6b96..c30953f43 100644 --- a/src/DynamicData/EnumerableEx.cs +++ b/src/DynamicData/EnumerableEx.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Disposables; using System.Reactive.Linq; diff --git a/src/DynamicData/Experimental/ExperimentalEx.cs b/src/DynamicData/Experimental/ExperimentalEx.cs index 5302d9e54..c39224cfe 100644 --- a/src/DynamicData/Experimental/ExperimentalEx.cs +++ b/src/DynamicData/Experimental/ExperimentalEx.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Concurrency; namespace DynamicData.Experimental; diff --git a/src/DynamicData/Experimental/IWatcher.cs b/src/DynamicData/Experimental/IWatcher.cs index 405741206..ae3a3426d 100644 --- a/src/DynamicData/Experimental/IWatcher.cs +++ b/src/DynamicData/Experimental/IWatcher.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - namespace DynamicData.Experimental; /// diff --git a/src/DynamicData/Experimental/SubjectWithRefCount.cs b/src/DynamicData/Experimental/SubjectWithRefCount.cs index 30cb8c05b..38903dc33 100644 --- a/src/DynamicData/Experimental/SubjectWithRefCount.cs +++ b/src/DynamicData/Experimental/SubjectWithRefCount.cs @@ -2,10 +2,8 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Subjects; -using System.Threading; namespace DynamicData.Experimental; @@ -13,21 +11,16 @@ namespace DynamicData.Experimental; /// A subject with a count of the number of subscribers. /// /// The type of the item. -internal class SubjectWithRefCount : ISubjectWithRefCount +/// +/// Initializes a new instance of the class. +/// +/// The subject to perform reference counting on. +internal class SubjectWithRefCount(ISubject? subject = null) : ISubjectWithRefCount { - private readonly ISubject _subject; + private readonly ISubject _subject = subject ?? new Subject(); private int _refCount; - /// - /// Initializes a new instance of the class. - /// - /// The subject to perform reference counting on. - public SubjectWithRefCount(ISubject? subject = null) - { - _subject = subject ?? new Subject(); - } - /// Gets number of subscribers. /// /// The ref count. @@ -37,28 +30,19 @@ public SubjectWithRefCount(ISubject? subject = null) /// /// Notifies the observer that the provider has finished sending push-based notifications. /// - public void OnCompleted() - { - _subject.OnCompleted(); - } + public void OnCompleted() => _subject.OnCompleted(); /// /// Notifies the observer that the provider has experienced an error condition. /// /// An object that provides additional information about the error. - public void OnError(Exception error) - { - _subject.OnError(error); - } + public void OnError(Exception error) => _subject.OnError(error); /// /// Provides the observer with new data. /// /// The current notification information. - public void OnNext(T value) - { - _subject.OnNext(value); - } + public void OnNext(T value) => _subject.OnNext(value); /// /// Notifies the provider that an observer is to receive notifications. diff --git a/src/DynamicData/Experimental/Watcher.cs b/src/DynamicData/Experimental/Watcher.cs index 89eb641ab..bfedbdb54 100644 --- a/src/DynamicData/Experimental/Watcher.cs +++ b/src/DynamicData/Experimental/Watcher.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Concurrency; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -54,14 +53,9 @@ public Watcher(IObservable> source, IScheduler schedul }); } - public void Dispose() - { - _disposer.Dispose(); - } + public void Dispose() => _disposer.Dispose(); - public IObservable> Watch(TKey key) - { - return Observable.Create>( + public IObservable> Watch(TKey key) => Observable.Create>( observer => { lock (_locker) @@ -106,5 +100,4 @@ public IObservable> Watch(TKey key) }); } }); - } } diff --git a/src/DynamicData/Kernel/EnumerableEx.cs b/src/DynamicData/Kernel/EnumerableEx.cs index 81cc46fb6..1ae70cf89 100644 --- a/src/DynamicData/Kernel/EnumerableEx.cs +++ b/src/DynamicData/Kernel/EnumerableEx.cs @@ -2,10 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; - namespace DynamicData.Kernel; /// @@ -77,10 +73,7 @@ public static IEnumerable Duplicates(this IEnumerable source, F /// /// A result as specified by the result selector. /// - public static IEnumerable> IndexOfMany(this IEnumerable source, IEnumerable itemsToFind) - { - return source.IndexOfMany(itemsToFind, (t, idx) => new ItemWithIndex(t, idx)); - } + public static IEnumerable> IndexOfMany(this IEnumerable source, IEnumerable itemsToFind) => source.IndexOfMany(itemsToFind, (t, idx) => new ItemWithIndex(t, idx)); /// /// Finds the index of many items as specified in the secondary enumerable. @@ -112,10 +105,7 @@ public static IEnumerable IndexOfMany(this IEnumerabl return itemsToFind.Join(indexed, left => left, right => right.Element, (_, right) => right).Select(x => resultSelector(x.Element, x.Index)); } - internal static IEnumerable EmptyIfNull(this IEnumerable? source) - { - return source ?? Enumerable.Empty(); - } + internal static IEnumerable EmptyIfNull(this IEnumerable? source) => source ?? Enumerable.Empty(); internal static IEnumerable EnumerateOne(this T source) { @@ -141,10 +131,7 @@ internal static void ForEach(this IEnumerable source, Action ToHashSet(this IEnumerable source) - { - return new(source); - } + internal static HashSet ToHashSet(this IEnumerable source) => new(source); #endif @@ -154,8 +141,5 @@ internal static HashSet ToHashSet(this IEnumerable source) /// The type of the item. /// The source. /// The enumerable of items with their indexes. - internal static IEnumerable> WithIndex(this IEnumerable source) - { - return source.Select((item, index) => new ItemWithIndex(item, index)); - } + internal static IEnumerable> WithIndex(this IEnumerable source) => source.Select((item, index) => new ItemWithIndex(item, index)); } diff --git a/src/DynamicData/Kernel/EnumerableIList.cs b/src/DynamicData/Kernel/EnumerableIList.cs index 83cb8dd8f..924644fa4 100644 --- a/src/DynamicData/Kernel/EnumerableIList.cs +++ b/src/DynamicData/Kernel/EnumerableIList.cs @@ -3,66 +3,58 @@ // See the LICENSE file in the project root for full license information. using System.Collections; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; // Lifted from here https://github.com/benaadams/Ben.Enumerable. Many thanks to the genius of the man. namespace DynamicData.Kernel; [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Same class name, different generics.")] -internal readonly struct EnumerableIList : IEnumerableIList, IList +internal readonly struct EnumerableIList(IList list) : IEnumerableIList, IList { - private readonly IList _list; - - public EnumerableIList(IList list) - { - _list = list; - } - public static EnumerableIList Empty { get; } /// - public int Count => _list.Count; + public int Count => list.Count; /// - public bool IsReadOnly => _list.IsReadOnly; + public bool IsReadOnly => list.IsReadOnly; /// public T this[int index] { - get => _list[index]; - set => _list[index] = value; + get => list[index]; + set => list[index] = value; } public static implicit operator EnumerableIList(List list) => new(list); public static implicit operator EnumerableIList(T[] array) => new(array); - public EnumeratorIList GetEnumerator() => new(_list); + public EnumeratorIList GetEnumerator() => new(list); /// - public void Add(T item) => _list.Add(item); + public void Add(T item) => list.Add(item); /// - public void Clear() => _list.Clear(); + public void Clear() => list.Clear(); /// - public bool Contains(T item) => _list.Contains(item); + public bool Contains(T item) => list.Contains(item); /// - public void CopyTo(T[] array, int arrayIndex) => _list.CopyTo(array, arrayIndex); + public void CopyTo(T[] array, int arrayIndex) => list.CopyTo(array, arrayIndex); /// - public int IndexOf(T item) => _list.IndexOf(item); + public int IndexOf(T item) => list.IndexOf(item); /// - public void Insert(int index, T item) => _list.Insert(index, item); + public void Insert(int index, T item) => list.Insert(index, item); /// - public bool Remove(T item) => _list.Remove(item); + public bool Remove(T item) => list.Remove(item); /// - public void RemoveAt(int index) => _list.RemoveAt(index); + public void RemoveAt(int index) => list.RemoveAt(index); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); diff --git a/src/DynamicData/Kernel/EnumeratorIList.cs b/src/DynamicData/Kernel/EnumeratorIList.cs index e02d1c773..c38104bdf 100644 --- a/src/DynamicData/Kernel/EnumeratorIList.cs +++ b/src/DynamicData/Kernel/EnumeratorIList.cs @@ -3,26 +3,17 @@ // See the LICENSE file in the project root for full license information. using System.Collections; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; // Lifted from here https://github.com/benaadams/Ben.Enumerable. Many thanks to the genius of the man. namespace DynamicData.Kernel; [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Same class name, different generics.")] -internal struct EnumeratorIList : IEnumerator +internal struct EnumeratorIList(IList list) : IEnumerator { - private readonly IList _list; + private int _index = -1; - private int _index; - - public EnumeratorIList(IList list) - { - _index = -1; - _list = list; - } - - public T Current => _list[_index]; + public T Current => list[_index]; object? IEnumerator.Current => Current; @@ -30,7 +21,7 @@ public bool MoveNext() { _index++; - return _index < _list.Count; + return _index < list.Count; } public void Dispose() diff --git a/src/DynamicData/Kernel/Error.cs b/src/DynamicData/Kernel/Error.cs index d8a7e285c..4a0e515b4 100644 --- a/src/DynamicData/Kernel/Error.cs +++ b/src/DynamicData/Kernel/Error.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - #pragma warning disable 1591 namespace DynamicData.Kernel; @@ -14,36 +11,29 @@ namespace DynamicData.Kernel; /// /// The type of the object. /// The type of the key. -public sealed class Error : IKeyValue, IEquatable> +/// +/// Initializes a new instance of the class. +/// +/// The exception that caused the error. +/// The value for the error. +/// The key for the error. +public sealed class Error(Exception? exception, TObject value, TKey key) : IKeyValue, IEquatable> where TKey : notnull { - /// - /// Initializes a new instance of the class. - /// - /// The exception that caused the error. - /// The value for the error. - /// The key for the error. - public Error(Exception? exception, TObject value, TKey key) - { - Exception = exception; - Value = value; - Key = key; - } - /// /// Gets the exception. /// - public Exception? Exception { get; } + public Exception? Exception { get; } = exception; /// /// Gets the key. /// - public TKey Key { get; } + public TKey Key { get; } = key; /// /// Gets the object. /// - public TObject Value { get; } + public TObject Value { get; } = value; public static bool operator ==(Error left, Error right) { @@ -100,8 +90,5 @@ public override int GetHashCode() } /// - public override string ToString() - { - return $"Key: {Key}, Value: {Value}, Exception: {Exception}"; - } + public override string ToString() => $"Key: {Key}, Value: {Value}, Exception: {Exception}"; } diff --git a/src/DynamicData/Kernel/IEnumerableIList.cs b/src/DynamicData/Kernel/IEnumerableIList.cs index 7191ddf32..fc0c29dfe 100644 --- a/src/DynamicData/Kernel/IEnumerableIList.cs +++ b/src/DynamicData/Kernel/IEnumerableIList.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - // Lifted from here https://github.com/benaadams/Ben.Enumerable. Many thanks to the genius of the man. namespace DynamicData.Kernel; diff --git a/src/DynamicData/Kernel/InternalEx.cs b/src/DynamicData/Kernel/InternalEx.cs index 0b5f5182e..ce5a8d9a5 100644 --- a/src/DynamicData/Kernel/InternalEx.cs +++ b/src/DynamicData/Kernel/InternalEx.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive; using System.Reactive.Concurrency; using System.Reactive.Linq; @@ -57,16 +56,13 @@ IObservable Retry(int failureCount) => /// The interval. /// The action. /// A disposable that will stop the schedule. - public static IDisposable ScheduleRecurringAction(this IScheduler scheduler, TimeSpan interval, Action action) - { - return scheduler.Schedule( + public static IDisposable ScheduleRecurringAction(this IScheduler scheduler, TimeSpan interval, Action action) => scheduler.Schedule( interval, scheduleNext => { action(); scheduleNext(interval); }); - } /// /// Schedules a recurring action. @@ -99,10 +95,7 @@ public static IDisposable ScheduleRecurringAction(this IScheduler scheduler, Fun }); } - internal static void OnNext(this ISubject source) - { - source.OnNext(Unit.Default); - } + internal static void OnNext(this ISubject source) => source.OnNext(Unit.Default); internal static void Swap(ref TSwap t1, ref TSwap t2) { @@ -111,10 +104,7 @@ internal static void Swap(ref TSwap t1, ref TSwap t2) t2 = temp; } - internal static IObservable ToUnit(this IObservable source) - { - return source.Select(_ => Unit.Default); - } + internal static IObservable ToUnit(this IObservable source) => source.Select(_ => Unit.Default); /// /// Observable.Return without the memory leak. diff --git a/src/DynamicData/Kernel/ItemWithIndex.cs b/src/DynamicData/Kernel/ItemWithIndex.cs index 14d1f87af..3eabdd92a 100644 --- a/src/DynamicData/Kernel/ItemWithIndex.cs +++ b/src/DynamicData/Kernel/ItemWithIndex.cs @@ -2,38 +2,29 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - namespace DynamicData.Kernel; /// /// Container for an item and it's index from a list. /// /// The type of the item. -public readonly struct ItemWithIndex : IEquatable> +/// +/// Initializes a new instance of the struct. +/// Initializes a new instance of the class. +/// +/// The item. +/// The index. +public readonly struct ItemWithIndex(T item, int index) : IEquatable> { - /// - /// Initializes a new instance of the struct. - /// Initializes a new instance of the class. - /// - /// The item. - /// The index. - public ItemWithIndex(T item, int index) - { - Item = item; - Index = index; - } - /// /// Gets the item. /// - public T Item { get; } + public T Item { get; } = item; /// /// Gets the index. /// - public int Index { get; } + public int Index { get; } = index; /// Returns a value that indicates whether the values of two objects are equal. /// The first value to compare. @@ -54,10 +45,7 @@ public ItemWithIndex(T item, int index) } /// - public bool Equals(ItemWithIndex other) - { - return EqualityComparer.Default.Equals(Item, other.Item); - } + public bool Equals(ItemWithIndex other) => EqualityComparer.Default.Equals(Item, other.Item); /// public override bool Equals(object? obj) @@ -72,14 +60,8 @@ public override bool Equals(object? obj) /// Returns the hash code for this instance. /// A 32-bit signed integer that is the hash code for this instance. - public override int GetHashCode() - { - return Item is null ? 0 : EqualityComparer.Default.GetHashCode(Item); - } + public override int GetHashCode() => Item is null ? 0 : EqualityComparer.Default.GetHashCode(Item); /// - public override string ToString() - { - return $"{Item} ({Index})"; - } + public override string ToString() => $"{Item} ({Index})"; } diff --git a/src/DynamicData/Kernel/ItemWithValue.cs b/src/DynamicData/Kernel/ItemWithValue.cs index 3fdc25565..aeb050503 100644 --- a/src/DynamicData/Kernel/ItemWithValue.cs +++ b/src/DynamicData/Kernel/ItemWithValue.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - namespace DynamicData.Kernel; /// @@ -12,29 +9,23 @@ namespace DynamicData.Kernel; /// /// The type of the object. /// The type of the value. -public readonly struct ItemWithValue : IEquatable> +/// +/// Initializes a new instance of the struct. +/// Initializes a new instance of the class. +/// +/// The item. +/// The Value. +public readonly struct ItemWithValue(TObject item, TValue value) : IEquatable> { - /// - /// Initializes a new instance of the struct. - /// Initializes a new instance of the class. - /// - /// The item. - /// The Value. - public ItemWithValue(TObject item, TValue value) - { - Item = item; - Value = value; - } - /// /// Gets the item. /// - public TObject Item { get; } + public TObject Item { get; } = item; /// /// Gets the Value. /// - public TValue Value { get; } + public TValue Value { get; } = value; /// /// Implements the operator ==. @@ -63,10 +54,7 @@ public ItemWithValue(TObject item, TValue value) } /// - public bool Equals(ItemWithValue other) - { - return EqualityComparer.Default.Equals(Item, other.Item) && EqualityComparer.Default.Equals(Value, other.Value); - } + public bool Equals(ItemWithValue other) => EqualityComparer.Default.Equals(Item, other.Item) && EqualityComparer.Default.Equals(Value, other.Value); /// public override bool Equals(object? obj) diff --git a/src/DynamicData/Kernel/OptionElse.cs b/src/DynamicData/Kernel/OptionElse.cs index e0847191e..9811fb8b7 100644 --- a/src/DynamicData/Kernel/OptionElse.cs +++ b/src/DynamicData/Kernel/OptionElse.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - namespace DynamicData.Kernel; /// diff --git a/src/DynamicData/Kernel/OptionExtensions.cs b/src/DynamicData/Kernel/OptionExtensions.cs index a75274444..5ef18d9f2 100644 --- a/src/DynamicData/Kernel/OptionExtensions.cs +++ b/src/DynamicData/Kernel/OptionExtensions.cs @@ -2,10 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; - namespace DynamicData.Kernel; /// @@ -237,10 +233,7 @@ public static bool RemoveIfContained(this IDictionaryThe source. /// An enumerable of the selected items. public static IEnumerable SelectValues(this IEnumerable> source) - where T : notnull - { - return source.Where(t => t.HasValue && t.Value is not null).Select(t => t.Value!); - } + where T : notnull => source.Where(t => t.HasValue && t.Value is not null).Select(t => t.Value!); /// /// Returns the value if the nullable has a value, otherwise returns the result of the value selector. @@ -250,10 +243,7 @@ public static IEnumerable SelectValues(this IEnumerable> sourc /// The default value. /// The value or the default value. public static T ValueOr(this T? source, T defaultValue) - where T : struct - { - return source ?? defaultValue; - } + where T : struct => source ?? defaultValue; /// /// Returns the value if the optional has a value, otherwise returns the result of the value selector. diff --git a/src/DynamicData/Kernel/OptionObservableExtensions.cs b/src/DynamicData/Kernel/OptionObservableExtensions.cs index c57ba7383..ddec33a53 100644 --- a/src/DynamicData/Kernel/OptionObservableExtensions.cs +++ b/src/DynamicData/Kernel/OptionObservableExtensions.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Linq; namespace DynamicData.Kernel; @@ -195,10 +192,7 @@ public static IObservable> OnHasNoValue(this IObservableAn Observable with the Values. /// Observable version of . public static IObservable SelectValues(this IObservable> source) - where T : notnull - { - return source.Where(t => t.HasValue && t.Value is not null).Select(t => t.Value!); - } + where T : notnull => source.Where(t => t.HasValue && t.Value is not null).Select(t => t.Value!); /// /// Converts an Observable of into an IObservable of by extracting the diff --git a/src/DynamicData/Kernel/Optional.cs b/src/DynamicData/Kernel/Optional.cs index 622d8263c..388d4f0f0 100644 --- a/src/DynamicData/Kernel/Optional.cs +++ b/src/DynamicData/Kernel/Optional.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; #pragma warning disable 1591 diff --git a/src/DynamicData/Kernel/ParallelEx.cs b/src/DynamicData/Kernel/ParallelEx.cs index 2995a7d87..1a07fb6a3 100644 --- a/src/DynamicData/Kernel/ParallelEx.cs +++ b/src/DynamicData/Kernel/ParallelEx.cs @@ -2,11 +2,7 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Threading; -using System.Threading.Tasks; namespace DynamicData.Kernel; diff --git a/src/DynamicData/Kernel/ReadOnlyCollectionLight.cs b/src/DynamicData/Kernel/ReadOnlyCollectionLight.cs index afd5061a2..a7b9681b6 100644 --- a/src/DynamicData/Kernel/ReadOnlyCollectionLight.cs +++ b/src/DynamicData/Kernel/ReadOnlyCollectionLight.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for full license information. using System.Collections; -using System.Collections.Generic; -using System.Linq; namespace DynamicData.Kernel; @@ -27,13 +25,7 @@ private ReadOnlyCollectionLight() public int Count { get; } - public IEnumerator GetEnumerator() - { - return _items.GetEnumerator(); - } + public IEnumerator GetEnumerator() => _items.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/src/DynamicData/Kernel/ReferenceEqualityComparer.cs b/src/DynamicData/Kernel/ReferenceEqualityComparer.cs index 32156a42f..2af0b2e6c 100644 --- a/src/DynamicData/Kernel/ReferenceEqualityComparer.cs +++ b/src/DynamicData/Kernel/ReferenceEqualityComparer.cs @@ -2,21 +2,13 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - namespace DynamicData.Kernel; internal class ReferenceEqualityComparer : IEqualityComparer { public static readonly IEqualityComparer Instance = new ReferenceEqualityComparer(); - public bool Equals(T? x, T? y) - { - return ReferenceEquals(x, y); - } + public bool Equals(T? x, T? y) => ReferenceEquals(x, y); - public int GetHashCode(T? obj) - { - return obj is null ? 0 : obj.GetHashCode(); - } + public int GetHashCode(T? obj) => obj is null ? 0 : obj.GetHashCode(); } diff --git a/src/DynamicData/List/ChangeAwareList.cs b/src/DynamicData/List/ChangeAwareList.cs index a37fc0770..a01d7a1e4 100644 --- a/src/DynamicData/List/ChangeAwareList.cs +++ b/src/DynamicData/List/ChangeAwareList.cs @@ -2,10 +2,7 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Collections; -using System.Collections.Generic; -using System.Linq; using DynamicData.Kernel; @@ -116,10 +113,7 @@ public T this[int index] /// Adds the item to the end of the collection. /// /// The item to add. - public void Add(T item) - { - InsertItem(_innerList.Count, item); - } + public void Add(T item) => InsertItem(_innerList.Count, item); /// /// Adds the elements of the specified collection to the end of the collection. @@ -401,10 +395,7 @@ public void RemoveRange(int index, int count) } /// - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); /// /// Clears the changes (for testing). diff --git a/src/DynamicData/List/ChangeAwareListWithRefCounts.cs b/src/DynamicData/List/ChangeAwareListWithRefCounts.cs index 2b8db67d4..eaf237894 100644 --- a/src/DynamicData/List/ChangeAwareListWithRefCounts.cs +++ b/src/DynamicData/List/ChangeAwareListWithRefCounts.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - using DynamicData.Kernel; using DynamicData.List.Internal; @@ -21,10 +19,7 @@ public override void Clear() base.Clear(); } - public override bool Contains(T item) - { - return _tracker.Contains(item); - } + public override bool Contains(T item) => _tracker.Contains(item); protected override void InsertItem(int index, T item) { @@ -32,15 +27,9 @@ protected override void InsertItem(int index, T item) base.InsertItem(index, item); } - protected override void OnInsertItems(int startIndex, IEnumerable items) - { - items.ForEach(t => _tracker.Add(t)); - } + protected override void OnInsertItems(int startIndex, IEnumerable items) => items.ForEach(t => _tracker.Add(t)); - protected override void OnRemoveItems(int startIndex, IEnumerable items) - { - items.ForEach(t => _tracker.Remove(t)); - } + protected override void OnRemoveItems(int startIndex, IEnumerable items) => items.ForEach(t => _tracker.Remove(t)); protected override void OnSetItem(int index, T newItem, T oldItem) { diff --git a/src/DynamicData/List/ChangeSet.cs b/src/DynamicData/List/ChangeSet.cs index 4fb567cdd..4a5eb184f 100644 --- a/src/DynamicData/List/ChangeSet.cs +++ b/src/DynamicData/List/ChangeSet.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; -using System.Linq; - // ReSharper disable once CheckNamespace namespace DynamicData; @@ -116,8 +113,5 @@ public int Removes /// /// A that represents this instance. /// - public override string ToString() - { - return $"ChangeSet<{typeof(T).Name}>. Count={Count}"; - } + public override string ToString() => $"ChangeSet<{typeof(T).Name}>. Count={Count}"; } diff --git a/src/DynamicData/List/ChangeSetEx.cs b/src/DynamicData/List/ChangeSetEx.cs index 2003bfe44..6224a2cd8 100644 --- a/src/DynamicData/List/ChangeSetEx.cs +++ b/src/DynamicData/List/ChangeSetEx.cs @@ -106,10 +106,7 @@ public static IChangeSet Transform(this ICh /// The source. /// An enumerable of changes. public static IEnumerable> YieldWithoutIndex(this IEnumerable> source) - where T : notnull - { - return new WithoutIndexEnumerator(source); - } + where T : notnull => new WithoutIndexEnumerator(source); /// /// Returns a flattened source. diff --git a/src/DynamicData/List/IChangeSet.cs b/src/DynamicData/List/IChangeSet.cs index 3e48c2b58..71ef708ef 100644 --- a/src/DynamicData/List/IChangeSet.cs +++ b/src/DynamicData/List/IChangeSet.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/List/IExtendedList.cs b/src/DynamicData/List/IExtendedList.cs index 3cf3028bf..4e1b1456e 100644 --- a/src/DynamicData/List/IExtendedList.cs +++ b/src/DynamicData/List/IExtendedList.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/List/IGrouping.cs b/src/DynamicData/List/IGrouping.cs index f829db436..d6bc8e085 100644 --- a/src/DynamicData/List/IGrouping.cs +++ b/src/DynamicData/List/IGrouping.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; - namespace DynamicData.List; /// diff --git a/src/DynamicData/List/IObservableList.cs b/src/DynamicData/List/IObservableList.cs index 28c1148bd..e8d04584b 100644 --- a/src/DynamicData/List/IObservableList.cs +++ b/src/DynamicData/List/IObservableList.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/List/ISourceList.cs b/src/DynamicData/List/ISourceList.cs index 50ec722a9..d943cccd1 100644 --- a/src/DynamicData/List/ISourceList.cs +++ b/src/DynamicData/List/ISourceList.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/List/Internal/AutoRefresh.cs b/src/DynamicData/List/Internal/AutoRefresh.cs index 38b81a28c..bf71e1b8a 100644 --- a/src/DynamicData/List/Internal/AutoRefresh.cs +++ b/src/DynamicData/List/Internal/AutoRefresh.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Concurrency; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -12,28 +10,13 @@ namespace DynamicData.List.Internal; -internal class AutoRefresh +internal class AutoRefresh(IObservable> source, Func> reEvaluator, TimeSpan? buffer = null, IScheduler? scheduler = null) where TObject : notnull { - private readonly TimeSpan? _buffer; + private readonly Func> _reEvaluator = reEvaluator ?? throw new ArgumentNullException(nameof(reEvaluator)); + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly Func> _reEvaluator; - - private readonly IScheduler? _scheduler; - - private readonly IObservable> _source; - - public AutoRefresh(IObservable> source, Func> reEvaluator, TimeSpan? buffer = null, IScheduler? scheduler = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _reEvaluator = reEvaluator ?? throw new ArgumentNullException(nameof(reEvaluator)); - _buffer = buffer; - _scheduler = scheduler; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -47,9 +30,9 @@ public IObservable> Run() var itemHasChanged = shared.MergeMany((t) => _reEvaluator(t).Select(_ => t)); // create a change set, either buffered or one item at the time - IObservable> itemsChanged = _buffer is null ? + IObservable> itemsChanged = buffer is null ? itemHasChanged.Select(t => new[] { t }) : - itemHasChanged.Buffer(_buffer.Value, _scheduler ?? Scheduler.Default).Where(list => list.Count > 0); + itemHasChanged.Buffer(buffer.Value, scheduler ?? Scheduler.Default).Where(list => list.Count > 0); IObservable> requiresRefresh = itemsChanged.Synchronize(locker).Select( items => @@ -63,5 +46,4 @@ public IObservable> Run() return new CompositeDisposable(publisher, shared.Connect()); }); - } } diff --git a/src/DynamicData/List/Internal/BufferIf.cs b/src/DynamicData/List/Internal/BufferIf.cs index 86cd71edf..cf0167336 100644 --- a/src/DynamicData/List/Internal/BufferIf.cs +++ b/src/DynamicData/List/Internal/BufferIf.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Concurrency; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -10,40 +9,27 @@ namespace DynamicData.List.Internal; -internal sealed class BufferIf +internal sealed class BufferIf(IObservable> source, IObservable pauseIfTrueSelector, bool initialPauseState = false, TimeSpan? timeOut = null, IScheduler? scheduler = null) where T : notnull { - private readonly bool _initialPauseState; + private readonly IObservable _pauseIfTrueSelector = pauseIfTrueSelector ?? throw new ArgumentNullException(nameof(pauseIfTrueSelector)); - private readonly IObservable _pauseIfTrueSelector; + private readonly IScheduler _scheduler = scheduler ?? Scheduler.Default; - private readonly IScheduler _scheduler; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly IObservable> _source; + private readonly TimeSpan _timeOut = timeOut ?? TimeSpan.Zero; - private readonly TimeSpan _timeOut; - - public BufferIf(IObservable> source, IObservable pauseIfTrueSelector, bool initialPauseState = false, TimeSpan? timeOut = null, IScheduler? scheduler = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _pauseIfTrueSelector = pauseIfTrueSelector ?? throw new ArgumentNullException(nameof(pauseIfTrueSelector)); - _initialPauseState = initialPauseState; - _timeOut = timeOut ?? TimeSpan.Zero; - _scheduler = scheduler ?? Scheduler.Default; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); - var paused = _initialPauseState; + var paused = initialPauseState; var buffer = new ChangeSet(); var timeoutSubscriber = new SerialDisposable(); var timeoutSubject = new Subject(); - var bufferSelector = Observable.Return(_initialPauseState).Concat(_pauseIfTrueSelector.Merge(timeoutSubject)).ObserveOn(_scheduler).Synchronize(locker).Publish(); + var bufferSelector = Observable.Return(initialPauseState).Concat(_pauseIfTrueSelector.Merge(timeoutSubject)).ObserveOn(_scheduler).Synchronize(locker).Publish(); var pause = bufferSelector.Where(state => state).Subscribe( _ => @@ -101,5 +87,4 @@ public IObservable> Run() timeoutSubscriber.Dispose(); }); }); - } } diff --git a/src/DynamicData/List/Internal/Combiner.cs b/src/DynamicData/List/Internal/Combiner.cs index 4e96a305a..800dc2035 100644 --- a/src/DynamicData/List/Internal/Combiner.cs +++ b/src/DynamicData/List/Internal/Combiner.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -12,24 +9,14 @@ namespace DynamicData.List.Internal; -internal sealed class Combiner +internal sealed class Combiner(ICollection>> source, CombineOperator type) where T : notnull { private readonly object _locker = new(); - private readonly ICollection>> _source; + private readonly ICollection>> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly CombineOperator _type; - - public Combiner(ICollection>> source, CombineOperator type) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _type = type; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var disposable = new CompositeDisposable(); @@ -59,7 +46,6 @@ public IObservable> Run() return disposable; }); - } private static void CloneSourceList(ReferenceCountTracker tracker, IChangeSet changes) { @@ -102,7 +88,7 @@ private static void CloneSourceList(ReferenceCountTracker tracker, IChangeSet private bool MatchesConstraint(List> sourceLists, T item) { - switch (_type) + switch (type) { case CombineOperator.And: { diff --git a/src/DynamicData/List/Internal/DeferUntilLoaded.cs b/src/DynamicData/List/Internal/DeferUntilLoaded.cs index 7878cf3b9..ae70ffae8 100644 --- a/src/DynamicData/List/Internal/DeferUntilLoaded.cs +++ b/src/DynamicData/List/Internal/DeferUntilLoaded.cs @@ -2,25 +2,16 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Linq; using DynamicData.Kernel; namespace DynamicData.List.Internal; -internal class DeferUntilLoaded +internal class DeferUntilLoaded(IObservable> source) where T : notnull { - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public DeferUntilLoaded(IObservable> source) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - } - - public IObservable> Run() - { - return _source.MonitorStatus().Where(status => status == ConnectionStatus.Loaded).Take(1).Select(_ => new ChangeSet()).Concat(_source).NotEmpty(); - } + public IObservable> Run() => _source.MonitorStatus().Where(status => status == ConnectionStatus.Loaded).Take(1).Select(_ => new ChangeSet()).Concat(_source).NotEmpty(); } diff --git a/src/DynamicData/List/Internal/Distinct.cs b/src/DynamicData/List/Internal/Distinct.cs index 4b034934b..08ba912d3 100644 --- a/src/DynamicData/List/Internal/Distinct.cs +++ b/src/DynamicData/List/Internal/Distinct.cs @@ -2,32 +2,21 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Linq; using DynamicData.Kernel; namespace DynamicData.List.Internal; -internal sealed class Distinct +internal sealed class Distinct(IObservable> source, Func valueSelector) where T : notnull where TValue : notnull { - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly Func _valueSelector; + private readonly Func _valueSelector = valueSelector ?? throw new ArgumentNullException(nameof(valueSelector)); - public Distinct(IObservable> source, Func valueSelector) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _valueSelector = valueSelector ?? throw new ArgumentNullException(nameof(valueSelector)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var valueCounters = new Dictionary(); @@ -42,7 +31,6 @@ public IObservable> Run() }, true).Select(changes => Process(valueCounters, result, changes)).NotEmpty().SubscribeSafe(observer); }); - } private static IChangeSet Process(Dictionary values, ChangeAwareList result, IChangeSet changes) { @@ -149,20 +137,13 @@ void RemoveAction(TValue value) return result.CaptureChanges(); } - private sealed class ItemWithMatch : IEquatable + private sealed class ItemWithMatch(T item, TValue value, TValue? previousValue) : IEquatable { - public ItemWithMatch(T item, TValue value, TValue? previousValue) - { - Item = item; - Value = value; - Previous = previousValue; - } - - public T Item { get; } + public T Item { get; } = item; - public TValue? Previous { get; } + public TValue? Previous { get; } = previousValue; - public TValue Value { get; } + public TValue Value { get; } = value; /// Returns a value that indicates whether the values of two objects are equal. /// The first value to compare. @@ -217,14 +198,8 @@ public override bool Equals(object? obj) return Equals((ItemWithMatch)obj); } - public override int GetHashCode() - { - return Item is null ? 0 : EqualityComparer.Default.GetHashCode(Item); - } + public override int GetHashCode() => Item is null ? 0 : EqualityComparer.Default.GetHashCode(Item); - public override string ToString() - { - return $"{nameof(Item)}: {Item}, {nameof(Value)}: {Value}, {nameof(Previous)}: {Previous}"; - } + public override string ToString() => $"{nameof(Item)}: {Item}, {nameof(Value)}: {Value}, {nameof(Previous)}: {Previous}"; } } diff --git a/src/DynamicData/List/Internal/DynamicCombiner.cs b/src/DynamicData/List/Internal/DynamicCombiner.cs index ec41bf243..258f9ad74 100644 --- a/src/DynamicData/List/Internal/DynamicCombiner.cs +++ b/src/DynamicData/List/Internal/DynamicCombiner.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -13,24 +10,14 @@ namespace DynamicData.List.Internal; -internal sealed class DynamicCombiner +internal sealed class DynamicCombiner(IObservableList>> source, CombineOperator type) where T : notnull { private readonly object _locker = new(); - private readonly IObservableList>> _source; + private readonly IObservableList>> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly CombineOperator _type; - - public DynamicCombiner(IObservableList>> source, CombineOperator type) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _type = type; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { // this is the resulting list which produces all notifications @@ -64,7 +51,7 @@ public IObservable> Run() } // On some operators, items not in the removed list can also be affected. - if (_type == CombineOperator.And || _type == CombineOperator.Except) + if (type == CombineOperator.And || type == CombineOperator.Except) { var itemsToCheck = sourceLists.Items.SelectMany(mc2 => mc2.Tracker.Items).ToArray(); var notification2 = UpdateItemSetMemberships(sourceLists.Items.AsArray(), resultList, itemsToCheck); @@ -86,7 +73,7 @@ public IObservable> Run() } // On some operators, items not in the new list can also be affected. - if (_type == CombineOperator.And || _type == CombineOperator.Except) + if (type == CombineOperator.And || type == CombineOperator.Except) { var notification2 = UpdateItemSetMemberships(sourceLists.Items.AsArray(), resultList, resultList.ToArray()); if (notification2.Count != 0) @@ -98,7 +85,6 @@ public IObservable> Run() return new CompositeDisposable(sourceLists, allChanges, removedItem, sourceChanged); }); - } private bool MatchesConstraint(MergeContainer[] sourceLists, T item) { @@ -107,7 +93,7 @@ private bool MatchesConstraint(MergeContainer[] sourceLists, T item) return false; } - switch (_type) + switch (type) { case CombineOperator.And: { @@ -132,7 +118,7 @@ private bool MatchesConstraint(MergeContainer[] sourceLists, T item) } default: - throw new IndexOutOfRangeException("Unknown CombineOperator " + _type); + throw new IndexOutOfRangeException("Unknown CombineOperator " + type); } } diff --git a/src/DynamicData/List/Internal/EditDiff.cs b/src/DynamicData/List/Internal/EditDiff.cs index 80b6589e7..d5c645fb2 100644 --- a/src/DynamicData/List/Internal/EditDiff.cs +++ b/src/DynamicData/List/Internal/EditDiff.cs @@ -2,30 +2,18 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; - using DynamicData.Kernel; namespace DynamicData.List.Internal; -internal class EditDiff +internal class EditDiff(ISourceList source, IEqualityComparer? equalityComparer) where T : notnull { - private readonly IEqualityComparer _equalityComparer; - - private readonly ISourceList _source; + private readonly IEqualityComparer _equalityComparer = equalityComparer ?? EqualityComparer.Default; - public EditDiff(ISourceList source, IEqualityComparer? equalityComparer) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _equalityComparer = equalityComparer ?? EqualityComparer.Default; - } + private readonly ISourceList _source = source ?? throw new ArgumentNullException(nameof(source)); - public void Edit(IEnumerable items) - { - _source.Edit( + public void Edit(IEnumerable items) => _source.Edit( innerList => { var originalItems = innerList.AsArray(); @@ -37,5 +25,4 @@ public void Edit(IEnumerable items) innerList.Remove(removes); innerList.AddRange(adds); }); - } } diff --git a/src/DynamicData/List/Internal/ExpirableItem.cs b/src/DynamicData/List/Internal/ExpirableItem.cs index bb83b6d9f..2fdda391c 100644 --- a/src/DynamicData/List/Internal/ExpirableItem.cs +++ b/src/DynamicData/List/Internal/ExpirableItem.cs @@ -2,25 +2,15 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - namespace DynamicData.List.Internal; -internal sealed class ExpirableItem : IEquatable> +internal sealed class ExpirableItem(TObject value, DateTime dateTime, long index) : IEquatable> { - public ExpirableItem(TObject value, DateTime dateTime, long index) - { - Item = value; - ExpireAt = dateTime; - Index = index; - } + public DateTime ExpireAt { get; } = dateTime; - public DateTime ExpireAt { get; } + public long Index { get; } = index; - public long Index { get; } - - public TObject Item { get; } + public TObject Item { get; } = value; public static bool operator ==(ExpirableItem left, ExpirableItem right) { @@ -73,8 +63,5 @@ public override int GetHashCode() } } - public override string ToString() - { - return $"{Item} @ {ExpireAt}"; - } + public override string ToString() => $"{Item} @ {ExpireAt}"; } diff --git a/src/DynamicData/List/Internal/ExpireAfter.cs b/src/DynamicData/List/Internal/ExpireAfter.cs index 3d1656e34..e000bb2a8 100644 --- a/src/DynamicData/List/Internal/ExpireAfter.cs +++ b/src/DynamicData/List/Internal/ExpireAfter.cs @@ -2,49 +2,29 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Concurrency; using System.Reactive.Disposables; using System.Reactive.Linq; -using System.Threading; using DynamicData.Kernel; namespace DynamicData.List.Internal; -internal sealed class ExpireAfter +internal sealed class ExpireAfter(ISourceList sourceList, Func expireAfter, TimeSpan? pollingInterval, IScheduler scheduler, object locker) where T : notnull { - private readonly Func _expireAfter; + private readonly Func _expireAfter = expireAfter ?? throw new ArgumentNullException(nameof(expireAfter)); + private readonly IScheduler _scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler)); - private readonly object _locker; + private readonly ISourceList _sourceList = sourceList ?? throw new ArgumentNullException(nameof(sourceList)); - private readonly TimeSpan? _pollingInterval; - - private readonly IScheduler _scheduler; - - private readonly ISourceList _sourceList; - - public ExpireAfter(ISourceList sourceList, Func expireAfter, TimeSpan? pollingInterval, IScheduler scheduler, object locker) - { - _sourceList = sourceList ?? throw new ArgumentNullException(nameof(sourceList)); - _expireAfter = expireAfter ?? throw new ArgumentNullException(nameof(expireAfter)); - _pollingInterval = pollingInterval; - _scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler)); - _locker = locker; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var dateTime = _scheduler.Now.UtcDateTime; long orderItemWasAdded = -1; - var autoRemover = _sourceList.Connect().Synchronize(_locker).Do(_ => dateTime = _scheduler.Now.UtcDateTime).Cast( + var autoRemover = _sourceList.Connect().Synchronize(locker).Do(_ => dateTime = _scheduler.Now.UtcDateTime).Cast( t => { var removeAt = _expireAfter(t); @@ -56,7 +36,7 @@ void RemovalAction() { try { - lock (_locker) + lock (locker) { var toRemove = autoRemover.Items.Where(ei => ei.ExpireAt <= _scheduler.Now.DateTime).Select(ei => ei.Item).ToList(); @@ -70,11 +50,11 @@ void RemovalAction() } var removalSubscription = new SingleAssignmentDisposable(); - if (_pollingInterval.HasValue) + if (pollingInterval.HasValue) { // use polling // ReSharper disable once InconsistentlySynchronizedField - removalSubscription.Disposable = _scheduler.ScheduleRecurringAction(_pollingInterval.Value, RemovalAction); + removalSubscription.Disposable = _scheduler.ScheduleRecurringAction(pollingInterval.Value, RemovalAction); } else { @@ -97,5 +77,4 @@ void RemovalAction() autoRemover.Dispose(); }); }); - } } diff --git a/src/DynamicData/List/Internal/Filter.cs b/src/DynamicData/List/Internal/Filter.cs index 2f1219b09..f847440b3 100644 --- a/src/DynamicData/List/Internal/Filter.cs +++ b/src/DynamicData/List/Internal/Filter.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Linq; using DynamicData.Kernel; @@ -36,9 +33,7 @@ public Filter(IObservable> source, Func predicate, ListFi _predicate = predicate ?? throw new ArgumentNullException(nameof(predicate)); } - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -94,7 +89,6 @@ public IObservable> Run() .Select(changes => changes.Transform(iwm => iwm.Item)) // use convert, not transform .SubscribeSafe(observer); }); - } private static IChangeSet Process(ChangeAwareList filtered, IChangeSet changes) { @@ -249,20 +243,13 @@ private IChangeSet Requery(Func predicate, List + private class ItemWithMatch(T item, bool isMatch, bool wasMatch = false) : IEquatable { - public T Item { get; } + public T Item { get; } = item; - public bool IsMatch { get; set; } + public bool IsMatch { get; set; } = isMatch; - public bool WasMatch { get; set; } - - public ItemWithMatch(T item, bool isMatch, bool wasMatch = false) - { - Item = item; - IsMatch = isMatch; - WasMatch = wasMatch; - } + public bool WasMatch { get; set; } = wasMatch; public bool Equals(ItemWithMatch? other) { @@ -279,10 +266,7 @@ public override bool Equals(object? obj) return Equals((ItemWithMatch)obj); } - public override int GetHashCode() - { - return EqualityComparer.Default.GetHashCode(Item!); - } + public override int GetHashCode() => EqualityComparer.Default.GetHashCode(Item!); public static bool operator ==(ItemWithMatch? left, ItemWithMatch? right) { diff --git a/src/DynamicData/List/Internal/FilterOnObservable.cs b/src/DynamicData/List/Internal/FilterOnObservable.cs index 5277f6d3e..a67b8d811 100644 --- a/src/DynamicData/List/Internal/FilterOnObservable.cs +++ b/src/DynamicData/List/Internal/FilterOnObservable.cs @@ -2,37 +2,19 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Concurrency; using System.Reactive.Disposables; using System.Reactive.Linq; namespace DynamicData.List.Internal; -internal class FilterOnObservable +internal class FilterOnObservable(IObservable> source, Func> filter, TimeSpan? buffer = null, IScheduler? scheduler = null) where TObject : notnull { - private readonly TimeSpan? _buffer; + private readonly Func> _filter = filter ?? throw new ArgumentNullException(nameof(filter)); + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly Func> _filter; - - private readonly IScheduler? _scheduler; - - private readonly IObservable> _source; - - public FilterOnObservable(IObservable> source, Func> filter, TimeSpan? buffer = null, IScheduler? scheduler = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _filter = filter ?? throw new ArgumentNullException(nameof(filter)); - _buffer = buffer; - _scheduler = scheduler; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -47,9 +29,9 @@ public IObservable> Run() var itemHasChanged = shared.MergeMany(v => _filter(v.Obj).Select(prop => new ObjWithFilterValue(v.Obj, prop))); // create a change set, either buffered or one item at the time - var itemsChanged = _buffer is null ? + var itemsChanged = buffer is null ? itemHasChanged.Select(t => new[] { t }) : - itemHasChanged.Buffer(_buffer.Value, _scheduler ?? Scheduler.Default).Where(list => list.Count > 0); + itemHasChanged.Buffer(buffer.Value, scheduler ?? Scheduler.Default).Where(list => list.Count > 0); var requiresRefresh = itemsChanged.Synchronize(locker).Select( items => @@ -67,7 +49,6 @@ public IObservable> Run() return new CompositeDisposable(publisher, shared.Connect()); }); - } private static IEnumerable IndexOfMany(IEnumerable source, IEnumerable itemsToFind, Func objectPropertyFunc, Func resultSelector) { @@ -90,42 +71,24 @@ private static IEnumerable IndexOfMany(IEnu return itemsToFind.Join(indexed, objectPropertyFunc, right => objectPropertyFunc(right.Element), (left, right) => resultSelector(left, right.Index)); } - private readonly struct ObjWithFilterValue : IEquatable + private readonly struct ObjWithFilterValue(TObject obj, bool filter) : IEquatable { - public readonly TObject Obj; + public readonly TObject Obj = obj; - public readonly bool Filter; - - public ObjWithFilterValue(TObject obj, bool filter) - { - Obj = obj; - Filter = filter; - } + public readonly bool Filter = filter; private static IEqualityComparer ObjComparer { get; } = new ObjEqualityComparer(); - public bool Equals(ObjWithFilterValue other) - { - // default equality does _not_ include Filter value, as that would cause the Filter operator that is used later to fail - return ObjComparer.Equals(this, other); - } + public bool Equals(ObjWithFilterValue other) => + ObjComparer.Equals(this, other); // default equality does _not_ include Filter value, as that would cause the Filter operator that is used later to fail - public override bool Equals(object? obj) - { - return obj is ObjWithFilterValue value && Equals(value); - } + public override bool Equals(object? obj) => obj is ObjWithFilterValue value && Equals(value); - public override int GetHashCode() - { - return ObjComparer.GetHashCode(this); - } + public override int GetHashCode() => ObjComparer.GetHashCode(this); private sealed class ObjEqualityComparer : IEqualityComparer { - public bool Equals(ObjWithFilterValue x, ObjWithFilterValue y) - { - return EqualityComparer.Default.Equals(x.Obj, y.Obj); - } + public bool Equals(ObjWithFilterValue x, ObjWithFilterValue y) => EqualityComparer.Default.Equals(x.Obj, y.Obj); public int GetHashCode(ObjWithFilterValue obj) { diff --git a/src/DynamicData/List/Internal/FilterOnProperty.cs b/src/DynamicData/List/Internal/FilterOnProperty.cs index 1a973fe00..ccd17ddb0 100644 --- a/src/DynamicData/List/Internal/FilterOnProperty.cs +++ b/src/DynamicData/List/Internal/FilterOnProperty.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.ComponentModel; using System.Linq.Expressions; using System.Reactive.Concurrency; @@ -10,30 +9,8 @@ namespace DynamicData.List.Internal; [Obsolete("Use AutoRefresh(), followed by Filter() instead")] -internal class FilterOnProperty +internal class FilterOnProperty(IObservable> source, Expression> propertySelector, Func predicate, TimeSpan? throttle = null, IScheduler? scheduler = null) where TObject : INotifyPropertyChanged { - private readonly Func _predicate; - - private readonly Expression> _propertySelector; - - private readonly IScheduler? _scheduler; - - private readonly IObservable> _source; - - private readonly TimeSpan? _throttle; - - public FilterOnProperty(IObservable> source, Expression> propertySelector, Func predicate, TimeSpan? throttle = null, IScheduler? scheduler = null) - { - _source = source; - _propertySelector = propertySelector; - _predicate = predicate; - _throttle = throttle; - _scheduler = scheduler; - } - - public IObservable> Run() - { - return _source.AutoRefresh(_propertySelector, propertyChangeThrottle: _throttle, scheduler: _scheduler).Filter(_predicate); - } + public IObservable> Run() => source.AutoRefresh(propertySelector, propertyChangeThrottle: throttle, scheduler: scheduler).Filter(predicate); } diff --git a/src/DynamicData/List/Internal/FilterStatic.cs b/src/DynamicData/List/Internal/FilterStatic.cs index d899ecfc6..69dab7d02 100644 --- a/src/DynamicData/List/Internal/FilterStatic.cs +++ b/src/DynamicData/List/Internal/FilterStatic.cs @@ -2,38 +2,27 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Linq; using System.Reactive.Linq; namespace DynamicData.List.Internal; -internal class FilterStatic +internal class FilterStatic(IObservable> source, Func predicate) where T : notnull { - private readonly Func _predicate; + private readonly Func _predicate = predicate ?? throw new ArgumentNullException(nameof(predicate)); - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public FilterStatic(IObservable> source, Func predicate) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _predicate = predicate ?? throw new ArgumentNullException(nameof(predicate)); - } - - public IObservable> Run() - { - return Observable.Defer(() => - { - return _source.Scan( - new ChangeAwareList(), - (state, changes) => - { - Process(state, changes); - return state; - }).Select(filtered => filtered.CaptureChanges()).NotEmpty(); - }); - } + public IObservable> Run() => Observable.Defer(() => + { + return _source.Scan( + new ChangeAwareList(), + (state, changes) => + { + Process(state, changes); + return state; + }).Select(filtered => filtered.CaptureChanges()).NotEmpty(); + }); private void Process(ChangeAwareList filtered, IChangeSet changes) { diff --git a/src/DynamicData/List/Internal/Group.cs b/src/DynamicData/List/Internal/Group.cs index f3f72002a..480aa4c59 100644 --- a/src/DynamicData/List/Internal/Group.cs +++ b/src/DynamicData/List/Internal/Group.cs @@ -2,17 +2,12 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - namespace DynamicData.List.Internal; -internal class Group : IGroup, IDisposable, IEquatable> +internal class Group(TGroup groupKey) : IGroup, IDisposable, IEquatable> where TObject : notnull { - public Group(TGroup groupKey) => GroupKey = groupKey; - - public TGroup GroupKey { get; } + public TGroup GroupKey { get; } = groupKey; public IObservableList List => Source; @@ -47,15 +42,9 @@ public bool Equals(Group? other) return EqualityComparer.Default.Equals(GroupKey, other.GroupKey); } - public override bool Equals(object? obj) - { - return obj is Group value && Equals(value); - } + public override bool Equals(object? obj) => obj is Group value && Equals(value); - public override int GetHashCode() - { - return GroupKey is null ? 0 : EqualityComparer.Default.GetHashCode(GroupKey); - } + public override int GetHashCode() => GroupKey is null ? 0 : EqualityComparer.Default.GetHashCode(GroupKey); public override string ToString() => $"Group of {GroupKey} ({List.Count} records)"; } diff --git a/src/DynamicData/List/Internal/GroupOn.cs b/src/DynamicData/List/Internal/GroupOn.cs index 42c96ec76..3838dcc13 100644 --- a/src/DynamicData/List/Internal/GroupOn.cs +++ b/src/DynamicData/List/Internal/GroupOn.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -13,26 +10,17 @@ namespace DynamicData.List.Internal; -internal sealed class GroupOn +internal sealed class GroupOn(IObservable> source, Func groupSelector, IObservable? regrouper) where TObject : notnull where TGroupKey : notnull { - private readonly Func _groupSelector; + private readonly Func _groupSelector = groupSelector ?? throw new ArgumentNullException(nameof(groupSelector)); - private readonly IObservable? _regrouper; + private readonly IObservable? _regrouper = regrouper; - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public GroupOn(IObservable> source, Func groupSelector, IObservable? regrouper) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _groupSelector = groupSelector ?? throw new ArgumentNullException(nameof(groupSelector)); - _regrouper = regrouper; - } - - public IObservable>> Run() - { - return Observable.Create>>( + public IObservable>> Run() => Observable.Create>>( observer => { var groupings = new ChangeAwareList>(); @@ -55,7 +43,6 @@ public IObservable>> Run() return new CompositeDisposable(publisher, shared.Connect()); }); - } private static GroupWithAddIndicator GetCache(IDictionary> groupCaches, TGroupKey key) { @@ -249,20 +236,13 @@ public GroupWithAddIndicator(Group group, bool wasCreated) public bool WasCreated { get; } } - private sealed class ItemWithGroupKey : IEquatable + private sealed class ItemWithGroupKey(TObject item, TGroupKey group, Optional previousGroup) : IEquatable { - public ItemWithGroupKey(TObject item, TGroupKey group, Optional previousGroup) - { - Item = item; - Group = group; - PreviousGroup = previousGroup; - } - - public TGroupKey Group { get; set; } + public TGroupKey Group { get; set; } = group; - public TObject Item { get; } + public TObject Item { get; } = item; - public Optional PreviousGroup { get; } + public Optional PreviousGroup { get; } = previousGroup; /// Returns a value that indicates whether the values of two objects are equal. /// The first value to compare. @@ -312,10 +292,7 @@ public override bool Equals(object? obj) return obj is ItemWithGroupKey value && Equals(value); } - public override int GetHashCode() - { - return Item is null ? 0 : EqualityComparer.Default.GetHashCode(Item); - } + public override int GetHashCode() => Item is null ? 0 : EqualityComparer.Default.GetHashCode(Item); public override string ToString() => $"{Item} ({Group})"; } diff --git a/src/DynamicData/List/Internal/GroupOnImmutable.cs b/src/DynamicData/List/Internal/GroupOnImmutable.cs index 4174b1fce..01eeb529e 100644 --- a/src/DynamicData/List/Internal/GroupOnImmutable.cs +++ b/src/DynamicData/List/Internal/GroupOnImmutable.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -13,26 +10,17 @@ namespace DynamicData.List.Internal; -internal sealed class GroupOnImmutable +internal sealed class GroupOnImmutable(IObservable> source, Func groupSelector, IObservable? reGrouper) where TObject : notnull where TGroupKey : notnull { - private readonly Func _groupSelector; + private readonly Func _groupSelector = groupSelector ?? throw new ArgumentNullException(nameof(groupSelector)); - private readonly IObservable? _reGrouper; + private readonly IObservable? _reGrouper = reGrouper; - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public GroupOnImmutable(IObservable> source, Func groupSelector, IObservable? reGrouper) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _groupSelector = groupSelector ?? throw new ArgumentNullException(nameof(groupSelector)); - _reGrouper = reGrouper; - } - - public IObservable>> Run() - { - return Observable.Create>>( + public IObservable>> Run() => Observable.Create>>( observer => { var groupings = new ChangeAwareList>(); @@ -57,7 +45,6 @@ public IObservable>> Run() return new CompositeDisposable(publisher, shared.Connect()); }); - } private static IChangeSet> CreateChangeSet(ChangeAwareList> result, IDictionary allGroupings, IDictionary> initialStateOfGroups) { @@ -105,15 +92,9 @@ private static GroupContainer GetGroup(IDictionary gr return newcache; } - private static IGrouping GetGroupState(GroupContainer grouping) - { - return new ImmutableGroup(grouping.Key, grouping.List); - } + private static IGrouping GetGroupState(GroupContainer grouping) => new ImmutableGroup(grouping.Key, grouping.List); - private static IGrouping GetGroupState(TGroupKey key, IList list) - { - return new ImmutableGroup(key, list); - } + private static IGrouping GetGroupState(TGroupKey key, IList list) => new ImmutableGroup(key, list); private static IChangeSet> Process(ChangeAwareList> result, IDictionary allGroupings, IChangeSet changes) { @@ -271,32 +252,20 @@ private IChangeSet> Regroup(ChangeAwareList List { get; } = new List(); } - private sealed class ItemWithGroupKey : IEquatable + private sealed class ItemWithGroupKey(TObject item, TGroupKey group, Optional previousGroup) : IEquatable { - public ItemWithGroupKey(TObject item, TGroupKey group, Optional previousGroup) - { - Item = item; - Group = group; - PreviousGroup = previousGroup; - } + public TGroupKey Group { get; set; } = group; - public TGroupKey Group { get; set; } + public TObject Item { get; } = item; - public TObject Item { get; } - - public Optional PreviousGroup { get; } + public Optional PreviousGroup { get; } = previousGroup; public static bool operator ==(ItemWithGroupKey left, ItemWithGroupKey right) { @@ -323,19 +292,10 @@ public bool Equals(ItemWithGroupKey? other) return EqualityComparer.Default.Equals(Item, other.Item); } - public override bool Equals(object? obj) - { - return obj is ItemWithGroupKey value && Equals(value); - } + public override bool Equals(object? obj) => obj is ItemWithGroupKey value && Equals(value); - public override int GetHashCode() - { - return Item is null ? 0 : EqualityComparer.Default.GetHashCode(Item); - } + public override int GetHashCode() => Item is null ? 0 : EqualityComparer.Default.GetHashCode(Item); - public override string ToString() - { - return $"{Item} ({Group})"; - } + public override string ToString() => $"{Item} ({Group})"; } } diff --git a/src/DynamicData/List/Internal/GroupOnProperty.cs b/src/DynamicData/List/Internal/GroupOnProperty.cs index c81fd278a..012800aa6 100644 --- a/src/DynamicData/List/Internal/GroupOnProperty.cs +++ b/src/DynamicData/List/Internal/GroupOnProperty.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.ComponentModel; using System.Linq.Expressions; using System.Reactive.Concurrency; @@ -12,45 +11,26 @@ namespace DynamicData.List.Internal; -internal sealed class GroupOnProperty +internal sealed class GroupOnProperty(IObservable> source, Expression> groupSelectorKey, TimeSpan? throttle = null, IScheduler? scheduler = null) where TObject : INotifyPropertyChanged where TGroup : notnull { - private readonly Func _groupSelector; + private readonly Func _groupSelector = groupSelectorKey.Compile(); + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly Expression> _propertySelector; - - private readonly IScheduler? _scheduler; - - private readonly IObservable> _source; - - private readonly TimeSpan? _throttle; - - public GroupOnProperty(IObservable> source, Expression> groupSelectorKey, TimeSpan? throttle = null, IScheduler? scheduler = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _groupSelector = groupSelectorKey.Compile(); - _propertySelector = groupSelectorKey; - _throttle = throttle; - _scheduler = scheduler; - } - - public IObservable>> Run() - { - return _source.Publish( + public IObservable>> Run() => _source.Publish( shared => { // Monitor explicit property changes - var regrouper = shared.WhenValueChanged(_propertySelector, false).ToUnit(); + var regrouper = shared.WhenValueChanged(groupSelectorKey, false).ToUnit(); // add a throttle if specified - if (_throttle is not null) + if (throttle is not null) { - regrouper = regrouper.Throttle(_throttle.Value, _scheduler ?? Scheduler.Default); + regrouper = regrouper.Throttle(throttle.Value, scheduler ?? Scheduler.Default); } // Use property changes as a trigger to re-evaluate Grouping return shared.GroupOn(_groupSelector, regrouper); }); - } } diff --git a/src/DynamicData/List/Internal/GroupOnPropertyWithImmutableState.cs b/src/DynamicData/List/Internal/GroupOnPropertyWithImmutableState.cs index 540fc1499..fc1530a22 100644 --- a/src/DynamicData/List/Internal/GroupOnPropertyWithImmutableState.cs +++ b/src/DynamicData/List/Internal/GroupOnPropertyWithImmutableState.cs @@ -2,7 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.ComponentModel; using System.Linq.Expressions; using System.Reactive.Concurrency; @@ -12,45 +11,26 @@ namespace DynamicData.List.Internal; -internal sealed class GroupOnPropertyWithImmutableState +internal sealed class GroupOnPropertyWithImmutableState(IObservable> source, Expression> groupSelectorKey, TimeSpan? throttle = null, IScheduler? scheduler = null) where TObject : INotifyPropertyChanged where TGroup : notnull { - private readonly Func _groupSelector; + private readonly Func _groupSelector = groupSelectorKey.Compile(); + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly Expression> _propertySelector; - - private readonly IScheduler? _scheduler; - - private readonly IObservable> _source; - - private readonly TimeSpan? _throttle; - - public GroupOnPropertyWithImmutableState(IObservable> source, Expression> groupSelectorKey, TimeSpan? throttle = null, IScheduler? scheduler = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _groupSelector = groupSelectorKey.Compile(); - _propertySelector = groupSelectorKey; - _throttle = throttle; - _scheduler = scheduler; - } - - public IObservable>> Run() - { - return _source.Publish( + public IObservable>> Run() => _source.Publish( shared => { // Monitor explicit property changes - var regrouper = shared.WhenValueChanged(_propertySelector, false).ToUnit(); + var regrouper = shared.WhenValueChanged(groupSelectorKey, false).ToUnit(); // add a throttle if specified - if (_throttle is not null) + if (throttle is not null) { - regrouper = regrouper.Throttle(_throttle.Value, _scheduler ?? Scheduler.Default); + regrouper = regrouper.Throttle(throttle.Value, scheduler ?? Scheduler.Default); } // Use property changes as a trigger to re-evaluate Grouping return shared.GroupWithImmutableState(_groupSelector, regrouper); }); - } } diff --git a/src/DynamicData/List/Internal/ImmutableGroup.cs b/src/DynamicData/List/Internal/ImmutableGroup.cs index 41503bc91..84cc19cfc 100644 --- a/src/DynamicData/List/Internal/ImmutableGroup.cs +++ b/src/DynamicData/List/Internal/ImmutableGroup.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - using DynamicData.Kernel; namespace DynamicData.List.Internal; @@ -65,13 +62,7 @@ public override bool Equals(object? obj) return obj is ImmutableGroup value && Equals(value); } - public override int GetHashCode() - { - return Key is null ? 0 : EqualityComparer.Default.GetHashCode(Key); - } + public override int GetHashCode() => Key is null ? 0 : EqualityComparer.Default.GetHashCode(Key); - public override string ToString() - { - return $"Grouping for: {Key} ({Count} items)"; - } + public override string ToString() => $"Grouping for: {Key} ({Count} items)"; } diff --git a/src/DynamicData/List/Internal/LimitSizeTo.cs b/src/DynamicData/List/Internal/LimitSizeTo.cs index 9aab3e218..d8dad320e 100644 --- a/src/DynamicData/List/Internal/LimitSizeTo.cs +++ b/src/DynamicData/List/Internal/LimitSizeTo.cs @@ -2,43 +2,26 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Concurrency; using System.Reactive.Linq; -using System.Threading; namespace DynamicData.List.Internal; -internal sealed class LimitSizeTo +internal sealed class LimitSizeTo(ISourceList sourceList, int sizeLimit, IScheduler scheduler, object locker) where T : notnull { - private readonly object _locker; - - private readonly IScheduler _scheduler; - - private readonly int _sizeLimit; - - private readonly ISourceList _sourceList; - - public LimitSizeTo(ISourceList sourceList, int sizeLimit, IScheduler scheduler, object locker) - { - _sourceList = sourceList ?? throw new ArgumentNullException(nameof(sourceList)); - _sizeLimit = sizeLimit; - _scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler)); - _locker = locker; - } + private readonly IScheduler _scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler)); + private readonly ISourceList _sourceList = sourceList ?? throw new ArgumentNullException(nameof(sourceList)); public IObservable> Run() { var emptyResult = new List(); long orderItemWasAdded = -1; - return _sourceList.Connect().ObserveOn(_scheduler).Synchronize(_locker).Transform(t => new ExpirableItem(t, _scheduler.Now.UtcDateTime, Interlocked.Increment(ref orderItemWasAdded))).ToCollection().Select( + return _sourceList.Connect().ObserveOn(_scheduler).Synchronize(locker).Transform(t => new ExpirableItem(t, _scheduler.Now.UtcDateTime, Interlocked.Increment(ref orderItemWasAdded))).ToCollection().Select( list => { - var numberToExpire = list.Count - _sizeLimit; + var numberToExpire = list.Count - sizeLimit; if (numberToExpire < 0) { return emptyResult; diff --git a/src/DynamicData/List/Internal/MergeMany.cs b/src/DynamicData/List/Internal/MergeMany.cs index 2232b9c49..c3bc722c3 100644 --- a/src/DynamicData/List/Internal/MergeMany.cs +++ b/src/DynamicData/List/Internal/MergeMany.cs @@ -2,29 +2,20 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; using System.Reactive.Subjects; namespace DynamicData.List.Internal; -internal sealed class MergeMany +internal sealed class MergeMany(IObservable> source, Func> observableSelector) where T : notnull { - private readonly Func> _observableSelector; + private readonly Func> _observableSelector = observableSelector ?? throw new ArgumentNullException(nameof(observableSelector)); - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public MergeMany(IObservable> source, Func> observableSelector) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _observableSelector = observableSelector ?? throw new ArgumentNullException(nameof(observableSelector)); - } - - public IObservable Run() - { - return Observable.Create( + public IObservable Run() => Observable.Create( observer => { var counter = new SubscriptionCounter(); @@ -39,7 +30,6 @@ public IObservable Run() return new CompositeDisposable(disposable, counter); }); - } private sealed class SubscriptionCounter : IDisposable { diff --git a/src/DynamicData/List/Internal/OnBeingAdded.cs b/src/DynamicData/List/Internal/OnBeingAdded.cs index 6be5c453b..051fe45fd 100644 --- a/src/DynamicData/List/Internal/OnBeingAdded.cs +++ b/src/DynamicData/List/Internal/OnBeingAdded.cs @@ -2,30 +2,20 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Linq; using DynamicData.Kernel; namespace DynamicData.List.Internal; -internal sealed class OnBeingAdded +internal sealed class OnBeingAdded(IObservable> source, Action callback) where T : notnull { - private readonly Action _callback; + private readonly Action _callback = callback ?? throw new ArgumentNullException(nameof(callback)); - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public OnBeingAdded(IObservable> source, Action callback) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _callback = callback ?? throw new ArgumentNullException(nameof(callback)); - } - - public IObservable> Run() - { - return _source.Do(RegisterForAddition); - } + public IObservable> Run() => _source.Do(RegisterForAddition); private void RegisterForAddition(IChangeSet changes) { diff --git a/src/DynamicData/List/Internal/OnBeingRemoved.cs b/src/DynamicData/List/Internal/OnBeingRemoved.cs index 8b1daed2c..e21a1fd8a 100644 --- a/src/DynamicData/List/Internal/OnBeingRemoved.cs +++ b/src/DynamicData/List/Internal/OnBeingRemoved.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -11,24 +9,13 @@ namespace DynamicData.List.Internal; -internal sealed class OnBeingRemoved +internal sealed class OnBeingRemoved(IObservable> source, Action callback, bool invokeOnUnsubscribe) where T : notnull { - private readonly Action _callback; - private readonly bool _invokeOnUnsubscribe; + private readonly Action _callback = callback ?? throw new ArgumentNullException(nameof(callback)); + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly IObservable> _source; - - public OnBeingRemoved(IObservable> source, Action callback, bool invokeOnUnsubscribe) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _callback = callback ?? throw new ArgumentNullException(nameof(callback)); - _invokeOnUnsubscribe = invokeOnUnsubscribe; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -40,13 +27,12 @@ public IObservable> Run() { subscriber.Dispose(); - if (_invokeOnUnsubscribe) + if (invokeOnUnsubscribe) { items.ForEach(t => _callback(t)); } }); }); - } private void RegisterForRemoval(IList items, IChangeSet changes) { diff --git a/src/DynamicData/List/Internal/Pager.cs b/src/DynamicData/List/Internal/Pager.cs index 7149ae53f..6f04c112e 100644 --- a/src/DynamicData/List/Internal/Pager.cs +++ b/src/DynamicData/List/Internal/Pager.cs @@ -5,26 +5,16 @@ using System.Collections; using System.Reactive.Linq; -using DynamicData.Kernel; - namespace DynamicData.List.Internal; -internal class Pager +internal class Pager(IObservable> source, IObservable requests) where T : notnull { - private readonly IObservable _requests; - - private readonly IObservable> _source; + private readonly IObservable _requests = requests ?? throw new ArgumentNullException(nameof(requests)); - public Pager(IObservable> source, IObservable requests) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _requests = requests ?? throw new ArgumentNullException(nameof(requests)); - } + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -50,7 +40,6 @@ public IObservable> Run() .Select(x => x!) .SubscribeSafe(observer); }); - } private static int CalculatePages(ICollection all, IPageRequest? request) { diff --git a/src/DynamicData/List/Internal/QueryWhenChanged.cs b/src/DynamicData/List/Internal/QueryWhenChanged.cs index 79db5c080..71f169874 100644 --- a/src/DynamicData/List/Internal/QueryWhenChanged.cs +++ b/src/DynamicData/List/Internal/QueryWhenChanged.cs @@ -2,35 +2,25 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Linq; using DynamicData.Kernel; namespace DynamicData.List.Internal; -internal class QueryWhenChanged +internal class QueryWhenChanged(IObservable> source) where T : notnull { - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public QueryWhenChanged(IObservable> source) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - } + public IObservable> Run() => Observable.Create>(observer => + { + var list = new List(); - public IObservable> Run() - { - return Observable.Create>(observer => - { - var list = new List(); - - return _source.Subscribe(changes => - { - list.Clone(changes); - observer.OnNext(new ReadOnlyCollectionLight(list)); - }); - }); - } + return _source.Subscribe(changes => + { + list.Clone(changes); + observer.OnNext(new ReadOnlyCollectionLight(list)); + }); + }); } diff --git a/src/DynamicData/List/Internal/ReaderWriter.cs b/src/DynamicData/List/Internal/ReaderWriter.cs index 89aa89d56..1d63d30ad 100644 --- a/src/DynamicData/List/Internal/ReaderWriter.cs +++ b/src/DynamicData/List/Internal/ReaderWriter.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - using DynamicData.Kernel; namespace DynamicData.List.Internal; diff --git a/src/DynamicData/List/Internal/RefCount.cs b/src/DynamicData/List/Internal/RefCount.cs index 754a61621..329064207 100644 --- a/src/DynamicData/List/Internal/RefCount.cs +++ b/src/DynamicData/List/Internal/RefCount.cs @@ -2,38 +2,27 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; namespace DynamicData.List.Internal; -internal class RefCount +internal class RefCount(IObservable> source) where T : notnull { private readonly object _locker = new(); - - private readonly IObservable> _source; - private IObservableList? _list; private int _refCount; - public RefCount(IObservable> source) - { - _source = source; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { lock (_locker) { if (++_refCount == 1) { - _list = _source.AsObservableList(); + _list = source.AsObservableList(); } } @@ -61,5 +50,4 @@ public IObservable> Run() listToDispose?.Dispose(); }); }); - } } diff --git a/src/DynamicData/List/Internal/ReferenceCountTracker.cs b/src/DynamicData/List/Internal/ReferenceCountTracker.cs index 841e492d7..526766524 100644 --- a/src/DynamicData/List/Internal/ReferenceCountTracker.cs +++ b/src/DynamicData/List/Internal/ReferenceCountTracker.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - namespace DynamicData.List.Internal; /// @@ -44,15 +41,9 @@ public bool Add(T item) return false; } - public void Clear() - { - ReferenceCounts.Clear(); - } + public void Clear() => ReferenceCounts.Clear(); - public bool Contains(T item) - { - return ReferenceCounts.ContainsKey(item); - } + public bool Contains(T item) => ReferenceCounts.ContainsKey(item); /// /// Decrements the reference count for the item. Returns true when reference count goes from 1 to 0. diff --git a/src/DynamicData/List/Internal/Sort.cs b/src/DynamicData/List/Internal/Sort.cs index ff9f2cd6a..6a9c7eea5 100644 --- a/src/DynamicData/List/Internal/Sort.cs +++ b/src/DynamicData/List/Internal/Sort.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive; using System.Reactive.Linq; @@ -12,34 +9,16 @@ namespace DynamicData.List.Internal; -internal sealed class Sort +internal sealed class Sort(IObservable> source, IComparer? comparer, SortOptions sortOptions, IObservable? resort, IObservable>? comparerObservable, int resetThreshold) where T : notnull { - private readonly IObservable> _comparerObservable; + private readonly IObservable> _comparerObservable = comparerObservable ?? Observable.Never>(); + private readonly IObservable _resort = resort ?? Observable.Never(); + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly int _resetThreshold; + private IComparer _comparer = comparer ?? Comparer.Default; - private readonly IObservable _resort; - - private readonly SortOptions _sortOptions; - - private readonly IObservable> _source; - - private IComparer _comparer; - - public Sort(IObservable> source, IComparer? comparer, SortOptions sortOptions, IObservable? resort, IObservable>? comparerObservable, int resetThreshold) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _resort = resort ?? Observable.Never(); - _comparerObservable = comparerObservable ?? Observable.Never>(); - _comparer = comparer ?? Comparer.Default; - _sortOptions = sortOptions; - _resetThreshold = resetThreshold; - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -49,24 +28,23 @@ public IObservable> Run() var dataChanged = _source.Synchronize(locker).Select( changes => { - if (_resetThreshold > 1) + if (resetThreshold > 1) { original.Clone(changes); } - return changes.TotalChanges > _resetThreshold ? Reset(original, target) : Process(target, changes); + return changes.TotalChanges > resetThreshold ? Reset(original, target) : Process(target, changes); }); var resort = _resort.Synchronize(locker).Select(_ => Reorder(target)); var changeComparer = _comparerObservable.Synchronize(locker).Select(comparer => ChangeComparer(target, comparer)); return changeComparer.Merge(resort).Merge(dataChanged).Where(changes => changes.Count != 0).SubscribeSafe(observer); }); - } private IChangeSet ChangeComparer(ChangeAwareList target, IComparer comparer) { _comparer = comparer; - if (_resetThreshold > 0 && target.Count <= _resetThreshold) + if (resetThreshold > 0 && target.Count <= resetThreshold) { return Reorder(target); } @@ -79,7 +57,7 @@ private IChangeSet ChangeComparer(ChangeAwareList target, IComparer com private int GetCurrentPosition(ChangeAwareList target, T item) { - var index = _sortOptions == SortOptions.UseBinarySearch ? target.BinarySearch(item, _comparer) : target.IndexOf(item); + var index = sortOptions == SortOptions.UseBinarySearch ? target.BinarySearch(item, _comparer) : target.IndexOf(item); if (index < 0) { @@ -89,10 +67,7 @@ private int GetCurrentPosition(ChangeAwareList target, T item) return index; } - private int GetInsertPosition(ChangeAwareList target, T item) - { - return _sortOptions == SortOptions.UseBinarySearch ? GetInsertPositionBinary(target, item) : GetInsertPositionLinear(target, item); - } + private int GetInsertPosition(ChangeAwareList target, T item) => sortOptions == SortOptions.UseBinarySearch ? GetInsertPositionBinary(target, item) : GetInsertPositionLinear(target, item); private int GetInsertPositionBinary(ChangeAwareList target, T item) { diff --git a/src/DynamicData/List/Internal/SubscribeMany.cs b/src/DynamicData/List/Internal/SubscribeMany.cs index ce2605362..5e105ece7 100644 --- a/src/DynamicData/List/Internal/SubscribeMany.cs +++ b/src/DynamicData/List/Internal/SubscribeMany.cs @@ -2,28 +2,19 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; namespace DynamicData.List.Internal; -internal sealed class SubscribeMany +internal sealed class SubscribeMany(IObservable> source, Func subscriptionFactory) where T : notnull { - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - private readonly Func _subscriptionFactory; + private readonly Func _subscriptionFactory = subscriptionFactory ?? throw new ArgumentNullException(nameof(subscriptionFactory)); - public SubscribeMany(IObservable> source, Func subscriptionFactory) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _subscriptionFactory = subscriptionFactory ?? throw new ArgumentNullException(nameof(subscriptionFactory)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var shared = _source.Publish(); @@ -31,5 +22,4 @@ public IObservable> Run() return new CompositeDisposable(subscriptions, shared.SubscribeSafe(observer), shared.Connect()); }); - } } diff --git a/src/DynamicData/List/Internal/Switch.cs b/src/DynamicData/List/Internal/Switch.cs index 0fb874940..b1ccc76f9 100644 --- a/src/DynamicData/List/Internal/Switch.cs +++ b/src/DynamicData/List/Internal/Switch.cs @@ -2,25 +2,17 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; namespace DynamicData.List.Internal; -internal sealed class Switch +internal sealed class Switch(IObservable>> sources) where T : notnull { - private readonly IObservable>> _sources; + private readonly IObservable>> _sources = sources ?? throw new ArgumentNullException(nameof(sources)); - public Switch(IObservable>> sources) - { - _sources = sources ?? throw new ArgumentNullException(nameof(sources)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -40,5 +32,4 @@ public IObservable> Run() var publisher = destination.Connect().SubscribeSafe(observer); return new CompositeDisposable(destination, populator, publisher); }); - } } diff --git a/src/DynamicData/List/Internal/ToObservableChangeSet.cs b/src/DynamicData/List/Internal/ToObservableChangeSet.cs index 5b3aef18a..a614dbbcd 100644 --- a/src/DynamicData/List/Internal/ToObservableChangeSet.cs +++ b/src/DynamicData/List/Internal/ToObservableChangeSet.cs @@ -8,30 +8,16 @@ namespace DynamicData.List.Internal; -internal class ToObservableChangeSet +internal class ToObservableChangeSet(IObservable> source, Func? expireAfter, int limitSizeTo, IScheduler? scheduler = null) where T : notnull { - private readonly Func? _expireAfter; - - private readonly int _limitSizeTo; - - private readonly IScheduler _scheduler; - - private readonly IObservable> _source; + private readonly IScheduler _scheduler = scheduler ?? Scheduler.Default; public ToObservableChangeSet(IObservable source, Func? expireAfter, int limitSizeTo, IScheduler? scheduler = null) : this(source.Select(t => new[] { t }), expireAfter, limitSizeTo, scheduler) { } - public ToObservableChangeSet(IObservable> source, Func? expireAfter, int limitSizeTo, IScheduler? scheduler = null) - { - _source = source; - _expireAfter = expireAfter; - _limitSizeTo = limitSizeTo; - _scheduler = scheduler ?? Scheduler.Default; - } - public IObservable> Run() => Observable.Create>( observer => { @@ -40,17 +26,17 @@ public IObservable> Run() => Observable.Create>( var dataSource = new SourceList(); // load local data source with current items - var populator = _source.Synchronize(locker) + var populator = source.Synchronize(locker) .Subscribe(items => { dataSource.Edit(innerList => { innerList.AddRange(items); - if (_limitSizeTo > 0 && innerList.Count > _limitSizeTo) + if (limitSizeTo > 0 && innerList.Count > limitSizeTo) { // remove oldest items [these will always be the first x in the list] - var toRemove = innerList.Count - _limitSizeTo; + var toRemove = innerList.Count - limitSizeTo; innerList.RemoveRange(0, toRemove); } }); @@ -62,12 +48,12 @@ public IObservable> Run() => Observable.Create>( DateTime Trim(DateTime date, long ticks) => new(date.Ticks - (date.Ticks % ticks), date.Kind); - if (_expireAfter is not null) + if (expireAfter is not null) { var expiry = dataSource.Connect() .Transform(t => { - var removeAt = _expireAfter?.Invoke(t); + var removeAt = expireAfter?.Invoke(t); if (removeAt is null) return (Item: t, ExpireAt: DateTime.MaxValue); diff --git a/src/DynamicData/List/Internal/TransformAsync.cs b/src/DynamicData/List/Internal/TransformAsync.cs index c6a6793d3..cb6276b74 100644 --- a/src/DynamicData/List/Internal/TransformAsync.cs +++ b/src/DynamicData/List/Internal/TransformAsync.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for full license information. using System.Reactive.Linq; -using System.Reactive.Threading.Tasks; -using DynamicData.Binding; using DynamicData.Kernel; namespace DynamicData.List.Internal; diff --git a/src/DynamicData/List/Internal/TransformMany.cs b/src/DynamicData/List/Internal/TransformMany.cs index 2044aa05a..0a05beb71 100644 --- a/src/DynamicData/List/Internal/TransformMany.cs +++ b/src/DynamicData/List/Internal/TransformMany.cs @@ -12,17 +12,12 @@ namespace DynamicData.List.Internal; -internal sealed class TransformMany +internal sealed class TransformMany(IObservable> source, Func> manySelector, IEqualityComparer? equalityComparer = null, Func>>? childChanges = null) where TSource : notnull where TDestination : notnull { - private readonly Func>>? _childChanges; - - private readonly IEqualityComparer _equalityComparer; - - private readonly Func> _manySelector; - - private readonly IObservable> _source; + private readonly IEqualityComparer _equalityComparer = equalityComparer ?? EqualityComparer.Default; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); public TransformMany(IObservable> source, Func> manySelector, IEqualityComparer? equalityComparer = null) : this( @@ -84,17 +79,9 @@ public TransformMany(IObservable> source, Func> source, Func> manySelector, IEqualityComparer? equalityComparer = null, Func>>? childChanges = null) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _manySelector = manySelector; - _childChanges = childChanges; - _equalityComparer = equalityComparer ?? EqualityComparer.Default; - } - public IObservable> Run() { - if (_childChanges is not null) + if (childChanges is not null) { return CreateWithChangeSet(); } @@ -105,7 +92,7 @@ public IObservable> Run() // NB: ChangeAwareList is used internally by dd to capture changes to a list and ensure they can be replayed by subsequent operators var result = new ChangeAwareList(); - return _source.Transform(item => new ManyContainer(_manySelector(item).ToArray()), true).Select( + return _source.Transform(item => new ManyContainer(manySelector(item).ToArray()), true).Select( changes => { var destinationChanges = new DestinationEnumerator(changes, _equalityComparer); @@ -117,7 +104,7 @@ public IObservable> Run() private IObservable> CreateWithChangeSet() { - if (_childChanges is null) + if (childChanges is null) { throw new InvalidOperationException("_childChanges must not be null."); } @@ -131,8 +118,8 @@ private IObservable> CreateWithChangeSet() t => { var locker = new object(); - var collection = _manySelector(t); - var changes = _childChanges(t).Synchronize(locker).Skip(1); + var collection = manySelector(t); + var changes = childChanges(t).Synchronize(locker).Skip(1); return new ManyContainer(collection, changes); }).Publish(); @@ -162,21 +149,11 @@ private IObservable> CreateWithChangeSet() } // make this an instance - private sealed class DestinationEnumerator : IEnumerable> + private sealed class DestinationEnumerator(IChangeSet changes, IEqualityComparer equalityComparer) : IEnumerable> { - private readonly IChangeSet _changes; - - private readonly IEqualityComparer _equalityComparer; - - public DestinationEnumerator(IChangeSet changes, IEqualityComparer equalityComparer) - { - _changes = changes; - _equalityComparer = equalityComparer; - } - public IEnumerator> GetEnumerator() { - foreach (var change in _changes) + foreach (var change in changes) { switch (change.Reason) { @@ -203,10 +180,10 @@ public IEnumerator> GetEnumerator() var currentItems = change.Item.Current.Destination.AsArray(); var previousItems = change.Item.Previous.Value.Destination.AsArray(); - var adds = currentItems.Except(previousItems, _equalityComparer); + var adds = currentItems.Except(previousItems, equalityComparer); // I am not sure whether it is possible to translate the original change into a replace - foreach (var destination in previousItems.Except(currentItems, _equalityComparer)) + foreach (var destination in previousItems.Except(currentItems, equalityComparer)) { yield return new Change(ListChangeReason.Remove, destination); } @@ -255,39 +232,22 @@ public IEnumerator> GetEnumerator() } } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } - private sealed class ManyContainer + private sealed class ManyContainer(IEnumerable destination, IObservable>? changes = null) { - public ManyContainer(IEnumerable destination, IObservable>? changes = null) - { - Destination = destination; - Changes = changes ?? Observable.Empty>(); - } + public IObservable> Changes { get; } = changes ?? Observable.Empty>(); - public IObservable> Changes { get; } - - public IEnumerable Destination { get; } + public IEnumerable Destination { get; } = destination; } - private class ManySelectorFunc : IEnumerable + private class ManySelectorFunc(TSource source, Func> selector) : IEnumerable { - private readonly TSource _source; - - private readonly Func> _selector; - - public ManySelectorFunc(TSource source, Func> selector) - { - _source = source; - _selector = selector ?? throw new ArgumentNullException(nameof(selector)); - } + private readonly Func> _selector = selector ?? throw new ArgumentNullException(nameof(selector)); - public IEnumerator GetEnumerator() => _selector(_source).GetEnumerator(); + public IEnumerator GetEnumerator() => _selector(source).GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => _selector(_source).GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => _selector(source).GetEnumerator(); } } diff --git a/src/DynamicData/List/Internal/Transformer.cs b/src/DynamicData/List/Internal/Transformer.cs index 93d94ff4b..c3709829d 100644 --- a/src/DynamicData/List/Internal/Transformer.cs +++ b/src/DynamicData/List/Internal/Transformer.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Linq; using DynamicData.Kernel; @@ -177,17 +174,11 @@ private void Transform(ChangeAwareList transformed, IC } } - internal sealed class TransformedItemContainer : IEquatable + internal sealed class TransformedItemContainer(TSource source, TDestination destination) : IEquatable { - public TransformedItemContainer(TSource source, TDestination destination) - { - Source = source; - Destination = destination; - } - - public TDestination Destination { get; } + public TDestination Destination { get; } = destination; - public TSource Source { get; } + public TSource Source { get; } = source; public static bool operator ==(TransformedItemContainer left, TransformedItemContainer right) => Equals(left, right); diff --git a/src/DynamicData/List/Internal/UnifiedChange.cs b/src/DynamicData/List/Internal/UnifiedChange.cs index bfe474743..3471b9bb8 100644 --- a/src/DynamicData/List/Internal/UnifiedChange.cs +++ b/src/DynamicData/List/Internal/UnifiedChange.cs @@ -2,14 +2,11 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - using DynamicData.Kernel; namespace DynamicData.List.Internal; -internal readonly struct UnifiedChange : IEquatable> +internal readonly struct UnifiedChange(ListChangeReason reason, T current, Optional previous) : IEquatable> where T : notnull { public UnifiedChange(ListChangeReason reason, T current) @@ -17,18 +14,11 @@ public UnifiedChange(ListChangeReason reason, T current) { } - public UnifiedChange(ListChangeReason reason, T current, Optional previous) - { - Reason = reason; - Current = current; - Previous = previous; - } - - public ListChangeReason Reason { get; } + public ListChangeReason Reason { get; } = reason; - public T Current { get; } + public T Current { get; } = current; - public Optional Previous { get; } + public Optional Previous { get; } = previous; public static bool operator ==(UnifiedChange left, UnifiedChange right) { @@ -40,10 +30,7 @@ public UnifiedChange(ListChangeReason reason, T current, Optional previous) return !left.Equals(right); } - public bool Equals(UnifiedChange other) - { - return Reason == other.Reason && EqualityComparer.Default.Equals(Current, other.Current) && Previous.Equals(other.Previous); - } + public bool Equals(UnifiedChange other) => Reason == other.Reason && EqualityComparer.Default.Equals(Current, other.Current) && Previous.Equals(other.Previous); public override bool Equals(object? obj) { @@ -66,8 +53,5 @@ public override int GetHashCode() } } - public override string ToString() - { - return $"Reason: {Reason}, Current: {Current}, Previous: {Previous}"; - } + public override string ToString() => $"Reason: {Reason}, Current: {Current}, Previous: {Previous}"; } diff --git a/src/DynamicData/List/Internal/Virtualiser.cs b/src/DynamicData/List/Internal/Virtualiser.cs index 8213beee3..3ca120728 100644 --- a/src/DynamicData/List/Internal/Virtualiser.cs +++ b/src/DynamicData/List/Internal/Virtualiser.cs @@ -7,22 +7,14 @@ namespace DynamicData.List.Internal; -internal sealed class Virtualiser +internal sealed class Virtualiser(IObservable> source, IObservable requests) where T : notnull { - private readonly IObservable _requests; + private readonly IObservable _requests = requests ?? throw new ArgumentNullException(nameof(requests)); - private readonly IObservable> _source; + private readonly IObservable> _source = source ?? throw new ArgumentNullException(nameof(source)); - public Virtualiser(IObservable> source, IObservable requests) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _requests = requests ?? throw new ArgumentNullException(nameof(requests)); - } - - public IObservable> Run() - { - return Observable.Create>( + public IObservable> Run() => Observable.Create>( observer => { var locker = new object(); @@ -45,7 +37,6 @@ public IObservable> Run() .Select(x => x!) .Select(changes => new VirtualChangeSet(changes, new VirtualResponse(virtualised.Count, parameters.StartIndex, all.Count))).SubscribeSafe(observer); }); - } private static IChangeSet? CheckParamsAndVirtualise(IList all, ChangeAwareList virtualised, IVirtualRequest? request) { diff --git a/src/DynamicData/List/ItemChange.cs b/src/DynamicData/List/ItemChange.cs index 5cafd029d..207e6b44a 100644 --- a/src/DynamicData/List/ItemChange.cs +++ b/src/DynamicData/List/ItemChange.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - using DynamicData.Kernel; // ReSharper disable once CheckNamespace @@ -106,10 +103,7 @@ public ItemChange(ListChangeReason reason, T current, int currentIndex) /// /// The other. /// If the value is equal. - public bool Equals(ItemChange other) - { - return EqualityComparer.Default.Equals(Current, other.Current) && CurrentIndex == other.CurrentIndex && Previous.Equals(other.Previous) && PreviousIndex == other.PreviousIndex; - } + public bool Equals(ItemChange other) => EqualityComparer.Default.Equals(Current, other.Current) && CurrentIndex == other.CurrentIndex && Previous.Equals(other.Previous) && PreviousIndex == other.PreviousIndex; /// /// Determines whether the specified , is equal to this instance. @@ -152,8 +146,5 @@ public override int GetHashCode() /// /// A that represents this instance. /// - public override string ToString() - { - return $"Current: {Current}, Previous: {Previous}"; - } + public override string ToString() => $"Current: {Current}, Previous: {Previous}"; } diff --git a/src/DynamicData/List/Linq/AddKeyEnumerator.cs b/src/DynamicData/List/Linq/AddKeyEnumerator.cs index 049225c90..d51883eba 100644 --- a/src/DynamicData/List/Linq/AddKeyEnumerator.cs +++ b/src/DynamicData/List/Linq/AddKeyEnumerator.cs @@ -2,25 +2,17 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Collections; -using System.Collections.Generic; namespace DynamicData.List.Linq; -internal class AddKeyEnumerator : IEnumerable> +internal class AddKeyEnumerator(IChangeSet source, Func keySelector) : IEnumerable> where TObject : notnull where TKey : notnull { - private readonly Func _keySelector; + private readonly Func _keySelector = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); - private readonly IChangeSet _source; - - public AddKeyEnumerator(IChangeSet source, Func keySelector) - { - _source = source ?? throw new ArgumentNullException(nameof(source)); - _keySelector = keySelector ?? throw new ArgumentNullException(nameof(keySelector)); - } + private readonly IChangeSet _source = source ?? throw new ArgumentNullException(nameof(source)); /// /// Returns an enumerator that iterates through the collection. @@ -111,8 +103,5 @@ public IEnumerator> GetEnumerator() } } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/src/DynamicData/List/Linq/ItemChangeEnumerator.cs b/src/DynamicData/List/Linq/ItemChangeEnumerator.cs index 9b068e834..c7a01253e 100644 --- a/src/DynamicData/List/Linq/ItemChangeEnumerator.cs +++ b/src/DynamicData/List/Linq/ItemChangeEnumerator.cs @@ -3,25 +3,17 @@ // See the LICENSE file in the project root for full license information. using System.Collections; -using System.Collections.Generic; namespace DynamicData.List.Linq; -internal class ItemChangeEnumerator : IEnumerable> +internal class ItemChangeEnumerator(IChangeSet changeSet) : IEnumerable> where T : notnull { - private readonly IChangeSet _changeSet; - - public ItemChangeEnumerator(IChangeSet changeSet) - { - _changeSet = changeSet; - } - public IEnumerator> GetEnumerator() { var lastKnownIndex = 0; - foreach (var change in _changeSet) + foreach (var change in changeSet) { if (change.Type == ChangeType.Item) { @@ -59,8 +51,5 @@ public IEnumerator> GetEnumerator() } } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/src/DynamicData/List/Linq/Reverser.cs b/src/DynamicData/List/Linq/Reverser.cs index db9074503..9e91ba5a5 100644 --- a/src/DynamicData/List/Linq/Reverser.cs +++ b/src/DynamicData/List/Linq/Reverser.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Generic; -using System.Linq; - namespace DynamicData.List.Linq; internal class Reverser diff --git a/src/DynamicData/List/Linq/UnifiedChangeEnumerator.cs b/src/DynamicData/List/Linq/UnifiedChangeEnumerator.cs index d85fd0ef3..3f511f484 100644 --- a/src/DynamicData/List/Linq/UnifiedChangeEnumerator.cs +++ b/src/DynamicData/List/Linq/UnifiedChangeEnumerator.cs @@ -3,25 +3,17 @@ // See the LICENSE file in the project root for full license information. using System.Collections; -using System.Collections.Generic; using DynamicData.List.Internal; namespace DynamicData.List.Linq; -internal class UnifiedChangeEnumerator : IEnumerable> +internal class UnifiedChangeEnumerator(IChangeSet changeSet) : IEnumerable> where T : notnull { - private readonly IChangeSet _changeSet; - - public UnifiedChangeEnumerator(IChangeSet changeSet) - { - _changeSet = changeSet; - } - public IEnumerator> GetEnumerator() { - foreach (var change in _changeSet) + foreach (var change in changeSet) { if (change.Type == ChangeType.Item) { @@ -53,8 +45,5 @@ public IEnumerator> GetEnumerator() } } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/src/DynamicData/List/Linq/WithoutIndexEnumerator.cs b/src/DynamicData/List/Linq/WithoutIndexEnumerator.cs index f5b0086d6..31d7505e0 100644 --- a/src/DynamicData/List/Linq/WithoutIndexEnumerator.cs +++ b/src/DynamicData/List/Linq/WithoutIndexEnumerator.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for full license information. using System.Collections; -using System.Collections.Generic; namespace DynamicData.List.Linq; @@ -12,19 +11,12 @@ namespace DynamicData.List.Linq; /// Otherwise these operators could break subsequent operators when the subsequent operator relies on the index. /// /// The type of the item. -internal class WithoutIndexEnumerator : IEnumerable> +internal class WithoutIndexEnumerator(IEnumerable> changeSet) : IEnumerable> where T : notnull { - private readonly IEnumerable> _changeSet; - - public WithoutIndexEnumerator(IEnumerable> changeSet) - { - _changeSet = changeSet; - } - public IEnumerator> GetEnumerator() { - foreach (var change in _changeSet) + foreach (var change in changeSet) { if (change.Reason == ListChangeReason.Moved) { @@ -43,8 +35,5 @@ public IEnumerator> GetEnumerator() } } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/src/DynamicData/List/ListEx.cs b/src/DynamicData/List/ListEx.cs index 9231d5e6a..ca1db7dfa 100644 --- a/src/DynamicData/List/ListEx.cs +++ b/src/DynamicData/List/ListEx.cs @@ -2,10 +2,7 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; using DynamicData.Kernel; @@ -170,10 +167,7 @@ public static void AddRange(this IList source, IEnumerable items, int i /// The list to be searched. /// The value to search for. /// The index of the specified value in the specified array, if value is found; otherwise, a negative number. - public static int BinarySearch(this IList list, TItem value) - { - return BinarySearch(list, value, Comparer.Default); - } + public static int BinarySearch(this IList list, TItem value) => BinarySearch(list, value, Comparer.Default); /// /// Performs a binary search on the specified collection. @@ -307,10 +301,7 @@ public static void Clone(this IList source, IEnumerable> changes /// The source enumerable. /// The item to get the index of. /// The index. - public static int IndexOf(this IEnumerable source, T item) - { - return IndexOf(source, item, EqualityComparer.Default); - } + public static int IndexOf(this IEnumerable source, T item) => IndexOf(source, item, EqualityComparer.Default); /// /// Finds the index of the current item using the specified equality comparer. diff --git a/src/DynamicData/List/ObservableListEx.cs b/src/DynamicData/List/ObservableListEx.cs index 67520adae..aa2301329 100644 --- a/src/DynamicData/List/ObservableListEx.cs +++ b/src/DynamicData/List/ObservableListEx.cs @@ -99,10 +99,7 @@ public static IObservable> AddKey(this /// The others. /// An observable which emits the change set. public static IObservable> And(this IObservable> source, params IObservable>[] others) - where T : notnull - { - return source.Combine(CombineOperator.And, others); - } + where T : notnull => source.Combine(CombineOperator.And, others); /// /// Apply a logical And operator between the collections. @@ -112,10 +109,7 @@ public static IObservable> And(this IObservable> /// The sources. /// An observable which emits the change set. public static IObservable> And(this ICollection>> sources) - where T : notnull - { - return sources.Combine(CombineOperator.And); - } + where T : notnull => sources.Combine(CombineOperator.And); /// /// Dynamically apply a logical And operator between the items in the outer observable list. @@ -125,10 +119,7 @@ public static IObservable> And(this ICollectionThe source. /// An observable which emits the change set. public static IObservable> And(this IObservableList>> sources) - where T : notnull - { - return sources.Combine(CombineOperator.And); - } + where T : notnull => sources.Combine(CombineOperator.And); /// /// Dynamically apply a logical And operator between the items in the outer observable list. @@ -138,10 +129,7 @@ public static IObservable> And(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> And(this IObservableList> sources) - where T : notnull - { - return sources.Combine(CombineOperator.And); - } + where T : notnull => sources.Combine(CombineOperator.And); /// /// Dynamically apply a logical And operator between the items in the outer observable list. @@ -151,10 +139,7 @@ public static IObservable> And(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> And(this IObservableList> sources) - where T : notnull - { - return sources.Combine(CombineOperator.And); - } + where T : notnull => sources.Combine(CombineOperator.And); /// /// Converts the source list to an read only observable list. @@ -384,10 +369,7 @@ public static IObservable> Bind(this IObservable> /// An observable which emits the change set. /// source. public static IObservable> BufferIf(this IObservable> source, IObservable pauseIfTrueSelector, IScheduler? scheduler = null) - where T : notnull - { - return BufferIf(source, pauseIfTrueSelector, false, scheduler); - } + where T : notnull => BufferIf(source, pauseIfTrueSelector, false, scheduler); /// /// Batches the underlying updates if a pause signal (i.e when the buffer selector return true) has been received. @@ -428,10 +410,7 @@ public static IObservable> BufferIf(this IObservableAn observable which emits the change set. /// source. public static IObservable> BufferIf(this IObservable> source, IObservable pauseIfTrueSelector, TimeSpan? timeOut, IScheduler? scheduler = null) - where T : notnull - { - return BufferIf(source, pauseIfTrueSelector, false, timeOut, scheduler); - } + where T : notnull => BufferIf(source, pauseIfTrueSelector, false, timeOut, scheduler); /// /// Batches the underlying updates if a pause signal (i.e when the buffer selector return true) has been received. @@ -470,16 +449,13 @@ public static IObservable> BufferIf(this IObservableThe scheduler to buffer on. /// An observable which emits the change set. public static IObservable> BufferInitial(this IObservable> source, TimeSpan initialBuffer, IScheduler? scheduler = null) - where TObject : notnull - { - return source.DeferUntilLoaded().Publish( + where TObject : notnull => source.DeferUntilLoaded().Publish( shared => { var initial = shared.Buffer(initialBuffer, scheduler ?? Scheduler.Default).FlattenBufferResult().Take(1); return initial.Concat(shared); }); - } /// /// Cast the changes to another form. @@ -532,10 +508,7 @@ public static IObservable> Cast( /// The source. /// An observable which emits the change set. public static IObservable> CastToObject(this IObservable> source) - where T : class - { - return source.Select(changes => changes.Transform(t => (object)t)); - } + where T : class => source.Select(changes => changes.Transform(t => (object)t)); /// /// Clones the target list as a side effect of the stream. @@ -629,15 +602,12 @@ public static IObservable> DeferUntilLoaded(this IObservableLis /// A continuation of the original stream. /// source. public static IObservable> DisposeMany(this IObservable> source) - where T : notnull - { - return source.OnItemRemoved( + where T : notnull => source.OnItemRemoved( t => { var d = t as IDisposable; d?.Dispose(); }); - } /// /// Selects distinct values from the source, using the specified value selector. @@ -678,10 +648,7 @@ public static IObservable> DistinctValues(th /// The others. /// An observable which emits the change set. public static IObservable> Except(this IObservable> source, params IObservable>[] others) - where T : notnull - { - return source.Combine(CombineOperator.Except, others); - } + where T : notnull => source.Combine(CombineOperator.Except, others); /// /// Apply a logical Except operator between the collections. @@ -691,10 +658,7 @@ public static IObservable> Except(this IObservableThe sources. /// An observable which emits the change set. public static IObservable> Except(this ICollection>> sources) - where T : notnull - { - return sources.Combine(CombineOperator.Except); - } + where T : notnull => sources.Combine(CombineOperator.Except); /// /// Dynamically apply a logical Except operator. Items from the first observable list are included when an equivalent item does not exist in the other sources. @@ -703,10 +667,7 @@ public static IObservable> Except(this ICollectionThe source. /// An observable which emits the change set. public static IObservable> Except(this IObservableList>> sources) - where T : notnull - { - return sources.Combine(CombineOperator.Except); - } + where T : notnull => sources.Combine(CombineOperator.Except); /// /// Dynamically apply a logical Except operator. Items from the first observable list are included when an equivalent item does not exist in the other sources. @@ -715,10 +676,7 @@ public static IObservable> Except(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> Except(this IObservableList> sources) - where T : notnull - { - return sources.Combine(CombineOperator.Except); - } + where T : notnull => sources.Combine(CombineOperator.Except); /// /// Dynamically apply a logical Except operator. Items from the first observable list are included when an equivalent item does not exist in the other sources. @@ -727,10 +685,7 @@ public static IObservable> Except(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> Except(this IObservableList> sources) - where T : notnull - { - return sources.Combine(CombineOperator.Except); - } + where T : notnull => sources.Combine(CombineOperator.Except); /// /// Removes items from the cache according to the value specified by the time selector function. @@ -741,10 +696,7 @@ public static IObservable> Except(this IObservableListThe scheduler. /// An observable which emits the enumerable of items. public static IObservable> ExpireAfter(this ISourceList source, Func timeSelector, IScheduler? scheduler = null) - where T : notnull - { - return source.ExpireAfter(timeSelector, null, scheduler); - } + where T : notnull => source.ExpireAfter(timeSelector, null, scheduler); /// /// Removes items from the cache according to the value specified by the time selector function. @@ -889,10 +841,7 @@ public static IObservable> FilterOnPropertyThe source. /// An observable which emits the change set. public static IObservable> FlattenBufferResult(this IObservable>> source) - where T : notnull - { - return source.Where(x => x.Count != 0).Select(updates => new ChangeSet(updates.SelectMany(u => u))); - } + where T : notnull => source.Where(x => x.Count != 0).Select(updates => new ChangeSet(updates.SelectMany(u => u))); /// /// Provides a call back for each item change. @@ -1230,10 +1179,7 @@ public static IObservable> OnItemRemoved(this IObservableThe source. /// An observable which emits the change set. public static IObservable> Or(this ICollection>> sources) - where T : notnull - { - return sources.Combine(CombineOperator.Or); - } + where T : notnull => sources.Combine(CombineOperator.Or); /// /// Apply a logical Or operator between the collections. @@ -1244,10 +1190,7 @@ public static IObservable> Or(this ICollectionThe others. /// An observable which emits the change set. public static IObservable> Or(this IObservable> source, params IObservable>[] others) - where T : notnull - { - return source.Combine(CombineOperator.Or, others); - } + where T : notnull => source.Combine(CombineOperator.Or, others); /// /// Dynamically apply a logical Or operator between the items in the outer observable list. @@ -1257,10 +1200,7 @@ public static IObservable> Or(this IObservable> s /// The source. /// An observable which emits the change set. public static IObservable> Or(this IObservableList>> sources) - where T : notnull - { - return sources.Combine(CombineOperator.Or); - } + where T : notnull => sources.Combine(CombineOperator.Or); /// /// Dynamically apply a logical Or operator between the items in the outer observable list. @@ -1270,10 +1210,7 @@ public static IObservable> Or(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> Or(this IObservableList> sources) - where T : notnull - { - return sources.Combine(CombineOperator.Or); - } + where T : notnull => sources.Combine(CombineOperator.Or); /// /// Dynamically apply a logical Or operator between the items in the outer observable list. @@ -1283,10 +1220,7 @@ public static IObservable> Or(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> Or(this IObservableList> sources) - where T : notnull - { - return sources.Combine(CombineOperator.Or); - } + where T : notnull => sources.Combine(CombineOperator.Or); /// /// Applies paging to the data source. @@ -1529,10 +1463,7 @@ public static IObservable> Sort(this IObservable> /// The source observable of change set values. /// An observable which emits a change set. public static IObservable> StartWithEmpty(this IObservable> source) - where T : notnull - { - return source.StartWith(ChangeSet.Empty); - } + where T : notnull => source.StartWith(ChangeSet.Empty); /// /// Subscribes to each item when it is added to the stream and unsubscribes when it is removed. All items will be unsubscribed when the stream is disposed. @@ -1637,10 +1568,7 @@ public static IObservable> Switch(this IObservableThe source. /// An observable which emits the read only collection. public static IObservable> ToCollection(this IObservable> source) - where TObject : notnull - { - return source.QueryWhenChanged(items => items); - } + where TObject : notnull => source.QueryWhenChanged(items => items); /// /// Converts the observable to an observable change set. @@ -1751,10 +1679,7 @@ public static IObservable> ToObservableChangeSet(this IObservab /// or /// keySelector. public static IObservable> ToObservableChangeSet(this IObservable> source, IScheduler? scheduler = null) - where T : notnull - { - return ToObservableChangeSet(source, null, -1, scheduler); - } + where T : notnull => ToObservableChangeSet(source, null, -1, scheduler); /// /// Converts the observable to an observable change set, allowing size and time limit to be specified. @@ -1769,10 +1694,7 @@ public static IObservable> ToObservableChangeSet(this IObservab /// or /// keySelector. public static IObservable> ToObservableChangeSet(this IObservable> source, int limitSizeTo, IScheduler? scheduler = null) - where T : notnull - { - return ToObservableChangeSet(source, null, limitSizeTo, scheduler); - } + where T : notnull => ToObservableChangeSet(source, null, limitSizeTo, scheduler); /// /// Converts the observable to an observable change set, allowing size to be specified. @@ -1787,10 +1709,7 @@ public static IObservable> ToObservableChangeSet(this IObservab /// or /// keySelector. public static IObservable> ToObservableChangeSet(this IObservable> source, Func expireAfter, IScheduler? scheduler = null) - where T : notnull - { - return ToObservableChangeSet(source, expireAfter, 0, scheduler); - } + where T : notnull => ToObservableChangeSet(source, expireAfter, 0, scheduler); /// /// Converts the observable to an observable change set, allowing size and time limit to be specified. @@ -1849,10 +1768,7 @@ public static IObservable> Top(this IObservable> /// The sort order. Defaults to ascending. /// An observable which emits the read only collection. public static IObservable> ToSortedCollection(this IObservable> source, Func sort, SortDirection sortOrder = SortDirection.Ascending) - where TObject : notnull - { - return source.QueryWhenChanged(query => sortOrder == SortDirection.Ascending ? new ReadOnlyCollectionLight(query.OrderBy(sort)) : new ReadOnlyCollectionLight(query.OrderByDescending(sort))); - } + where TObject : notnull => source.QueryWhenChanged(query => sortOrder == SortDirection.Ascending ? new ReadOnlyCollectionLight(query.OrderBy(sort)) : new ReadOnlyCollectionLight(query.OrderByDescending(sort))); /// /// Converts the change set into a fully formed sorted collection. Each change in the source results in a new sorted collection. @@ -1862,16 +1778,13 @@ public static IObservable> ToSortedCollectionThe sort comparer. /// An observable which emits the read only collection. public static IObservable> ToSortedCollection(this IObservable> source, IComparer comparer) - where TObject : notnull - { - return source.QueryWhenChanged( + where TObject : notnull => source.QueryWhenChanged( query => { var items = query.AsList(); items.Sort(comparer); return new ReadOnlyCollectionLight(items); }); - } /// /// Projects each update item to a new form using the specified transform function. @@ -2175,10 +2088,7 @@ public static IObservable> TransformManyAn observable which emits the change set. public static IObservable> TransformMany(this IObservable> source, Func> manySelector, IEqualityComparer? equalityComparer = null) where TDestination : notnull - where TSource : notnull - { - return new TransformMany(source, manySelector, equalityComparer).Run(); - } + where TSource : notnull => new TransformMany(source, manySelector, equalityComparer).Run(); /// /// Flatten the nested observable collection, and observe subsequently observable collection changes. @@ -2191,10 +2101,7 @@ public static IObservable> TransformManyAn observable which emits the change set. public static IObservable> TransformMany(this IObservable> source, Func> manySelector, IEqualityComparer? equalityComparer = null) where TDestination : notnull - where TSource : notnull - { - return new TransformMany(source, manySelector, equalityComparer).Run(); - } + where TSource : notnull => new TransformMany(source, manySelector, equalityComparer).Run(); /// /// Flatten the nested observable list, and observe subsequent observable collection changes. @@ -2207,10 +2114,7 @@ public static IObservable> TransformManyAn observable which emits the change set. public static IObservable> TransformMany(this IObservable> source, Func> manySelector, IEqualityComparer? equalityComparer = null) where TDestination : notnull - where TSource : notnull - { - return new TransformMany(source, manySelector, equalityComparer).Run(); - } + where TSource : notnull => new TransformMany(source, manySelector, equalityComparer).Run(); /// /// Virtualises the source using parameters provided via the requests observable. @@ -2374,10 +2278,7 @@ public static IObservable> WhereReasonsAreNot(this IObservable< /// The others. /// An observable which emits the change set. public static IObservable> Xor(this IObservable> source, params IObservable>[] others) - where T : notnull - { - return source.Combine(CombineOperator.Xor, others); - } + where T : notnull => source.Combine(CombineOperator.Xor, others); /// /// Apply a logical Xor operator between the collections. @@ -2387,10 +2288,7 @@ public static IObservable> Xor(this IObservable> /// The sources. /// An observable which emits the change set. public static IObservable> Xor(this ICollection>> sources) - where T : notnull - { - return sources.Combine(CombineOperator.Xor); - } + where T : notnull => sources.Combine(CombineOperator.Xor); /// /// Dynamically apply a logical Xor operator between the items in the outer observable list. @@ -2400,10 +2298,7 @@ public static IObservable> Xor(this ICollectionThe source. /// An observable which emits the change set. public static IObservable> Xor(this IObservableList>> sources) - where T : notnull - { - return sources.Combine(CombineOperator.Xor); - } + where T : notnull => sources.Combine(CombineOperator.Xor); /// /// Dynamically apply a logical Xor operator between the items in the outer observable list. @@ -2413,10 +2308,7 @@ public static IObservable> Xor(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> Xor(this IObservableList> sources) - where T : notnull - { - return sources.Combine(CombineOperator.Xor); - } + where T : notnull => sources.Combine(CombineOperator.Xor); /// /// Dynamically apply a logical Xor operator between the items in the outer observable list. @@ -2426,10 +2318,7 @@ public static IObservable> Xor(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> Xor(this IObservableList> sources) - where T : notnull - { - return sources.Combine(CombineOperator.Xor); - } + where T : notnull => sources.Combine(CombineOperator.Xor); private static IObservable> Combine(this ICollection>> sources, CombineOperator type) where T : notnull diff --git a/src/DynamicData/List/PageChangeSet.cs b/src/DynamicData/List/PageChangeSet.cs index 8690ee1c3..2623fb860 100644 --- a/src/DynamicData/List/PageChangeSet.cs +++ b/src/DynamicData/List/PageChangeSet.cs @@ -2,32 +2,23 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Collections; -using System.Collections.Generic; using DynamicData.Operators; // ReSharper disable once CheckNamespace namespace DynamicData; -internal sealed class PageChangeSet : IPageChangeSet +internal sealed class PageChangeSet(IChangeSet virtualChangeSet, IPageResponse response) : IPageChangeSet where T : notnull { - private readonly IChangeSet _virtualChangeSet; - - public PageChangeSet(IChangeSet virtualChangeSet, IPageResponse response) - { - _virtualChangeSet = virtualChangeSet ?? throw new ArgumentNullException(nameof(virtualChangeSet)); - - Response = response ?? throw new ArgumentNullException(nameof(response)); - } + private readonly IChangeSet _virtualChangeSet = virtualChangeSet ?? throw new ArgumentNullException(nameof(virtualChangeSet)); public int Count => _virtualChangeSet.Count; public int Refreshes => _virtualChangeSet.Refreshes; - public IPageResponse Response { get; } + public IPageResponse Response { get; } = response ?? throw new ArgumentNullException(nameof(response)); int IChangeSet.Adds => _virtualChangeSet.Adds; @@ -45,13 +36,7 @@ int IChangeSet.Capacity int IChangeSet.TotalChanges => _virtualChangeSet.TotalChanges; - public IEnumerator> GetEnumerator() - { - return _virtualChangeSet.GetEnumerator(); - } + public IEnumerator> GetEnumerator() => _virtualChangeSet.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/src/DynamicData/List/RangeChange.cs b/src/DynamicData/List/RangeChange.cs index 4d3a9737d..8ab9c33f1 100644 --- a/src/DynamicData/List/RangeChange.cs +++ b/src/DynamicData/List/RangeChange.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for full license information. using System.Collections; -using System.Collections.Generic; using DynamicData.Kernel; diff --git a/src/DynamicData/List/SortException.cs b/src/DynamicData/List/SortException.cs index 74c565bb8..7149a124e 100644 --- a/src/DynamicData/List/SortException.cs +++ b/src/DynamicData/List/SortException.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - // ReSharper disable once CheckNamespace namespace DynamicData; @@ -38,14 +36,4 @@ public SortException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the class. - /// - /// The serialization info. - /// The serialization context. - protected SortException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) - : base(serializationInfo, streamingContext) - { - } } diff --git a/src/DynamicData/List/SourceList.cs b/src/DynamicData/List/SourceList.cs index ea7c3375b..8be553eb7 100644 --- a/src/DynamicData/List/SourceList.cs +++ b/src/DynamicData/List/SourceList.cs @@ -186,10 +186,7 @@ private void InvokeNextPreview(IChangeSet changes) } } - private IDisposable LoadFromSource(IObservable> source) - { - return source.Synchronize(_locker).Finally(OnCompleted).Select(_readerWriter.Write).Subscribe(InvokeNext, OnError, OnCompleted); - } + private IDisposable LoadFromSource(IObservable> source) => source.Synchronize(_locker).Finally(OnCompleted).Select(_readerWriter.Write).Subscribe(InvokeNext, OnError, OnCompleted); private void OnCompleted() { diff --git a/src/DynamicData/List/SourceListEditConvenienceEx.cs b/src/DynamicData/List/SourceListEditConvenienceEx.cs index 142994280..1784431da 100644 --- a/src/DynamicData/List/SourceListEditConvenienceEx.cs +++ b/src/DynamicData/List/SourceListEditConvenienceEx.cs @@ -2,9 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; - using DynamicData.List.Internal; // ReSharper disable once CheckNamespace diff --git a/src/DynamicData/List/SourceListEx.cs b/src/DynamicData/List/SourceListEx.cs index cbc2be9d9..996ac5aff 100644 --- a/src/DynamicData/List/SourceListEx.cs +++ b/src/DynamicData/List/SourceListEx.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - // ReSharper disable once CheckNamespace namespace DynamicData; diff --git a/src/DynamicData/List/Tests/ChangeSetAggregator.cs b/src/DynamicData/List/Tests/ChangeSetAggregator.cs index 34c5e4262..b3acc874b 100644 --- a/src/DynamicData/List/Tests/ChangeSetAggregator.cs +++ b/src/DynamicData/List/Tests/ChangeSetAggregator.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Reactive.Disposables; using System.Reactive.Linq; diff --git a/src/DynamicData/List/Tests/ListTextEx.cs b/src/DynamicData/List/Tests/ListTextEx.cs index a3b202fa4..7bae5af74 100644 --- a/src/DynamicData/List/Tests/ListTextEx.cs +++ b/src/DynamicData/List/Tests/ListTextEx.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - // ReSharper disable once CheckNamespace namespace DynamicData.Tests; @@ -19,8 +17,5 @@ public static class ListTextEx /// The type of the object. /// The change set aggregator. public static ChangeSetAggregator AsAggregator(this IObservable> source) - where T : notnull - { - return new(source); - } + where T : notnull => new(source); } diff --git a/src/DynamicData/List/UnspecifiedIndexException.cs b/src/DynamicData/List/UnspecifiedIndexException.cs index 69916e144..c2b8f468d 100644 --- a/src/DynamicData/List/UnspecifiedIndexException.cs +++ b/src/DynamicData/List/UnspecifiedIndexException.cs @@ -2,8 +2,6 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; - // ReSharper disable once CheckNamespace namespace DynamicData; @@ -38,14 +36,4 @@ public UnspecifiedIndexException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the class. - /// - /// The serialization info. - /// The serialization context. - protected UnspecifiedIndexException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) - : base(serializationInfo, streamingContext) - { - } } diff --git a/src/DynamicData/List/VirtualChangeSet.cs b/src/DynamicData/List/VirtualChangeSet.cs index 0cc0d08aa..f5b733895 100644 --- a/src/DynamicData/List/VirtualChangeSet.cs +++ b/src/DynamicData/List/VirtualChangeSet.cs @@ -2,28 +2,19 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Collections; -using System.Collections.Generic; // ReSharper disable once CheckNamespace namespace DynamicData; -internal class VirtualChangeSet : IVirtualChangeSet +internal class VirtualChangeSet(IChangeSet virtualChangeSet, IVirtualResponse response) : IVirtualChangeSet where T : notnull { - private readonly IChangeSet _virtualChangeSet; - - public VirtualChangeSet(IChangeSet virtualChangeSet, IVirtualResponse response) - { - _virtualChangeSet = virtualChangeSet ?? throw new ArgumentNullException(nameof(virtualChangeSet)); - - Response = response ?? throw new ArgumentNullException(nameof(response)); - } + private readonly IChangeSet _virtualChangeSet = virtualChangeSet ?? throw new ArgumentNullException(nameof(virtualChangeSet)); public int Refreshes => _virtualChangeSet.Refreshes; - public IVirtualResponse Response { get; } + public IVirtualResponse Response { get; } = response ?? throw new ArgumentNullException(nameof(response)); int IChangeSet.Adds => _virtualChangeSet.Adds; @@ -43,13 +34,7 @@ int IChangeSet.Capacity int IChangeSet.TotalChanges => _virtualChangeSet.TotalChanges; - public IEnumerator> GetEnumerator() - { - return _virtualChangeSet.GetEnumerator(); - } + public IEnumerator> GetEnumerator() => _virtualChangeSet.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/src/DynamicData/ObservableChangeSet.cs b/src/DynamicData/ObservableChangeSet.cs index 1ead33041..8147e38ab 100644 --- a/src/DynamicData/ObservableChangeSet.cs +++ b/src/DynamicData/ObservableChangeSet.cs @@ -2,11 +2,8 @@ // Roland Pheasant licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System; using System.Reactive.Disposables; using System.Reactive.Linq; -using System.Threading; -using System.Threading.Tasks; namespace DynamicData; diff --git a/src/DynamicData/Platforms/net45/ParallelisationOptions.cs b/src/DynamicData/Platforms/net45/ParallelisationOptions.cs index b91053a04..09d5ef8ec 100644 --- a/src/DynamicData/Platforms/net45/ParallelisationOptions.cs +++ b/src/DynamicData/Platforms/net45/ParallelisationOptions.cs @@ -9,7 +9,13 @@ namespace DynamicData.PLinq /// /// Options to specify parallelisation of stream operations. Only applicable for .Net4 and .Net45 builds. /// - public class ParallelisationOptions + /// + /// Initializes a new instance of the class. + /// + /// The type of parallel operation. + /// The threshold before making the operation parallel. + /// The maximum degrees of parallelism. + public class ParallelisationOptions(ParallelType type = ParallelType.None, int threshold = 0, int maxDegreeOfParallelisation = 0) { /// /// The default parallelisation options. @@ -21,34 +27,21 @@ public class ParallelisationOptions /// public static readonly ParallelisationOptions None = new(); - /// - /// Initializes a new instance of the class. - /// - /// The type of parallel operation. - /// The threshold before making the operation parallel. - /// The maximum degrees of parallelism. - public ParallelisationOptions(ParallelType type = ParallelType.None, int threshold = 0, int maxDegreeOfParallelisation = 0) - { - Type = type; - Threshold = threshold; - MaxDegreeOfParallelisation = maxDegreeOfParallelisation; - } - /// /// Gets the maximum degree of parallelisation. /// - public int MaxDegreeOfParallelisation { get; } + public int MaxDegreeOfParallelisation { get; } = maxDegreeOfParallelisation; /// /// Gets the threshold. /// - public int Threshold { get; } + public int Threshold { get; } = threshold; /// /// Gets the type. /// - public ParallelType Type { get; } + public ParallelType Type { get; } = type; } } -#endif \ No newline at end of file +#endif diff --git a/src/global.json b/src/global.json index 781c465e6..d9af7e6d6 100644 --- a/src/global.json +++ b/src/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0", + "version": "8.0.10", "rollForward": "latestMinor", "allowPrerelease": true }, diff --git a/version.json b/version.json index 192f83013..ed626a73f 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "version": "8.1", + "version": "8.2", "publicReleaseRefSpec": [ "^refs/heads/main$", // we release out of master "^refs/heads/preview/.*", // we release previews