public static SmsSection Read(string sectionName) { // Get the application configuration file. Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); Console.WriteLine($"Config Path: {config.FilePath}"); // Read and display the custom section. SmsSection customSection = config.GetSection(sectionName) as SmsSection; Console.WriteLine($"Name: {customSection?.Name}"); Console.WriteLine($"Provider: {customSection?.Provider}"); return(customSection); }
public static void CreateSection(string sectionName) { SmsSection customSection = new SmsSection(); // Get the current configuration file. Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); // Add the custom section to the application // configuration file. if (config.Sections[sectionName] == null) { config.Sections.Add(sectionName, customSection); } // Save the application configuration file. customSection.SectionInformation.ForceSave = true; config.Save(ConfigurationSaveMode.Modified); }
public SmsTwilioService(SmsSection settings) { Settings = settings; }