コード例 #1
0
 private ClientSettingsSection DeclareUserSection(System.Configuration.Configuration config, string sectionName)
 {
     ConfigurationSectionGroup sectionGroup = config.GetSectionGroup("userSettings");
     if (sectionGroup == null)
     {
         sectionGroup = new UserSettingsGroup();
         config.SectionGroups.Add("userSettings", sectionGroup);
     }
     bool flag = false;
     ConfigurationSection section = sectionGroup.Sections[sectionName];
     if (section == null)
     {
         section = new ClientSettingsSection();
         flag = true;
     }
     else if (section is DefaultSection)
     {
         section = this.ReadClientSettingsSection(section);
         if (section != null)
         {
             sectionGroup.Sections.Remove(sectionName);
             flag = true;
         }
     }
     if (flag)
     {
         section.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser;
         section.SectionInformation.RequirePermission = false;
         sectionGroup.Sections.Add(sectionName, section);
     }
     return (section as ClientSettingsSection);
 }
コード例 #2
0
		public static TransactionsSectionGroup GetSectionGroup(System.Configuration.Configuration config)
		{
			if (config == null)
				throw new ArgumentNullException("config");

			return config.GetSectionGroup("system.transactions") as TransactionsSectionGroup;
		}
 private void DeclareSection(System.Configuration.Configuration config, string sectionName)
 {
     if (config.GetSectionGroup("userSettings") == null)
     {
         ConfigurationSectionGroup group2 = new UserSettingsGroup();
         config.SectionGroups.Add("userSettings", group2);
     }
     ConfigurationSectionGroup sectionGroup = config.GetSectionGroup("userSettings");
     if ((sectionGroup != null) && (sectionGroup.Sections[sectionName] == null))
     {
         ConfigurationSection section = new ClientSettingsSection {
             SectionInformation = { AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser, RequirePermission = false }
         };
         sectionGroup.Sections.Add(sectionName, section);
     }
 }
 public static NetSectionGroup GetSectionGroup(System.Configuration.Configuration config)
 {
     if (config == null)
     {
         throw new ArgumentNullException("config");
     }
     return (config.GetSectionGroup("system.net") as NetSectionGroup);
 }
            /// <summary>
            /// Inits the specified configuration.
            /// </summary>
            /// <param name="configuration">The configuration.</param>
            /// <param name="sectionName">The name of the section containing the settings.</param>
            /// <exception cref="ArgumentNullException"><paramref name="configuration"/> is <c>null</c>.</exception>
            /// <param name="sectionName">The name of the section containing the settings.</param>
            internal Provider(System.Configuration.Configuration configuration, string sectionName)
            {
                if (configuration == null)
                {
                    throw new ArgumentNullException("configuration");
                }

                if (string.IsNullOrEmpty(sectionName))
                {
                    throw new ArgumentNullException("sectionName");
                }

                _configuration = configuration;

                _sectionName = sectionName;

                var sectionGroup = configuration.GetSectionGroup("applicationSettings");

                _applicationSection = sectionGroup == null ? null : sectionGroup.Sections[_sectionName] as ClientSettingsSection;

                sectionGroup = configuration.GetSectionGroup("userSettings");

                _userSection = sectionGroup == null ? null : sectionGroup.Sections[_sectionName] as ClientSettingsSection;

                // The provider MUST have a name
                Initialize(GetType().Name, null);
            }