Beispiel #1
0
        private IReadOnlyList <ActionSelectorCandidate> EvaluateActionConstraintsCore(RouteContext context, IReadOnlyList <ActionSelectorCandidate> candidates, int?startingOrder)
        {
            int?startingOrder1 = new int?();
            int?nullable;

            for (int index1 = 0; index1 < candidates.Count; ++index1)
            {
                ActionSelectorCandidate candidate = candidates[index1];
                if (candidate.Constraints != null)
                {
                    for (int index2 = 0; index2 < candidate.Constraints.Count; ++index2)
                    {
                        IActionConstraint constraint = candidate.Constraints[index2];
                        if (startingOrder.HasValue)
                        {
                            int order = constraint.Order;
                            nullable = startingOrder;
                            int valueOrDefault = nullable.GetValueOrDefault();
                            if ((order > valueOrDefault ? (nullable.HasValue ? 1 : 0) : 0) == 0)
                            {
                                continue;
                            }
                        }
                        if (startingOrder1.HasValue)
                        {
                            int order = constraint.Order;
                            nullable = startingOrder1;
                            int valueOrDefault = nullable.GetValueOrDefault();
                            if ((order < valueOrDefault ? (nullable.HasValue ? 1 : 0) : 0) == 0)
                            {
                                continue;
                            }
                        }
                        startingOrder1 = new int?(constraint.Order);
                    }
                }
            }
            if (!startingOrder1.HasValue)
            {
                return(candidates);
            }
            List <ActionSelectorCandidate> selectorCandidateList1 = new List <ActionSelectorCandidate>();
            List <ActionSelectorCandidate> selectorCandidateList2 = new List <ActionSelectorCandidate>();
            ActionConstraintContext        context1 = new ActionConstraintContext();

            context1.Candidates   = candidates;
            context1.RouteContext = context;
            for (int index1 = 0; index1 < candidates.Count; ++index1)
            {
                ActionSelectorCandidate candidate = candidates[index1];
                bool flag1 = true;
                bool flag2 = false;
                if (candidate.Constraints != null)
                {
                    context1.CurrentCandidate = candidate;
                    for (int index2 = 0; index2 < candidate.Constraints.Count; ++index2)
                    {
                        IActionConstraint constraint = candidate.Constraints[index2];
                        int order = constraint.Order;
                        nullable = startingOrder1;
                        int valueOrDefault = nullable.GetValueOrDefault();
                        if ((order == valueOrDefault ? (nullable.HasValue ? 1 : 0) : 0) != 0)
                        {
                            flag2 = true;
                            if (!constraint.Accept(context1))
                            {
                                flag1 = false;
                                this._logger.LogDebug($"ConstraintMismatch( {candidate.Action.DisplayName}, {candidate.Action.Id}, {constraint}");
                                break;
                            }
                        }
                    }
                }
                if (flag1 & flag2)
                {
                    selectorCandidateList1.Add(candidate);
                }
                else if (flag1)
                {
                    selectorCandidateList2.Add(candidate);
                }
            }
            if (selectorCandidateList1.Count > 0)
            {
                IReadOnlyList <ActionSelectorCandidate> actionConstraintsCore = this.EvaluateActionConstraintsCore(context, (IReadOnlyList <ActionSelectorCandidate>)selectorCandidateList1, startingOrder1);
                if (actionConstraintsCore != null && actionConstraintsCore.Count > 0)
                {
                    return(actionConstraintsCore);
                }
            }
            if (selectorCandidateList2.Count == 0)
            {
                return((IReadOnlyList <ActionSelectorCandidate>)null);
            }
            return(this.EvaluateActionConstraintsCore(context, (IReadOnlyList <ActionSelectorCandidate>)selectorCandidateList2, startingOrder1));
        }