Library for simple configuration management
In your web.config or app.config make sure you have a custom section:
<configuration>
<ExtConfigure>
<IncludeFilePath="etc\externalConfig.xml"Search="All"Include="All"Required="true"/>
<IncludeFilePath="etc\machineSpecific.xml"Search="All"Include="All"Required="true"/>
</ExtConfigure>
</configuration>Find and download all of the files in the parent directory. Tracking changed included files.
publicIAppSettingsLoadSettings(){varpath=ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location).FilePath;varloader=newSettingsLoader();loader.XmlFileBySection();varresult=loader.LoadSettings(newXmlFileSettings(path,"ExtConfigure"));varfileCheckers=FileChecker.TryCreate(result.Sources).ToArray();newFirstChange(fileCheckers).Changed+=SettingsChanged;returnresult.Joined.ToAppSettings();}privatevoidSettingsChanged(objectsender,EventArgse){//TODO: reload settings or application}Watch file configuration:
<WatchFileMode='Auto'Delay='0:0:30'Check='Attr,Hash' />- Mode - mode of watch from file
Auto- try create FileSystemWatcher, otherwise create delayed monitorSystem- create FileSystemWatcherTime- create delayed monitorNone- not watching, default value- Delay - delay between checking of monitored file
- Check - what is required to check
None- only exists file and lenghtAttr- last write time and other file attributesHash- MD5 hash sum of reader fileAllorAttr,Hash- check same as inAttrandHash
Deserialization section with the name of all downloaded files.
varconfigs=settings.Get<ConfigClass>("MyConfig");