< Summary

Information
Class: MyNet.Collections.ObservableRangeCollectionExtensions
Assembly: MyNet.Collections
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Collections/Extensions/ObservableRangeCollectionExtensions.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 50
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
SortBy(...)100%22100%
Synchronized(...)100%11100%
Dispatched(...)100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Collections/Extensions/ObservableRangeCollectionExtensions.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="ObservableRangeCollectionExtensions.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.ComponentModel;
 9
 10#pragma warning disable IDE0130 // Namespace does not match folder structure
 11namespace MyNet.Collections;
 12#pragma warning restore IDE0130 // Namespace does not match folder structure
 13
 14public static class ObservableRangeCollectionExtensions
 15{
 16    extension<T>(ObservableRangeCollection<T> collection)
 17    {
 18        /// <summary>
 19        /// Sorts the collection using an external sorting strategy.
 20        /// </summary>
 21        public void SortBy(Func<T, object> selector, ListSortDirection direction = ListSortDirection.Ascending, ICollect
 22        {
 1523            ArgumentNullException.ThrowIfNull(collection);
 1524            ArgumentNullException.ThrowIfNull(selector);
 25
 1526            var sorted = (sorter ?? DefaultCollectionSorter<T>.Default).Sort(collection, selector, direction);
 1527            collection.Load(sorted);
 1528        }
 29
 30        /// <summary>
 31        /// Wraps the collection in a synchronized adapter.
 32        /// </summary>
 33        public SynchronizedObservableCollection<T> Synchronized(ICollectionSynchronizer? synchronizer = null)
 34        {
 335            ArgumentNullException.ThrowIfNull(collection);
 336            return new(collection, synchronizer);
 37        }
 38
 39        /// <summary>
 40        /// Wraps an observable range collection so notifications are dispatched with the specified dispatcher.
 41        /// </summary>
 42        public DispatchedObservableCollection<T> Dispatched(ICollectionEventDispatcher dispatcher)
 43        {
 344            ArgumentNullException.ThrowIfNull(collection);
 345            ArgumentNullException.ThrowIfNull(dispatcher);
 346            return new(collection, dispatcher);
 47        }
 48    }
 49}
 50