| | | 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> |
| | | 9 | | : ISpecificationBuilder<T, TResult>, IOrderedSpecificationBuilder<T> |
| | | 10 | | { |
| | | 11 | | } |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Represents a specification builder that supports order operations. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <typeparam name="T">The type of the entity.</typeparam> |
| | | 17 | | public interface IOrderedSpecificationBuilder<T> |
| | | 18 | | : ISpecificationBuilder<T> |
| | | 19 | | { |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Represents a specification builder. |
| | | 24 | | /// </summary> |
| | | 25 | | /// <typeparam name="T">The type of the entity.</typeparam> |
| | | 26 | | /// <typeparam name="TResult">The type of the result.</typeparam> |
| | | 27 | | public interface ISpecificationBuilder<T, TResult> |
| | | 28 | | : ISpecificationBuilder<T> |
| | | 29 | | { |
| | | 30 | | new internal Specification<T, TResult> Specification { get; } |
| | | 31 | | } |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Represents a specification builder. |
| | | 35 | | /// </summary> |
| | | 36 | | /// <typeparam name="T">The type of the entity.</typeparam> |
| | | 37 | | public interface ISpecificationBuilder<T> |
| | | 38 | | { |
| | | 39 | | internal Specification<T> Specification { get; } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Adds an item to the specification. |
| | | 43 | | /// </summary> |
| | | 44 | | /// <param name="type">The type of the item.</param> |
| | | 45 | | /// <param name="value">The object to be stored in the item.</param> |
| | | 46 | | /// <exception cref="ArgumentNullException">Thrown if value is null</exception> |
| | | 47 | | /// <exception cref="ArgumentOutOfRangeException">Thrown if type is zero or negative.</exception> |
| | | 48 | | void Add(int type, object value); |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// Adds or updates an item in the specification. |
| | | 52 | | /// </summary> |
| | | 53 | | /// <param name="type">The type of the item.</param> |
| | | 54 | | /// <param name="value">The object to be stored in the item.</param> |
| | | 55 | | /// <exception cref="ArgumentNullException">Thrown if value is null</exception> |
| | | 56 | | /// <exception cref="ArgumentOutOfRangeException">Thrown if type is zero or negative.</exception> |
| | | 57 | | void AddOrUpdate(int type, object value); |
| | | 58 | | } |
| | | 59 | | |
| | | 60 | | internal class SpecificationBuilder<T, TResult>(Specification<T, TResult> specification) |
| | | 61 | | : SpecificationBuilder<T>(specification), IOrderedSpecificationBuilder<T, TResult>, ISpecificationBuilder<T, TResult |
| | | 62 | | { |
| | | 63 | | new public Specification<T, TResult> Specification { get; } = specification; |
| | | 64 | | } |
| | | 65 | | |
| | 467 | 66 | | internal class SpecificationBuilder<T>(Specification<T> specification) |
| | | 67 | | : IOrderedSpecificationBuilder<T>, ISpecificationBuilder<T> |
| | | 68 | | { |
| | 1102 | 69 | | public Specification<T> Specification { get; } = specification; |
| | 2 | 70 | | public void Add(int type, object value) => Specification.Add(type, value); |
| | 2 | 71 | | public void AddOrUpdate(int type, object value) => Specification.AddOrUpdate(type, value); |
| | | 72 | | } |