< Summary - SonghayCore

Information
Class: Songhay.Extensions.DisplayItemModelExtensions
Assembly: SonghayCore
File(s): /home/rasx/sourceRoot/SonghayCore/SonghayCore/Extensions/DisplayItemModelExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 37
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
HasTag(...)0%40%
ToMenuDisplayItemModel(...)100%10%
WithTag(...)0%20%

File(s)

/home/rasx/sourceRoot/SonghayCore/SonghayCore/Extensions/DisplayItemModelExtensions.cs

#LineLine coverage
 1namespace Songhay.Extensions;
 2
 3/// <summary>
 4/// Extensions of <see cref="DisplayItemModel"/>.
 5/// </summary>
 6public static class DisplayItemModelExtensions
 7{
 8    /// <summary>
 9    /// Returns <c>true</c> when the item has the <see cref="DisplayItemModel.Tag"/>
 10    /// based on the specified evaluator.
 11    /// </summary>
 12    /// <param name="data">The <see cref="DisplayItemModel"/>.</param>
 13    /// <param name="evaluator">The predicate for evaluating <see cref="DisplayItemModel.Tag"/>.</param>
 14    public static bool HasTag(this DisplayItemModel? data, Func<object?, bool>? evaluator) =>
 015        data != null && evaluator != null && evaluator.Invoke(data.Tag);
 16
 17    /// <summary>
 18    /// Converts the <see cref="DisplayItemModel"/> into a menu display item model.
 19    /// </summary>
 20    /// <param name="data">The <see cref="DisplayItemModel"/>.</param>
 21    public static MenuDisplayItemModel? ToMenuDisplayItemModel(this DisplayItemModel? data) =>
 022        data as MenuDisplayItemModel;
 23
 24    /// <summary>
 25    /// Fluently sets <see cref="DisplayItemModel.Tag"/>.
 26    /// </summary>
 27    /// <param name="data">The <see cref="DisplayItemModel"/>.</param>
 28    /// <param name="tag">The value of <see cref="DisplayItemModel.Tag"/>.</param>
 29    public static DisplayItemModel? WithTag(this DisplayItemModel? data, object tag)
 030    {
 031        if (data == null) return null;
 32
 033        data.Tag = tag;
 34
 035        return data;
 036    }
 37}