private static void AddFilters(MvcOptions options)
 {
     options.Filters.AddService(typeof(AbpAuthorizationFilter));
     options.Filters.AddService(typeof(AbpAuditActionFilter));
     options.Filters.AddService(typeof(AbpValidationActionFilter));
     options.Filters.AddService(typeof(AbpUowActionFilter));
     options.Filters.AddService(typeof(AbpExceptionFilter));
     options.Filters.AddService(typeof(AbpResultFilter));
 }
Exemple #2
0
        public void MaxValidationError_ThrowsIfValueIsOutOfRange()
        {
            // Arrange
            var options = new MvcOptions();

            // Act & Assert
            var ex = Assert.Throws<ArgumentOutOfRangeException>(() => options.MaxModelValidationErrors = -1);
            Assert.Equal("value", ex.ParamName);
        }
        public void DefaultControllerModelConvention_AppliesToAllControllers()
        {
            // Arrange
            var options = new MvcOptions();
            var app = new ApplicationModel();
            app.Controllers.Add(new ControllerModel(typeof(HelloController).GetTypeInfo(), new List<object>()));
            app.Controllers.Add(new ControllerModel(typeof(WorldController).GetTypeInfo(), new List<object>()));
            options.Conventions.Add(new SimpleControllerConvention());

            // Act
            options.Conventions[0].Apply(app);

            // Assert
            foreach (var controller in app.Controllers)
            {
                Assert.True(controller.Properties.ContainsKey("TestProperty"));
            }
        }
 private static void AddModelBinders(MvcOptions options)
 {
     options.ModelBinderProviders.Add(new AbpDateTimeModelBinderProvider());
 }
 private static void AddConventions(MvcOptions options, IServiceCollection services)
 {
     options.Conventions.Add(new AbpAppServiceConvention(services));
 }
Exemple #6
0
        /// <summary>
        /// Adds model binders to the MVC configuration.
        /// </summary>
        private void SetupMvc(MvcOptions options)
        {
            // Support binding to abstract models for a set of whitelisted types.
            options.ModelBinderProviders.Insert(0, new AbstractModelBinderProvider
            (
                new List<Type>()
                {
                        typeof(Question),
                        typeof(CodeQuestionTest),
                        typeof(QuestionSubmission)
                })
            );

            options.ModelBinderProviders.Insert(0, new DateTimeModelBinderProvider
            (
                _container.Resolve<ITimeZoneProvider>())
            );
        }
Exemple #7
0
        public static MvcOptions AddMetricsResourceFilter(this MvcOptions options)
        {
            options.Filters.Add(new MetricsResourceFilter(new DefaultRouteTemplateResolver()));

            return(options);
        }
 private static void AddFilter(Microsoft.AspNetCore.Mvc.MvcOptions config)
 {
     config.Filters.Add(new CustomExceptionFilterAttribute());
 }
 public static MvcOptions AddSCIMValueProviders(this MvcOptions mvcOptions)
 {
     mvcOptions.ValueProviderFactories.Insert(0, new SeparatedQueryStringValueProviderFactory(","));
     return(mvcOptions);
 }