| | 1 | | namespace Pozitron.QuerySpecification; |
| | 2 | |
|
| | 3 | | /// <summary> |
| | 4 | | /// Represents a specification builder that supports order operations. |
| | 5 | | /// </summary> |
| | 6 | | /// <typeparam name="T">The type of the entity.</typeparam> |
| | 7 | | /// <typeparam name="TResult">The type of the result.</typeparam> |
| | 8 | | public interface IOrderedSpecificationBuilder<T, TResult> : ISpecificationBuilder<T, TResult> |
| | 9 | | { |
| | 10 | | } |
| | 11 | |
|
| | 12 | | /// <summary> |
| | 13 | | /// Represents a specification builder that supports order operations. |
| | 14 | | /// </summary> |
| | 15 | | /// <typeparam name="T">The type of the entity.</typeparam> |
| | 16 | | public interface IOrderedSpecificationBuilder<T> : ISpecificationBuilder<T> |
| | 17 | | { |
| | 18 | | } |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// Represents a specification builder. |
| | 22 | | /// </summary> |
| | 23 | | /// <typeparam name="T">The type of the entity.</typeparam> |
| | 24 | | /// <typeparam name="TResult">The type of the result.</typeparam> |
| | 25 | | public interface ISpecificationBuilder<T, TResult> |
| | 26 | | { |
| | 27 | | internal Specification<T, TResult> Specification { get; } |
| | 28 | |
|
| | 29 | | /// <summary> |
| | 30 | | /// Adds an item to the specification. |
| | 31 | | /// </summary> |
| | 32 | | /// <param name="type">The type of the item.</param> |
| | 33 | | /// <param name="value">The object to be stored in the item.</param> |
| | 34 | | /// <exception cref="ArgumentNullException">Thrown if value is null</exception> |
| | 35 | | /// <exception cref="ArgumentOutOfRangeException">Thrown if type is zero or negative.</exception> |
| | 36 | | void Add(int type, object value); |
| | 37 | |
|
| | 38 | | /// <summary> |
| | 39 | | /// Adds or updates an item in the specification. |
| | 40 | | /// </summary> |
| | 41 | | /// <param name="type">The type of the item.</param> |
| | 42 | | /// <param name="value">The object to be stored in the item.</param> |
| | 43 | | /// <exception cref="ArgumentNullException">Thrown if value is null</exception> |
| | 44 | | /// <exception cref="ArgumentOutOfRangeException">Thrown if type is zero or negative.</exception> |
| | 45 | | void AddOrUpdate(int type, object value); |
| | 46 | | } |
| | 47 | |
|
| | 48 | | /// <summary> |
| | 49 | | /// Represents a specification builder. |
| | 50 | | /// </summary> |
| | 51 | | /// <typeparam name="T">The type of the entity.</typeparam> |
| | 52 | | public interface ISpecificationBuilder<T> |
| | 53 | | { |
| | 54 | | internal Specification<T> Specification { get; } |
| | 55 | |
|
| | 56 | | /// <summary> |
| | 57 | | /// Adds an item to the specification. |
| | 58 | | /// </summary> |
| | 59 | | /// <param name="type">The type of the item.</param> |
| | 60 | | /// <param name="value">The object to be stored in the item.</param> |
| | 61 | | /// <exception cref="ArgumentNullException">Thrown if value is null</exception> |
| | 62 | | /// <exception cref="ArgumentOutOfRangeException">Thrown if type is zero or negative.</exception> |
| | 63 | | void Add(int type, object value); |
| | 64 | |
|
| | 65 | | /// <summary> |
| | 66 | | /// Adds or updates an item in the specification. |
| | 67 | | /// </summary> |
| | 68 | | /// <param name="type">The type of the item.</param> |
| | 69 | | /// <param name="value">The object to be stored in the item.</param> |
| | 70 | | /// <exception cref="ArgumentNullException">Thrown if value is null</exception> |
| | 71 | | /// <exception cref="ArgumentOutOfRangeException">Thrown if type is zero or negative.</exception> |
| | 72 | | void AddOrUpdate(int type, object value); |
| | 73 | | } |
| | 74 | |
|
| | 75 | | internal class SpecificationBuilder<T, TResult>(Specification<T, TResult> specification) |
| | 76 | | : IOrderedSpecificationBuilder<T, TResult>, ISpecificationBuilder<T, TResult> |
| | 77 | | { |
| | 78 | | public Specification<T, TResult> Specification { get; } = specification; |
| | 79 | | public void Add(int type, object value) => Specification.Add(type, value); |
| | 80 | | public void AddOrUpdate(int type, object value) => Specification.AddOrUpdate(type, value); |
| | 81 | | } |
| | 82 | |
|
| 259 | 83 | | internal class SpecificationBuilder<T>(Specification<T> specification) |
| | 84 | | : IOrderedSpecificationBuilder<T>, ISpecificationBuilder<T> |
| | 85 | | { |
| 767 | 86 | | public Specification<T> Specification { get; } = specification; |
| 1 | 87 | | public void Add(int type, object value) => Specification.Add(type, value); |
| 1 | 88 | | public void AddOrUpdate(int type, object value) => Specification.AddOrUpdate(type, value); |
| | 89 | | } |