/// <inheritdoc />
 public void OnProvidersExecuting([NotNull] ActionConstraintProviderContext context)
 {
     foreach (var item in context.Results)
     {
         ProvideConstraint(item, context.HttpContext.RequestServices);
     }
 }
예제 #2
0
        /// <inheritdoc />
        public void OnProvidersExecuting(ActionConstraintProviderContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            for (var i = 0; i < context.Results.Count; i++)
            {
                ProvideConstraint(context.Results[i], context.HttpContext.RequestServices);
            }
        }
        /// <inheritdoc />
        public void OnProvidersExecuting(ActionConstraintProviderContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            for (var i = 0; i < context.Results.Count; i++)
            {
                ProvideConstraint(context.Results[i], context.HttpContext.RequestServices);
            }
        }
예제 #4
0
        private IReadOnlyList<IActionConstraint> GetConstraints(HttpContext httpContext, ActionDescriptor action)
        {
            if (action.ActionConstraints == null || action.ActionConstraints.Count == 0)
            {
                return null;
            }

            var items = new List<ActionConstraintItem>(action.ActionConstraints.Count);
            for (var i = 0; i < action.ActionConstraints.Count; i++)
            {
                items.Add(new ActionConstraintItem(action.ActionConstraints[i]));
            }

            var context = new ActionConstraintProviderContext(httpContext, action, items);
            for (var i = 0; i < _actionConstraintProviders.Length; i++)
            {
                _actionConstraintProviders[i].OnProvidersExecuting(context);
            }

            for (var i = _actionConstraintProviders.Length - 1; i >= 0; i--)
            {
                _actionConstraintProviders[i].OnProvidersExecuted(context);
            }

            var count = 0;
            for (var i = 0; i < context.Results.Count; i++)
            {
                if (context.Results[i].Constraint != null)
                {
                    count++;
                }
            }

            if (count == 0)
            {
                return null;
            }

            var results = new IActionConstraint[count];
            for (int i = 0, j = 0; i < context.Results.Count; i++)
            {
                var constraint = context.Results[i].Constraint;
                if (constraint != null)
                {
                    results[j++] = constraint;
                }
            }

            return results;
        }
 /// <inheritdoc />
 public void OnProvidersExecuted([NotNull] ActionConstraintProviderContext context)
 {
 }
예제 #6
0
        private IReadOnlyList<IActionConstraint> GetConstraints(HttpContext httpContext, ActionDescriptor action)
        {
            if (action.ActionConstraints == null || action.ActionConstraints.Count == 0)
            {
                return null;
            }

            var items = action.ActionConstraints.Select(c => new ActionConstraintItem(c)).ToList();
            var context = new ActionConstraintProviderContext(httpContext, action, items);

            foreach (var provider in _actionConstraintProviders)
            {
                provider.OnProvidersExecuting(context);
            }

            for (var i = _actionConstraintProviders.Length - 1; i >= 0; i--)
            {
                _actionConstraintProviders[i].OnProvidersExecuted(context);
            }

            return
                context.Results
                .Where(item => item.Constraint != null)
                .Select(item => item.Constraint)
                .ToList();
        }
 public void OnProvidersExecuted(ActionConstraintProviderContext context)
 {
 }
 public void OnProvidersExecuting(ActionConstraintProviderContext context)
 {
     foreach (var item in context.Results)
     {
         var marker = item.Metadata as BooleanConstraintMarker;
         if (marker != null)
         {
             Assert.Null(item.Constraint);
             item.Constraint = new BooleanConstraint() { Pass = marker.Pass };
         }
     }
 }