When you have .config file: <?xml version="1.0" encoding="utf-8" ?><configuration> <appSettings> <add key="MailNotificationSettings.SmtpServerAddress" value="http://localhost"/> <add key="MailNotificationSettings.Username" value="user123"/> <add key="MailNotificationSettings.Password" value="passwd123"/> </appSettings></configuration>Define the following interface: public interface IMailNotificationSettings{ Uri SmtpServerAddress { get; } string Username { get; } string Password { get; }}And from your program use this code: public static void Main(){ ConfigurationReader configReader = new ConfigurationReader().SetupConfigOf<IMailNotificationSettings>(); IMailNotificationSettings mailNotificationSettings = configReader.ConfigBrowser.Get<IMailNotificationSettings>(); var mailNotificationService = new MailNotificationService(mailNotificationSettings); // // Do the work.. //}
When you have .config file:
<?xml version="1.0" encoding="utf-8" ?><configuration> <appSettings> <add key="MailNotificationSettings.SmtpServerAddress" value="http://localhost"/> <add key="MailNotificationSettings.Username" value="user123"/> <add key="MailNotificationSettings.Password" value="passwd123"/> </appSettings></configuration>
Define the following interface:
public interface IMailNotificationSettings{ Uri SmtpServerAddress { get; } string Username { get; } string Password { get; }}
And from your program use this code:
public static void Main(){ ConfigurationReader configReader = new ConfigurationReader().SetupConfigOf<IMailNotificationSettings>(); IMailNotificationSettings mailNotificationSettings = configReader.ConfigBrowser.Get<IMailNotificationSettings>(); var mailNotificationService = new MailNotificationService(mailNotificationSettings); // // Do the work.. //}
Subscribe to RSS headline updates from: