<commit_before>using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using Abp.Dependency;

namespace Abp.WebApi.Validation
{
    public class AbpValidationFilterAttribute : IActionFilter, ITransientDependency
    {
        public bool AllowMultiple => false;

        private readonly IIocResolver _iocResolver;

        public AbpValidationFilterAttribute(IIocResolver iocResolver)
        {
            _iocResolver = iocResolver;
        }

        public async Task<HttpResponseMessage> ExecuteActionFilterAsync(HttpActionContext actionContext, CancellationToken cancellationToken, Func<Task<HttpResponseMessage>> continuation)
        {
            var methodInfo = actionContext.ActionDescriptor.GetMethodInfoOrNull();
            if (methodInfo != null)
            {
                using (var validator = _iocResolver.ResolveAsDisposable<WebApiActionInvocationValidator>())
                {
                    validator.Object.Initialize(actionContext, methodInfo);
                    validator.Object.Validate();
                }
            }

            return await continuation();
        }
    }
}<commit_msg>Avoid duplicate validation for web apis.<commit_after>using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using Abp.Application.Services;
using Abp.Dependency;

namespace Abp.WebApi.Validation
{
    public class AbpValidationFilterAttribute : IActionFilter, ITransientDependency
    {
        public bool AllowMultiple => false;

        private readonly IIocResolver _iocResolver;

        public AbpValidationFilterAttribute(IIocResolver iocResolver)
        {
            _iocResolver = iocResolver;
        }

        public async Task<HttpResponseMessage> ExecuteActionFilterAsync(HttpActionContext actionContext, CancellationToken cancellationToken, Func<Task<HttpResponseMessage>> continuation)
        {
            using (AbpCrossCuttingConcerns.Applying(actionContext.ControllerContext.Controller, AbpCrossCuttingConcerns.Validation))
            {
                var methodInfo = actionContext.ActionDescriptor.GetMethodInfoOrNull();
                if (methodInfo != null)
                {
                    using (var validator = _iocResolver.ResolveAsDisposable<WebApiActionInvocationValidator>())
                    {
                        validator.Object.Initialize(actionContext, methodInfo);
                        validator.Object.Validate();
                    }
                }

                return await continuation();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07006603081438005, 'fraction_numerical': 0.0, 'mean_word_length': 2.5323834196891193, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3522564', 'n_tokens_mistral': 667, 'n_tokens_neox': 658, 'n_words': 128}