Exemplo n.º 1
0
        public static bool Evaluate <T>(this CollectionOperator @operator, IEnumerable <T> collection, Func <T, bool> predicate)
        {
            @operator.Validate(nameof(@operator));
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }

            var isOdd = ((int)@operator) % 2 == 1;

            return(EvaluateInternal(isOdd ? @operator + 1 : @operator) ^ isOdd);

            bool EvaluateInternal(CollectionOperator effectiveOperator)
            {
                return(effectiveOperator switch
                {
                    CollectionOperator.Any => collection.Any(predicate),
                    CollectionOperator.All => collection.All(predicate),
                    _ => throw new NotSupportedException($"CollectionOperator of {@operator} is not supported"),
                });
            }
Exemplo n.º 2
0
        public EmailAccountQuery WithTemplateId(long?value = null,
                                                ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                                CollectionOperator @operator  = CollectionOperator.Equal,
                                                CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(ea => ea.Templates.Any(mt => mt.Id == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(ea => ea.Templates.All(mt => mt.Id == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(ea => ea.Templates.Any(mt => mt.Id != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(ea => ea.Templates.All(mt => mt.Id != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
        public ToDoStatusQuery WithToDoId(long?value = null,
                                          ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                          CollectionOperator @operator  = CollectionOperator.Equal,
                                          CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(tds => tds.ToDos.Any(td => td.Id == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(tds => tds.ToDos.All(td => td.Id == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(tds => tds.ToDos.Any(td => td.Id != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(tds => tds.ToDos.All(td => td.Id != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
Exemplo n.º 4
0
        public ActivityTypeQuery WithActivity(Activity value = null,
                                              ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                              CollectionOperator @operator  = CollectionOperator.Equal,
                                              CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(at => at.Activities.Any(a => a == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(at => at.Activities.All(a => a == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(at => at.Activities.Any(a => a != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(at => at.Activities.All(a => a != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
Exemplo n.º 5
0
        public CategoryQuery WithNews(News value = null,
                                      ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                      CollectionOperator @operator  = CollectionOperator.Equal,
                                      CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(c => c.News.Any(n => n == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(c => c.News.All(n => n == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(c => c.News.Any(n => n != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(c => c.News.All(n => n != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
        public QueuedEmailQuery WithBcc(string value = null,
                                        ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                        CollectionOperator @operator  = CollectionOperator.Equal,
                                        CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(qe => qe.Bcc.Any(bcc => bcc == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(qe => qe.Bcc.All(bcc => bcc == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(qe => qe.Bcc.Any(bcc => bcc != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(qe => qe.Bcc.All(bcc => bcc != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
Exemplo n.º 7
0
        public PollChoiceItemQuery WithVotingRecordId(long?value = null,
                                                      ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                                      CollectionOperator @operator  = CollectionOperator.Equal,
                                                      CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(pci => pci.VotingRecords.Any(pvr => pvr.Id == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(pci => pci.VotingRecords.All(pvr => pvr.Id == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(pci => pci.VotingRecords.Any(pvr => pvr.Id != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(pci => pci.VotingRecords.All(pvr => pvr.Id != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
Exemplo n.º 8
0
        public PublisherQuery WithTrack(Track value = null,
                                        ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                        CollectionOperator @operator  = CollectionOperator.Equal,
                                        CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(p => p.Tracks.Any(t => t == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(p => p.Tracks.All(t => t == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(p => p.Tracks.Any(t => t != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(p => p.Tracks.All(t => t != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
        public ResourceKeyQuery WithValue(ResourceValue value           = null,
                                          ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                          CollectionOperator @operator  = CollectionOperator.Equal,
                                          CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(rk => rk.Values.Any(rv => rv == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(rk => rk.Values.All(rv => rv == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(rk => rk.Values.Any(rv => rv != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(rk => rk.Values.All(rv => rv != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
Exemplo n.º 10
0
        public BlogQuery WithAuthor(User value = null,
                                    ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                    CollectionOperator @operator  = CollectionOperator.Equal,
                                    CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(b => b.Authors.Any(u => u == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(b => b.Authors.All(u => u == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(b => b.Authors.Any(u => u != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(b => b.Authors.All(u => u != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
Exemplo n.º 11
0
        public TransactionRequestQuery WithResponse(TransactionResponse value     = null,
                                                    ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                                    CollectionOperator @operator  = CollectionOperator.Equal,
                                                    CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(tr => tr.Responses.Any(tr2 => tr2 == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(tr => tr.Responses.All(tr2 => tr2 == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(tr => tr.Responses.Any(tr2 => tr2 != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(tr => tr.Responses.All(tr2 => tr2 != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
        public PermissionRecordQuery WithRole(Role value = null,
                                              ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                              CollectionOperator @operator  = CollectionOperator.Equal,
                                              CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(pr => pr.Roles.Any(r => r == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(pr => pr.Roles.All(r => r == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(pr => pr.Roles.Any(r => r != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(pr => pr.Roles.All(r => r != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
Exemplo n.º 13
0
        public MessageTemplateQuery WithBccEmailAddresses(string value = null,
                                                          ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                                          CollectionOperator @operator  = CollectionOperator.Equal,
                                                          CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(mt => mt.BccEmailAddresses.Any(bea => bea == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(mt => mt.BccEmailAddresses.All(bea => bea == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(mt => mt.BccEmailAddresses.Any(bea => bea != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(mt => mt.BccEmailAddresses.All(bea => bea != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
Exemplo n.º 14
0
        public RedirectorQuery WithDownload(Download value = null,
                                            ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                            CollectionOperator @operator  = CollectionOperator.Equal,
                                            CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(r => r.Downloads.Any(d => d == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(r => r.Downloads.All(d => d == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(r => r.Downloads.Any(d => d != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(r => r.Downloads.All(d => d != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
Exemplo n.º 15
0
		public TicketDepartmentQuery WithTicket(Ticket value = null,
		                                        ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral,
		                                        CollectionOperator @operator = CollectionOperator.Equal,
		                                        CollectionDirection direction = CollectionDirection.Any) {
			switch (mode) {
				case ArgumentEvaluationMode.IgnoreNeutral:
					if (Neutrals.Is(value))
						return this;
					break;

				case ArgumentEvaluationMode.Explicit:
					break;

				default:
					throw new NotSupportedEnumException(mode);
			}

			switch (@operator) {
				case CollectionOperator.Equal:
					switch (direction) {
						case CollectionDirection.Any:
							Entities = Entities.Where(td => td.Tickets.Any(t => t == value));
							return this;

						case CollectionDirection.All:
							Entities = Entities.Where(td => td.Tickets.All(t => t == value));
							return this;

						default:
							throw new NotSupportedEnumException(direction);
					}

				case CollectionOperator.NotEqual:
					switch (direction) {
						case CollectionDirection.Any:
							Entities = Entities.Where(td => td.Tickets.Any(t => t != value));
							return this;

						case CollectionDirection.All:
							Entities = Entities.Where(td => td.Tickets.All(t => t != value));
							return this;

						default:
							throw new NotSupportedEnumException(direction);
					}
				default:
					throw new NotSupportedEnumException(@operator);
			}
		}
        protected virtual string GetCollectionExpressionString(CollectionOperator op)
        {
            switch (op)
            {
            case CollectionOperator.In:
                return(" IN ");

            case CollectionOperator.NotIn:
                return(" NOT IN ");

            case CollectionOperator.All:
            case CollectionOperator.Any:
            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 17
0
        private void DepthFirstSearch(
            ThreeAddressCode currentBlock,
            Dictionary <ThreeAddressCode, bool> visited,
            Stack <ThreeAddressCode> predecessors,
            Func <ThreeAddressCode, bool> checkForNext,
            Func <ThreeAddressCode, IEnumerable <Edge <ThreeAddressCode> > > getNextEdges
            )
        {
            visited[currentBlock] = true;

            var collectionOperatorResult = new HashSet <TacNode>();

            if (predecessors.Count > 0)
            {
                collectionOperatorResult = predecessors
                                           .Select(e => InOut.Out[e])
                                           .Aggregate((a, b) => CollectionOperator.Collect(a, b));
            }

            InOut.In[currentBlock] = CollectionOperator.Collect(collectionOperatorResult, InOut.In[currentBlock]);
            var outBefore = InOut.Out[currentBlock];

            InOut.Out[currentBlock] = TransmissionFunction.Calculate(InOut.In[currentBlock], currentBlock);

            if (checkForNext(currentBlock))
            {
                visited[currentBlock] = false;
                return;
            }

            predecessors.Push(currentBlock);
            foreach (var outEdge in getNextEdges(currentBlock))
            {
                var outVertex = IsForwardDirection ? outEdge.Target : outEdge.Source;
                if (!visited[outVertex])
                {
                    DepthFirstSearch(outVertex, visited, predecessors, checkForNext, getNextEdges);
                }
            }

            predecessors.Pop();
            visited[currentBlock] = false;
        }
Exemplo n.º 18
0
        /// <summary>
        /// Initializes the operator resolver.
        /// </summary>
        /// <returns>The operator resolver.</returns>
        private static OperatorResolver InitOperatorResolver()
        {
            Mock <OperatorResolver> opResolverMock = new Mock <OperatorResolver>();
            IExpressionFactory      exprFactory    =
                new ExpressionFactory(
                    ModelResolvers.ExprResolver,
                    ModelResolvers.RuleExprResolver,
                    ModelResolvers.JoinExprResolver,
                    opResolverMock.Object);

            JoinApplyMeasuresOperator joinApplyMeasuresOp = new JoinApplyMeasuresOperator(
                exprFactory,
                ModelResolvers.DsResolver);

            opResolverMock.Setup(o => o(It.IsAny <string>()))
            .Returns((string key) =>
            {
                IOperatorDefinition op;

                if (key.In("count", "min", "max", "median", "sum", "avg", "stddev_pop", "stddev_samp", "var_pop", "var_samp"))
                {
                    op = new AggrFunctionOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver);
                }
                else if (key == "aggr")
                {
                    op = new AggrOperator();
                }
                else if (key.In("first_value", "last_value", "lag", "rank", "ratio_to_report", "lead"))
                {
                    op = new AnalyticFunctionOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver);
                }
                else if (key.In("+", "-", "*", "/"))
                {
                    op = new ArithmeticOperator(joinApplyMeasuresOp);
                }
                else if (key == "between")
                {
                    op = new BetweenOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver);
                }
                else if (key.In("and", "or", "xor", "not"))
                {
                    op = new BooleanOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver);
                }
                else if (key == "calc")
                {
                    op = new CalcOperator(ModelResolvers.DsResolver);
                }
                else if (key == "check_datapoint")
                {
                    op = new CheckDatapointOperator(ModelResolvers.DsResolver, exprFactory);
                }
                else if (key.In("=", "<>", "<", "<=", ">", ">="))
                {
                    op = new ComparisonOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver);
                }
                else if (key == "comp")
                {
                    op = new ComponentOperator(ModelResolvers.DsResolver, new ComponentTypeInference(ModelResolvers.DsResolver));
                }
                else if (key == "const")
                {
                    op = new ConstantOperator(ModelResolvers.DsResolver);
                }
                else if (key == "current_date")
                {
                    op = new CurrentDateOperator(ModelResolvers.DsResolver);
                }
                else if (key == "exists_in")
                {
                    op = new ExistsInOperator(ModelResolvers.DsResolver);
                }
                else if (key == "get")
                {
                    op = new GetOperator(new Mock <IDataModelProvider>().Object);                       // operator tests should mock IDataModel implementation
                }
                else if (key == "if")
                {
                    op = new IfThenElseOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver);
                }
                else if (key.In("in", "not_in"))
                {
                    op = new InOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver);
                }
                else if (key == "isnull")
                {
                    op = new IsNullOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver);
                }
                else if (key == "join")
                {
                    op = new JoinOperator(ModelResolvers.DsResolver);
                }
                else if (key.In("keep", "drop"))
                {
                    op = new KeepDropOperator(ModelResolvers.DsResolver);
                }
                else if (key == "match_characters")
                {
                    op = new MatchCharactersOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver);
                }
                else if (key == "#")
                {
                    op = new MembershipOperator();
                }
                else if (key.In("ceil", "floor", "abs", "exp", "ln", "sqrt", "mod", "round", "power", "log", "trunc"))
                {
                    op = new NumericOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver);
                }
                else if (key == "nvl")
                {
                    op = new NvlOperator(joinApplyMeasuresOp);
                }
                else if (key == "opt")
                {
                    op = new OptionalOperator(ModelResolvers.DsResolver);
                }
                else if (key == "period_indicator")
                {
                    op = new PeriodIndicatorOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver, exprFactory);
                }
                else if (key == "pivot")
                {
                    op = new PivotOperator(ModelResolvers.DsResolver);
                }
                else if (key == "ref")
                {
                    op = new ReferenceOperator();
                }
                else if (key == "rename")
                {
                    op = new RenameOperator(ModelResolvers.DsResolver);
                }
                else if (key.In("union", "intersect", "setdiff", "symdiff"))
                {
                    op = new SetOperator();
                }
                else if (key.In("||", "trim", "rtrim", "ltrim", "upper", "lower", "substr", "replace", "instr", "length"))
                {
                    op = new StringOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver);
                }
                else if (key == "sub")
                {
                    op = new SubspaceOperator(ModelResolvers.DsResolver);
                }
                else if (key.In("fill_time_series", "flow_to_stock", "stock_to_flow", "timeshift", "time_agg"))
                {
                    op = new TimeOperator();
                }
                else if (key.In("plus", "minus"))
                {
                    op = new UnaryArithmeticOperator(joinApplyMeasuresOp);
                }
                else if (key == "unpivot")
                {
                    op = new UnpivotOperator(ModelResolvers.DsResolver);
                }
                // ---
                else if (key == "calcExpr")
                {
                    op = new CalcExprOperator(ModelResolvers.DsResolver);
                }
                else if (key == "collection")
                {
                    op = new CollectionOperator(ModelResolvers.DsResolver);
                }
                else if (key == "datasetClause")
                {
                    op = new DatasetClauseOperator();
                }
                else if (key == "group")
                {
                    op = new GroupOperator(ModelResolvers.DsResolver);
                }
                else if (key == "order")
                {
                    op = new OrderOperator(ModelResolvers.DsResolver);
                }
                else if (key == "partition")
                {
                    op = new PartitionOperator(ModelResolvers.DsResolver);
                }
                else if (key == "renameExpr")
                {
                    op = new RenameExprOperator(ModelResolvers.DsResolver);
                }
                else if (key == "subExpr")
                {
                    op = new SubspaceExprOperator();
                }
                else if (key == "when")
                {
                    op = new WhenOperator();
                }
                else
                {
                    throw new InvalidOperationException("Operator not found");
                }

                op.Symbol = key;
                return(op);
            });

            return(opResolverMock.Object);
        }
Exemplo n.º 19
0
        public static CollectionOperator Invert(this CollectionOperator @operator)
        {
            @operator.Validate(nameof(@operator));

            return(@operator + (((int)@operator) % 2 == 0 ? 1 : -1));
        }
Exemplo n.º 20
0
 protected OidCollectionExpression(IEnumerable collection, CollectionOperator op)
     : base(new OidExpression(), op, new CollectionExpression(collection))
 {
 }
 protected OidCollectionExpression(IEnumerable collection, CollectionOperator op)
     : base(new OidExpression(), op, new CollectionExpression(collection)) { }