Esempio n. 1
0
        public static DevonfwOptions SetupDevonfw(this IServiceCollection services, IConfiguration configuration)
        {
            DevonfwOptions = services.GetTypedOptions <DevonfwOptions>(configuration, DevonFwConst.OptionsNodeName);

            if (DevonfwOptions == null || string.IsNullOrEmpty(DevonfwOptions.Environment) || DevonfwOptions.Kestrel == null)
            {
                throw new ArgumentException("Please check the devonfw options node in your configuration file");
            }

            services.AddMvc().AddFluentValidation();

            if (DevonfwOptions.UseModelStateValidation)
            {
                services.AddMvc(options => options.Filters.Add(typeof(ModelStateCheckerAttribute)));
            }

            if (DevonfwOptions.UseIIS)
            {
                services.ConfigureIIS(DevonfwOptions.IIS);
            }

            if (DevonfwOptions.UseXsrf)
            {
                services.ConfigureXsrf();
            }

            return(DevonfwOptions);
        }
Esempio n. 2
0
        public static void SetupDevonfw(this IServiceCollection services, ref IConfiguration configuration)
        {
            DevonfwOptions = services.GetTypedOptions <DevonfwOptions>(configuration, DevonFwConst.DevonFwAppSettingsNodeName);

            if (DevonfwOptions == null || string.IsNullOrEmpty(DevonfwOptions.Environment) || DevonfwOptions.Kestrel == null)
            {
                throw new ApplicationException("Please check the devonfw options node in your configuration file");
            }

            services.ConfigureIIS(ref configuration);
            services.SetupKillSwitch(ref configuration);
            services.AddTransient(typeof(IObjectTypeHelper), typeof(ObjectTypeHelper));
            services.AddTransient(typeof(IJsonHelper), typeof(JsonHelper));
            services.ConfigureXsrf();
        }