< Summary

Information
Class: MyNet.Utilities.Execution.SubscriberLists
Assembly: MyNet.Utilities
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Utilities/Execution/SubscriberLists.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 34
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Add(...)50%22100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Utilities/Execution/SubscriberLists.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="SubscriberLists.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System.Collections.Generic;
 8
 9namespace MyNet.Utilities.Execution;
 10
 11/// <summary>
 12/// Helper for managing lists of items associated to subscribers (e.g. for tracking subscriptions of a subscriber to mul
 13/// </summary>
 14internal static class SubscriberLists
 15{
 16    /// <summary>
 17    /// Adds an item to the list associated to the specified subscriber in the dictionary, creating a new list if the su
 18    /// </summary>
 19    /// <param name="dictionary">The dictionary mapping subscribers to their lists of items.</param>
 20    /// <param name="subscriber">The subscriber for whom the item is being added.</param>
 21    /// <param name="item">The item to add to the subscriber's list.</param>
 22    /// <typeparam name="T">The type of items in the list.</typeparam>
 23    public static void Add<T>(Dictionary<object, List<T>> dictionary, object subscriber, T item)
 24    {
 1525        if (!dictionary.TryGetValue(subscriber, out var list))
 26        {
 1527            list = [];
 1528            dictionary[subscriber] = list;
 29        }
 30
 1531        list.Add(item);
 1532    }
 33}
 34