< Summary

Information
Class: Fluorite.Strainer.Attributes.StrainerPropertyAttribute
Assembly: Fluorite.Strainer
File(s): /builds/fluorite/strainer/src/Strainer/Attributes/StrainerPropertyAttribute.cs
Line coverage
88%
Covered lines: 8
Uncovered lines: 1
Coverable lines: 9
Total lines: 70
Line coverage: 88.8%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
get_DisplayName()100%11100%
get_IsDefaultSorting()100%11100%
get_DefaultSortingWay()100%210%
get_IsFilterable()100%11100%
get_IsSortable()100%11100%
get_Name()100%11100%
get_PropertyInfo()100%11100%

File(s)

/builds/fluorite/strainer/src/Strainer/Attributes/StrainerPropertyAttribute.cs

#LineLine coverage
 1using Fluorite.Strainer.Models.Metadata;
 2using Fluorite.Strainer.Models.Sorting;
 3using System.Reflection;
 4
 5namespace Fluorite.Strainer.Attributes;
 6
 7/// <summary>
 8/// Marks a property as filterable and/or sortable.
 9/// </summary>
 10[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
 11public class StrainerPropertyAttribute : Attribute, IPropertyMetadata
 12{
 13    /// <summary>
 14    /// Initializes a new instance of the <see cref="StrainerPropertyAttribute"/>
 15    /// class.
 16    /// </summary>
 2017    public StrainerPropertyAttribute()
 18    {
 2019    }
 20
 21    /// <summary>
 22    /// Gets or sets the display name for related property.
 23    /// </summary>
 2624    public string? DisplayName { get; set; }
 25
 26    /// <summary>
 27    /// Gets or sets a value indicating whether related
 28    /// property should be used as a default (fallback) property when
 29    /// no sorting information was provided but sorting was still requested.
 30    /// <para/>
 31    /// Default sorting is not perfomed when sorting information was not
 32    /// properly recognized.
 33    /// <para/>
 34    /// Defaults to <see langword="false"/>.
 35    /// </summary>
 436    public bool IsDefaultSorting { get; set; } = false;
 37
 38    /// <summary>
 39    /// Gets or sets default sorting way used when related property is marked
 40    /// as a default sorting property.
 41    /// <para/>
 42    /// Defaults to <see langword="null"/>.
 43    /// </summary>
 044    public SortingWay? DefaultSortingWay { get; set; } = null;
 45
 46    /// <summary>
 47    /// Gets or sets a value indicating whether related
 48    /// property is marked as filterable.
 49    /// <para/>
 50    /// Defaults to <see langword="true"/>.
 51    /// </summary>
 2652    public bool IsFilterable { get; set; } = true;
 53
 54    /// <summary>
 55    /// Gets or sets a value indicating whether related
 56    /// property is marked as sortable.
 57    /// <para/>
 58    /// Defaults to <see langword="true"/>.
 59    /// </summary>
 3060    public bool IsSortable { get; set; } = true;
 61
 62    /// <inheritdoc/>
 363    public string Name => PropertyInfo!.Name;
 64
 65    /// <summary>
 66    /// Gets or sets the <see cref="System.Reflection.PropertyInfo"/> for
 67    /// related property.
 68    /// </summary>
 1469    public PropertyInfo? PropertyInfo { get; set; }
 70}