Closed avanderhoorn closed 9 years ago
@avanderhoorn I've worked on a branch regarding the code configuration for Glimpse. It is already functional and fully backward compatible with the current glimpse configurations, it allows for configuration to be defined externally (database, server, custom config files, ...) and provides out of the box a provider based on xml configuration file as this is how users configured glimpse up until now. Adding another default to deal with json configs etc... is just a small step...
I definitely am going to take a look at what you described above, maybe things can be mapped, maybe not...
I didn't make a PR yet of that branch, as I wanted to finish it further to make sure I didn't overlook things, but then I had to take a little break on my work :-(
Have a look at the branch to get an idea about how it works, and I can always give a quick guide over Skype or so if you want too
@CGijbels more than happy to talk it over and see what we can do. My main thinking here is that the config/options in vNext is very different to what it was with classic ASP.Net. I know that we (mainly you) put a huge amount of effort into the config system in the old v2 code base, but with the advent of vNext and how different it is, I'm not sure what else we can do. For instance the next version of MVC is built solely on the base support, web.config doesn't exist, code configurations are preferred over json/environment/etc configurations (particularly when it comes to complex cases, type based black/white listing, etc), dependency injection which is at the core of vNext is a fairly fundamental part of vNext, etc, etc. When looking at this I struggled to see how what we did would natively/cleanly come across. Any ideas?
web.config doesn't exist, code configurations are preferred over json/environment/etc configurations (particularly when it comes to complex cases, type based black/white listing, etc)
the configuration has been built to allow any kind of source for the configuration settings to start with, after which configuration to code can be added as well.
So for vNext it might be enough to implement the IConfigurationSettingsProvider
although the hook for that lies in setting the provider to use, through the config, as you can see in the (ConfigurationFactory
)[https://github.com/Glimpse/Glimpse/blob/glimpse-configuration-system-refactoring/source/Glimpse.Core/Configuration/ConfigurationFactory.cs] class. Now on the other hand, by specifying a IConfigurationSettingsProvider
in a ConfigurationFactory.Create
overload might be enough, as that Create
method is called by the hosting environment (ASP.Net, OWIN Middleware (see here ,...)
So as long as the hook into the new MVC provides an IConfigurationSettingsProvider
to the ConfigurationFactory
all should be good to go, and that IConfigurationSettingsProvider
can be quite basic as well because code configuration then happens on the resulting ConfigurationSettings
Just wondering, but even with the advent of ASP.NET vNext etc... we only need to provide the hooks into the runtime and maybe other plugins, but we still share the Glimpse Core? Or is the idea to have 2 Glimpse Core's maintained next to each other? Because the majority of users will still be using ASP.NET vCurrent for the upcoming year(s)...
Design:
Inspiration for this design is based on the supported configuration system for DNXRE and how MVC utilizes this.
Use Case
Implementation
Descriptor
's are used for anyList<>
properties for theGlimpseOptions
to control lazy loading - seeoptions.ModelBinders
hasBodyModelBinder
see registered as one of its items (options.ModelBinders.Add(typeof(BodyModelBinder));
see and it intern injectsDefaultValidationExcludeFiltersProvider
see which is the only consumer ofoptions.ValidationExcludeFilters
DefaultValidationExcludeFiltersProvider
gets replaced by something else that implementsIValidationExcludeFiltersProvider
,options.ValidationExcludeFilters
wont be used by anything... this is okservices.Replace(...)
to override the default registration - see & seeProviders
are typically registered via this means and depending on implementation they might leverage the Options infrastructure or provide wiring up to Custom Hooks - seeIConfiguration
to pull out the settings from the users config source - seeDictionary<string, string>
, from there the data is pulled into a typed object - see & seeOptions
are explicitly not being used in convention scenarios to help avoid confusion and streamline the processFixedSet
providers are populated via extension methods which are extend off theIServiceCollection
Default
providers scan through the assemblies looking for types at playExamples
Startup
&Startup
MvcOptions
&RazorViewEngineOptions
MvcOptionsSetup
&RazorViewEngineOptionsSetup
MvcServices
DefaultModelMetadataProvider
DbContextOptionsParser
EntityFrameworkServicesBuilder
Startup
MvcServiceCollectionExtensions
DefaultControllerTypeProvider
&FixedSetControllerTypeProvider
State The Application Model is a model that might not be needed by provides a unified view of the complete discovery process.
Guidelines:
Implementation
Server Web: