| | 1 | | using Fluorite.Strainer.Models.Sorting; |
| | 2 | | using System.Diagnostics; |
| | 3 | | using System.Reflection; |
| | 4 | |
|
| | 5 | | namespace Fluorite.Strainer.Models.Metadata; |
| | 6 | |
|
| | 7 | | /// <summary> |
| | 8 | | /// Represents default property metadata model. |
| | 9 | | /// </summary> |
| | 10 | | [DebuggerDisplay("\\{" + nameof(Name) + " = " + "{" + nameof(Name) + "} \\}")] |
| | 11 | | public class PropertyMetadata : IPropertyMetadata |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// Initializes a new instance of the <see cref="PropertyMetadata"/> class. |
| | 15 | | /// </summary> |
| | 16 | | /// <param name="name"> |
| | 17 | | /// The property name. |
| | 18 | | /// </param> |
| | 19 | | /// <param name="propertyInfo"> |
| | 20 | | /// The property info instance for the property. |
| | 21 | | /// </param> |
| 42 | 22 | | public PropertyMetadata(string name, PropertyInfo propertyInfo) |
| | 23 | | { |
| 42 | 24 | | Name = Guard.Against.NullOrWhiteSpace(name); |
| 42 | 25 | | PropertyInfo = Guard.Against.Null(propertyInfo); |
| 42 | 26 | | } |
| | 27 | |
|
| | 28 | | /// <summary> |
| | 29 | | /// Gets or sets the display name of the property. |
| | 30 | | /// </summary> |
| 64 | 31 | | public string? DisplayName { get; set; } |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// Gets or sets a value indicating whether related |
| | 35 | | /// property should be used as a default (fallback) property when |
| | 36 | | /// no sorting information was provided but sorting was still requested. |
| | 37 | | /// <para/> |
| | 38 | | /// Default sorting is not perfomed when sorting information is not |
| | 39 | | /// properly recognized. |
| | 40 | | /// </summary> |
| 83 | 41 | | public bool IsDefaultSorting { get; set; } |
| | 42 | |
|
| | 43 | | /// <summary> |
| | 44 | | /// Gets or sets default sorting way used when related property is marked |
| | 45 | | /// as a default sorting property. |
| | 46 | | /// </summary> |
| 54 | 47 | | public SortingWay? DefaultSortingWay { get; set; } |
| | 48 | |
|
| | 49 | | /// <summary> |
| | 50 | | /// Gets or sets a value indicating whether related |
| | 51 | | /// property is marked as filterable for Strainer. |
| | 52 | | /// </summary> |
| 54 | 53 | | public bool IsFilterable { get; set; } |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Gets or sets a value indicating whether related |
| | 57 | | /// property is marked as sortable for Strainer. |
| | 58 | | /// </summary> |
| 57 | 59 | | public bool IsSortable { get; set; } |
| | 60 | |
|
| | 61 | | /// <inheritdoc/> |
| 42 | 62 | | public string Name { get; } |
| | 63 | |
|
| | 64 | | /// <inheritdoc/> |
| 21 | 65 | | public PropertyInfo PropertyInfo { get; } |
| | 66 | | } |