Skip to content

Instantly share code, notes, and snippets.

@idavis
Created April 6, 2011 13:50
Show Gist options
  • Save idavis/905671 to your computer and use it in GitHub Desktop.
Save idavis/905671 to your computer and use it in GitHub Desktop.
Config
;config.ini
[Network]
DataFeed=http://mydomain.com/feed.xml
Port=68
NextUpdate=3/23/2009 9:11:48 PM
You can load it:
var configurationSource = new IniConfigurationSource("config.ini");
var datafeed = configurationSource.Sections["Network"].Get<string>("DataFeed");
var datafeedUri = configurationSource.Sections["Network"].Get<Uri>("DataFeed");
var nextUpdate = configurationSource.Sections["Network"].Get<DateTime>("NextUpdate");
If you want to cut down on the typing, save the section:
var networkConfig = configurationSource.Sections["Network"];
int port = networkConfig.Get<int>("Port");
var longPort = networkConfig.Get<long>("Port");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment