Skip to content

Repository files navigation

NConfiguration

Library for simple configuration management

Build statusNuGet VersionNuGet Downloads

Examples:

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 monitor
  • System - create FileSystemWatcher
  • Time - create delayed monitor
  • None - not watching, default value
  • Delay - delay between checking of monitored file
  • Check - what is required to check
  • None - only exists file and lenght
  • Attr - last write time and other file attributes
  • Hash - MD5 hash sum of reader file
  • All or Attr,Hash - check same as in Attr and Hash

Deserialization section with the name of all downloaded files.

varconfigs=settings.Get<ConfigClass>("MyConfig");

About

Library for simple configuration management

Resources

Stars

2 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages