| | 1 | | using Fluorite.Strainer.Models.Filtering.Terms; |
| | 2 | | using System.Linq.Expressions; |
| | 3 | |
|
| | 4 | | namespace Fluorite.Strainer.Models.Filtering; |
| | 5 | |
|
| | 6 | | /// <summary> |
| | 7 | | /// Represents custom filter method. |
| | 8 | | /// </summary> |
| | 9 | | /// <typeparam name="T"> |
| | 10 | | /// The type of entity processed by the custom method. |
| | 11 | | /// </typeparam> |
| | 12 | | public class CustomFilterMethod<T> : CustomFilterMethod, ICustomFilterMethod<T> |
| | 13 | | { |
| | 14 | | /// <summary> |
| | 15 | | /// Initializes a new instance of the <see cref="CustomFilterMethod{TEntity}"/> |
| | 16 | | /// class. |
| | 17 | | /// </summary> |
| | 18 | | /// <param name="name"> |
| | 19 | | /// The custom method name. |
| | 20 | | /// </param> |
| | 21 | | /// <param name="expression"> |
| | 22 | | /// The expression used for custom filtering. |
| | 23 | | /// </param> |
| 4 | 24 | | public CustomFilterMethod(string name, Expression<Func<T, bool>> expression) : base(name) |
| | 25 | | { |
| 4 | 26 | | Expression = Guard.Against.Null(expression); |
| 4 | 27 | | } |
| | 28 | |
|
| | 29 | | /// <summary> |
| | 30 | | /// Initializes a new instance of the <see cref="CustomFilterMethod{TEntity}"/> |
| | 31 | | /// class. |
| | 32 | | /// </summary> |
| | 33 | | /// <param name="name"> |
| | 34 | | /// The custom method name. |
| | 35 | | /// </param> |
| | 36 | | /// <param name="filterTermExpression"> |
| | 37 | | /// The expression used for custom filtering. |
| | 38 | | /// </param> |
| 1 | 39 | | public CustomFilterMethod(string name, Func<IFilterTerm, Expression<Func<T, bool>>> filterTermExpression) : base(nam |
| | 40 | | { |
| 1 | 41 | | FilterTermExpression = Guard.Against.Null(filterTermExpression); |
| 1 | 42 | | } |
| | 43 | |
|
| | 44 | | /// <summary> |
| | 45 | | /// Gets the expression used for custom filtering. |
| | 46 | | /// </summary> |
| 5 | 47 | | public Expression<Func<T, bool>>? Expression { get; } |
| | 48 | |
|
| | 49 | | /// <summary> |
| | 50 | | /// Gets the func leading to expression used for custom filtering. |
| | 51 | | /// </summary> |
| 4 | 52 | | public Func<IFilterTerm, Expression<Func<T, bool>>>? FilterTermExpression { get; } |
| | 53 | | } |