< Summary

Information
Class: Fluorite.Strainer.Attributes.StrainerObjectAttribute
Assembly: Fluorite.Strainer
File(s): /builds/fluorite/strainer/src/Strainer/Attributes/StrainerObjectAttribute.cs
Line coverage
72%
Covered lines: 8
Uncovered lines: 3
Coverable lines: 11
Total lines: 81
Line coverage: 72.7%
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%
.ctor(...)100%210%
get_DefaultSortingPropertyName()100%11100%
get_DefaultSortingWay()100%11100%
get_IsFilterable()100%11100%
get_IsSortable()100%11100%
get_DefaultSortingPropertyInfo()100%11100%

File(s)

/builds/fluorite/strainer/src/Strainer/Attributes/StrainerObjectAttribute.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 class or struct as filterable and/or sortable, setting default
 9/// values for all its properties.
 10/// </summary>
 11[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false)]
 12public class StrainerObjectAttribute : Attribute, IObjectMetadata
 13{
 14    /// <summary>
 15    /// Initializes a new instance of the <see cref="StrainerObjectAttribute"/>
 16    /// class.
 17    /// </summary>
 18    /// <param name="defaultSortingPropertyName">
 19    /// Property name being default sorting property for marked object.
 20    /// </param>
 21    /// <exception cref="ArgumentNullException">
 22    /// <paramref name="defaultSortingPropertyName"/> is <see langword="null"/>.
 23    /// </exception>
 24    /// <exception cref="ArgumentException">
 25    /// <paramref name="defaultSortingPropertyName"/> is empty or contains only whitespace characters.
 26    /// </exception>
 1427    public StrainerObjectAttribute(string defaultSortingPropertyName)
 28    {
 1429        DefaultSortingPropertyName = Guard.Against.NullOrWhiteSpace(defaultSortingPropertyName);
 1430    }
 31
 32    /// <summary>
 33    /// Initializes a new instance of the <see cref="StrainerObjectAttribute"/>
 34    /// class.
 35    /// </summary>
 36    /// <param name="defaultSortingPropertyName">
 37    /// Property name being default sorting property for marked object.
 38    /// </param>
 39    /// <param name="defaultSortingWay">
 40    /// A default sorting way for marked object.
 41    /// </param>
 42    /// <exception cref="ArgumentException">
 43    /// <paramref name="defaultSortingPropertyName"/> is <see langword="null"/>,
 44    /// empty or contains only whitespace characters.
 45    /// </exception>
 046    public StrainerObjectAttribute(string defaultSortingPropertyName, SortingWay defaultSortingWay) : this(defaultSortin
 47    {
 048        DefaultSortingWay = defaultSortingWay;
 049    }
 50
 51    /// <inheritdoc/>
 952    public string DefaultSortingPropertyName { get; }
 53
 54    /// <summary>
 55    /// Gets default sorting way used when applying sorting using default sorting property.
 56    /// <para/>
 57    /// Defaults to <see langword="null"/>.
 58    /// </summary>
 259    public SortingWay? DefaultSortingWay { get; }
 60
 61    /// <summary>
 62    /// Gets or sets a value indicating whether marked
 63    /// object is marked as filterable.
 64    /// <para/>
 65    /// Defaults to <see langword="true"/>.
 66    /// </summary>
 2267    public bool IsFilterable { get; set; } = true;
 68
 69    /// <summary>
 70    /// Gets or sets a value indicating whether marked
 71    /// object is marked as filterable.
 72    /// <para/>
 73    /// Defaults to <see langword="true"/>.
 74    /// </summary>
 2375    public bool IsSortable { get; set; } = true;
 76
 77    /// <summary>
 78    /// Gets or sets the <see cref="PropertyInfo"/> for default sorting property.
 79    /// </summary>
 380    public PropertyInfo? DefaultSortingPropertyInfo { get; set; }
 81}