Create a dynamically created configuration user interface using reflection in .NET Config data types

Does anyone have experience / attempt to do this?

We have a rather complex XML configuration for our .NET application, and we thought it would be nice if we could use our hierarchy of configuration objects to dynamically assemble the user interface using the reflection and attributes / metadata from the properties of these objects to represent the parameters user to create a configuration.

It would be nice to make this fairly general, so we can provide it with any .NET XML configuration object (within reason), and it will reflect it and allow it to fill.

+4
source share
1 answer

You need to think about what the Config files in .NET are for. This is the place to distinguish between different deployments of your application. Therefore, when you talk about dynamic configuration changes based on encoded logic, I think you might have the wrong path. This is your code, which should select its direction from the settings entered through the configuration.

It seems you want to create some kind of configuration editor? Why does this happen when Visual Studio has two built-in? Editing window and various Configuration Editors, ASP.NET Configuration Editor, Microsoft Service Configuration Editor, etc.

In my experience, the differences between web or app.config in the Dev environment and the test environment compared to the production environment will usually differ only in a few settings, such as connection strings, AppSettings, message queue addresses, service endpoints, Log4Net settings, etc. .

Well, quite a few settings, but each configuration block usually has only one or two attributes that differ from environment to environment. An exception is an IOC configuration such as Spring.NET, CastleWinsor, or Unity. But even in this case, they often exactly coincide with the environment and the environment.

I would advise you to leave and think about it a bit. Think about the real problem you are trying to solve. Perhaps you need some kind of database workflow? I dont know.

I just know that config should not be run-time-driven. This application is for deployment and assembly.

Having said that, there are tools like ConfigGen , which makes setting up your environment-specific configuration easy. Check it out when it really is what you need.

+1
source

All Articles