Esempio n. 1
0
        // If this method needs to become any more complex, then break it away to a service of its own which gets
        // a spec from a request.
        ISpecificationExpression <Sprint> GetSpecification(ListSprintsRequest request)
        {
            var project = GetProject(request);
            ISpecificationExpression <Sprint> spec = projectSprintFactory(project);

            if (!request.ShowOpenSprints)
            {
                spec = spec.And(closedSprintFactory());
            }

            if (!request.ShowClosedSprints)
            {
                spec = spec.And(openSprintFactory());
            }

            return(spec);
        }
Esempio n. 2
0
        public Expression <Func <Ticket, bool> > GetExpression()
        {
            ISpecificationExpression <Ticket> output = Spec.Expr <Ticket>(x => true);

            foreach (var labelName in labelNames)
            {
                var nameExpression = Spec.Expr <Ticket>(x => x.Labels.Any(l => l.Name == labelName));
                output = output.And(nameExpression);
            }

            return(output.GetExpression());
        }
Esempio n. 3
0
        ISpecificationExpression <Ticket> AddSpecification(ISpecificationExpression <Ticket> toAdd,
                                                           LogicalOperator logicalOperator)
        {
            if (specBeingBuilt == null)
            {
                return(toAdd);
            }
            logicalOperator.RequireDefinedValue(nameof(logicalOperator));

            switch (logicalOperator)
            {
            case LogicalOperator.Or:
                return(specBeingBuilt.Or(toAdd));

            case LogicalOperator.And:
                return(specBeingBuilt.And(toAdd));

            default:
                throw new NotSupportedException($"The {nameof(LogicalOperator)} must have a supported value.");
            }
        }