コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public SmsTwilioService(SmsSection settings)
 {
     Settings = settings;
 }