private void LoadProperties(ExeConfigurationFileMap exeMap, SettingsPropertyCollection collection, ConfigurationUserLevel level, string sectionGroupName, bool allowOverwrite, string groupName) { Configuration config = ConfigurationManager.OpenMappedExeConfiguration(exeMap, level); ConfigurationSectionGroup sectionGroup = config.GetSectionGroup(sectionGroupName); if (sectionGroup != null) { foreach (ConfigurationSection configSection in sectionGroup.Sections) { if (configSection.SectionInformation.Name != groupName) { continue; } ClientSettingsSection clientSection = configSection as ClientSettingsSection; if (clientSection == null) { continue; } foreach (SettingElement element in clientSection.Settings) { LoadPropertyValue(collection, element, allowOverwrite); } // Only the first one seems to be processed by MS break; } } }
// Declares the section handler of a given section in its section group, if a declaration isn't already // present. private void DeclareSection(Configuration config, string sectionName) { ConfigurationSectionGroup settingsGroup = config.GetSectionGroup(UserSettingsGroupName); if (settingsGroup == null) { //Declare settings group ConfigurationSectionGroup group = new UserSettingsGroup(); config.SectionGroups.Add(UserSettingsGroupName, group); } settingsGroup = config.GetSectionGroup(UserSettingsGroupName); Debug.Assert(settingsGroup != null, "Failed to declare settings group"); if (settingsGroup != null) { ConfigurationSection section = settingsGroup.Sections[sectionName]; if (section == null) { section = new ClientSettingsSection(); section.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser; section.SectionInformation.RequirePermission = false; settingsGroup.Sections.Add(sectionName, section); } } }
private static IEnumerable<ConfigurationSectionEntry> GetConfigurationSections(ConfigurationSectionGroup group, ConfigurationSectionGroupPath groupPath, ConfigurationSectionErrorHandler errorHandler, bool recursive) { if (recursive) { foreach (ConfigurationSectionGroup childGroup in group.SectionGroups) { foreach (var sectionEntry in GetConfigurationSections(childGroup, groupPath.GetChildGroupPath(childGroup.Name), errorHandler, true)) yield return sectionEntry; } } for (var n = 0; n < group.Sections.Count; ++n) { ConfigurationSection section = null; try { section = group.Sections[n]; } catch (ConfigurationErrorsException) { if (errorHandler != null) section = errorHandler.Invoke(groupPath, group.Sections.Keys[n]); } if (section != null) yield return new ConfigurationSectionEntry(groupPath, section); } }
internal void CreateSectionGroup(SectionGroupInfo parentGroup, string name, ConfigurationSectionGroup sec) { if (parentGroup.HasChild(name)) { throw new ConfigurationErrorsException( "Cannot add a ConfigurationSectionGroup. A section or section group already exists with the name '" + name + "'"); } if (sec.Type == null) { sec.Type = _system.Host.GetConfigTypeName(sec.GetType()); } sec.SetName(name); var section = new SectionGroupInfo(name, sec.Type) { StreamName = FileName, ConfigHost = _system.Host }; parentGroup.AddChild(section); _elementData[section] = sec; sec.Initialize(this, section); }
public void CopyTo(ConfigurationSectionGroup[] array, int index) { if (array == null) throw new ArgumentNullException(nameof(array)); int c = Count; if (array.Length < c + index) throw new ArgumentOutOfRangeException(nameof(index)); for (int i = 0, j = index; i < c; i++, j++) array[j] = Get(i); }
internal ConfigurationSectionGroup GetSectionGroupInstance(SectionGroupInfo group) { ConfigurationSectionGroup gr = group.CreateInstance() as ConfigurationSectionGroup; if (gr != null) { gr.Initialize(this, group); } return(gr); }
public ConfigurationSectionGroup GetSectionGroup(string path) { string[] parts = path.Split('/'); ConfigurationSectionGroup group = SectionGroups [parts[0]]; for (int n = 1; group != null && n < parts.Length; n++) { group = group.SectionGroups [parts [n]]; } return(group); }
private void ForceGroupsRecursive(ConfigurationSectionGroup group) { foreach (ConfigurationSection section in group.Sections) { ConfigurationSection section1 = group.Sections[section.SectionInformation.Name]; } foreach (ConfigurationSectionGroup group2 in group.SectionGroups) { this.ForceGroupsRecursive(group.SectionGroups[group2.Name]); } }
// // Create the collection of all section groups in the section group. // internal ConfigurationSectionGroupCollection(MgmtConfigurationRecord configRecord, ConfigurationSectionGroup configSectionGroup) : base(StringComparer.Ordinal) { _configRecord = configRecord; _configSectionGroup = configSectionGroup; foreach (DictionaryEntry de in _configRecord.SectionGroupFactories) { FactoryId factoryId = (FactoryId) de.Value; if (factoryId.Group == _configSectionGroup.SectionGroupName) { BaseAdd(factoryId.Name, factoryId.Name); } } }
internal ConfigurationSectionCollection(MgmtConfigurationRecord configRecord, ConfigurationSectionGroup configSectionGroup) : base(StringComparer.Ordinal) { this._configRecord = configRecord; this._configSectionGroup = configSectionGroup; foreach (DictionaryEntry entry in this._configRecord.SectionFactories) { FactoryId id = (FactoryId) entry.Value; if (id.Group == this._configSectionGroup.SectionGroupName) { base.BaseAdd(id.Name, id.Name); } } }
internal ConfigurationSectionGroupCollection(MgmtConfigurationRecord configRecord, ConfigurationSectionGroup configSectionGroup) : base(StringComparer.Ordinal) { this._configRecord = configRecord; this._configSectionGroup = configSectionGroup; foreach (DictionaryEntry entry in this._configRecord.SectionGroupFactories) { FactoryId id = (FactoryId)entry.Value; if (id.Group == this._configSectionGroup.SectionGroupName) { base.BaseAdd(id.Name, id.Name); } } }
// Force all sections and section groups to be instantiated. private void ForceGroupsRecursive(ConfigurationSectionGroup group) { foreach (ConfigurationSection configSection in group.Sections) { // Force the section to be read into the cache _ = group.Sections[configSection.SectionInformation.Name]; } foreach (ConfigurationSectionGroup sectionGroup in group.SectionGroups) { ForceGroupsRecursive(group.SectionGroups[sectionGroup.Name]); } }
// // Create the collection of all sections in the section group. // internal ConfigurationSectionCollection(MgmtConfigurationRecord configRecord, ConfigurationSectionGroup configSectionGroup) : base(StringComparer.Ordinal) { _configRecord = configRecord; _configSectionGroup = configSectionGroup; foreach (DictionaryEntry de in _configRecord.SectionFactories) { FactoryId factoryId = (FactoryId)de.Value; if (factoryId.Group == _configSectionGroup.SectionGroupName) { BaseAdd(factoryId.Name, factoryId.Name); } } }
// Methods public void AddGroup(string groupName) { #region Contracts if (string.IsNullOrEmpty(groupName) == true) throw new ArgumentNullException(); #endregion // Require ReflectConfigurationSection existSection = _configuration.GetSection(groupName) as ReflectConfigurationSection; if (existSection != null) return; // Variables string[] sectionNameChain = groupName.Split('/'); ConfigurationSectionGroup parentSectionGroup = _configuration.RootSectionGroup; // Add for (int i = 0; i < sectionNameChain.Length; i++) { // SectionGroup if (i < sectionNameChain.Length - 1) { ConfigurationSectionGroup sectionGroup = parentSectionGroup.SectionGroups.Get(sectionNameChain[i]); if (sectionGroup == null) { sectionGroup = new ConfigurationSectionGroup(); parentSectionGroup.SectionGroups.Add(sectionNameChain[i], sectionGroup); } parentSectionGroup = sectionGroup; continue; } // Section if (i >= sectionNameChain.Length - 1) { ConfigurationSection section = parentSectionGroup.Sections.Get(sectionNameChain[i]); if (section == null) { section = new ReflectConfigurationSection(); parentSectionGroup.Sections.Add(sectionNameChain[i], section); } continue; } } // Save _configuration.Save(); }
public ConfigurationSectionGroup this [string name] { get { ConfigurationSectionGroup sec = BaseGet(name) as ConfigurationSectionGroup; if (sec == null) { SectionGroupInfo secData = group.Groups [name] as SectionGroupInfo; if (secData == null) { return(null); } sec = config.GetSectionGroupInstance(secData); BaseSet(name, sec); } return(sec); } }
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); } }
private static void PreloadConfigurationSectionGroup(ConfigurationSectionGroup sectionGroup) { if (null == sectionGroup) { return; } // Preload sections just by iterating. foreach (ConfigurationSection section in sectionGroup.Sections) { } // Load child section groups. foreach (ConfigurationSectionGroup childSectionGroup in sectionGroup.SectionGroups) { PreloadConfigurationSectionGroup(childSectionGroup); } }
public void CopyTo(ConfigurationSectionGroup[] array, int index) { if (array == null) { throw new ArgumentNullException("array"); } int count = this.Count; if (array.Length < (count + index)) { throw new ArgumentOutOfRangeException("index"); } int num2 = 0; for (int i = index; num2 < count; i++) { array[i] = this.Get(num2); num2++; } }
private void LoadProperies(ExeConfigurationFileMap exeMap, SettingsPropertyCollection collection, ConfigurationUserLevel level, string sectionGroupName, bool allowOverwrite) { Configuration config = ConfigurationManager.OpenMappedExeConfiguration(exeMap, level); ConfigurationSectionGroup sectionGroup = config.GetSectionGroup(sectionGroupName); if (sectionGroup != null) { foreach (ConfigurationSection configSection in sectionGroup.Sections) { ClientSettingsSection clientSection = configSection as ClientSettingsSection; if (clientSection != null) { foreach (SettingElement element in clientSection.Settings) { LoadPropertyValue(collection, element, allowOverwrite); } } } } }
public void Load() { do { try { _config = ConfigurationManager.OpenMappedExeConfiguration(_map, ConfigurationUserLevel.PerUserRoaming); _group = _config.SectionGroups["libSnesDotNet"]; if (_group != null) { _group.Validate(); } else { _group = new ConfigurationSectionGroup(); _config.SectionGroups.Add("libSnesDotNet", _group); } } catch { var result = System.Windows.MessageBox.Show("Configuration is invalid. Restore defaults instead?", "Error", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Error); if (result == System.Windows.MessageBoxResult.Yes) { _group = null; File.Delete(_map.RoamingUserConfigFilename); } else { return; } } } while (_group == null); if (UI == null) { UI = new UISection(); } if (Input == null) { Input = new InputSection(); } }
public ConfigurationSection GetSection(string path) { string[] parts = path.Split('/'); if (parts.Length == 1) { return(Sections [parts[0]]); } ConfigurationSectionGroup group = SectionGroups [parts[0]]; for (int n = 1; group != null && n < parts.Length - 1; n++) { group = group.SectionGroups [parts [n]]; } if (group != null) { return(group.Sections [parts [parts.Length - 1]]); } else { return(null); } }
private static bool StoreSettings ( ConfigurationSectionGroup sectionGroup, string sectionName, IEnumerable<PropertyInfo> properties, IDictionary<string, string> newValues ) { bool newSection = false; ConfigurationSection section = sectionGroup.Sections[sectionName]; if (section == null) { newSection = true; section = AddDefaultSection(sectionGroup, sectionName, properties); } bool modified = UpdateSection(CastToClientSection(section), properties, newValues); if (newSection && !modified) sectionGroup.Sections.Remove(sectionName); return modified; }
public void Add(string name, ConfigurationSectionGroup sectionGroup) { VerifyIsAttachedToConfigRecord(); _configRecord.AddConfigurationSectionGroup(_configSectionGroup.SectionGroupName, name, sectionGroup); BaseAdd(name, name); }
private static ClientSettingsSection AddDefaultSection(ConfigurationSectionGroup sectionGroup, string sectionName, IEnumerable<PropertyInfo> properties) { ClientSettingsSection newClientSection = CreateDefaultSection(properties); sectionGroup.Sections.Add(sectionName, newClientSection); if (sectionGroup.Name == ConfigurationSectionGroupPath.UserSettings.ToString()) newClientSection.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser; return newClientSection; }
public IndexingActualConfiguration() { _indexingGroup = ConfigurationManager .OpenExeConfiguration(ConfigurationUserLevel.None) .SectionGroups["indexingSettings"]; }
public ConfigurationSectionGroupWrapper(ConfigurationSectionGroup sectionGroup) { this.sectionGroup = sectionGroup; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the section <paramref name="sectionName"/> in the section group "userSettings". /// </summary> /// ------------------------------------------------------------------------------------ private static ClientSettingsSection GetSection(Configuration config, string sectionName, string sectionGroup = "userSettings") { var userSettingsGroup = config.GetSectionGroup(sectionGroup); if (userSettingsGroup == null) { userSettingsGroup = new ConfigurationSectionGroup(); config.SectionGroups.Add(sectionGroup, userSettingsGroup); } var section = userSettingsGroup.Sections[sectionName] as ClientSettingsSection; if (section == null) { section = new ClientSettingsSection(); userSettingsGroup.Sections.Add(sectionName, section); } return section; }
private string GetUpdatedSectionGroupDeclarationXml(FactoryRecord factoryRecord, ConfigurationSectionGroup configSectionGroup) { if ((TargetFramework != null) && !configSectionGroup.ShouldSerializeSectionGroupInTargetVersion(TargetFramework)) return null; StringBuilder sb = new StringBuilder(); sb.Append('<'); sb.Append(KeywordSectiongroup); sb.Append(' '); AppendAttribute(sb, KeywordSectiongroupName, configSectionGroup.Name); string type = configSectionGroup.Type ?? factoryRecord.FactoryTypeName; if (TypeStringTransformerIsSet) type = TypeStringTransformer(type); AppendAttribute(sb, KeywordSectiongroupType, type); sb.Append('>'); return sb.ToString(); }
private void CreateAllSectionName(ref List<string> sectionNameList, ConfigurationSectionGroup sectionGroup) { #region Contracts if (sectionGroup == null) throw new ArgumentNullException(); #endregion // Section foreach (ConfigurationSection childSection in sectionGroup.Sections) { ReflectConfigurationSection section = childSection as ReflectConfigurationSection; if (section != null) { sectionNameList.Add(section.SectionInformation.SectionName); } } // SectionGroup foreach (ConfigurationSectionGroup childSectionGroup in sectionGroup.SectionGroups) { this.CreateAllSectionName(ref sectionNameList, childSectionGroup); } }
public void Add(string name, ConfigurationSectionGroup sectionGroup) { }
public ConfigurationSectionGroup GetSectionGroup(string sectionGroupName) { ConfigurationSectionGroup sectionGroup = _configRecord.GetSectionGroup(sectionGroupName); return(sectionGroup); }
// Force all sections and section groups to be instantiated. private void ForceGroupsRecursive(ConfigurationSectionGroup group) { foreach (ConfigurationSection configSection in group.Sections) { // Force the section to be read into the cache ConfigurationSection section = group.Sections[configSection.SectionInformation.Name]; } foreach (ConfigurationSectionGroup sectionGroup in group.SectionGroups) ForceGroupsRecursive(group.SectionGroups[sectionGroup.Name]); }
public void CopyTo(ConfigurationSectionGroup[] array, int index) { }
public void CopyTo (ConfigurationSectionGroup [] array, int index) { for (int n=0; n<group.Groups.Count; n++) array [n + index] = this [n]; }
///// <summary> ///// 从配置文件中加载SAP的连接配置。 ///// </summary> ///// <returns></returns> //public static RfcDestinationCollection LoadSAPAllConfig() //{ // //if (SAPINT.SAPConfigList.loadDefaultSystemListFromSAPLogonIniFile()) // //{ // // // MessageBox.Show("成功加载SAP GUI配置文件!"); // //} // try // { // RfcGeneralConfiguration configuration2 = getSAPGeneralConfiguration(); // RfcDestinationCollection clientsSetting = getClientSettings(); // if (clientsSetting != null) // { // return clientsSetting; // // RfcDestinationManager.RegisterDestinationConfiguration(new DefaultDestinationConfiguration(clientsSetting)); // } // RfcServerCollection severSetting = getServerSettings(); // if (severSetting != null) // { // // RfcServerManager.RegisterServerConfiguration(new DefaultServerConfiguration(severSetting)); // } // // RfcServerManager.loadedFromParameterFile = true; // } // catch (Exception) // { // throw new Exception("无法从配置文件加载"); // } //} /// <summary> /// 加载根节点 /// </summary> private static void getSapSectionGroup() { System.Configuration.Configuration configuration = null; // configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); configuration = SAPGlobalSettings.config; sectionGroup = configuration.GetSectionGroup("SAPINT"); if (sectionGroup==null) { throw new Exception("无法从配置文件加载SAP配置!!"); } }
// // Copy all section groups to an array. // public void CopyTo(ConfigurationSectionGroup[] array, int index) { if (array == null) { throw new ArgumentNullException("array"); } int c = Count; if (array.Length < c + index) { throw new ArgumentOutOfRangeException("index"); } for (int i = 0, j = index; i < c; i++, j++) { array[j] = Get(i); } }
public void Add(string name, ConfigurationSectionGroup sectionGroup) { config.CreateSectionGroup(group, name, sectionGroup); }
// Returns the ConfigurationSectionGroup of the configKey. // The ConfigurationSectionGroup is created if it doesn't exist. // This method only returns null if a FactoryRecord does not exist for the // desired configKey. internal ConfigurationSectionGroup GetSectionGroup(string configKey) { ConfigurationSectionGroup configSectionGroup = LookupSectionGroup(configKey); if (configSectionGroup == null) { BaseConfigurationRecord configRecord; FactoryRecord factoryRecord = FindFactoryRecord(configKey, false, out configRecord); if (factoryRecord == null) { return null; } if (!factoryRecord.IsGroup) { throw ExceptionUtil.ParameterInvalid("sectionGroupName"); } if (factoryRecord.FactoryTypeName == null) { // // If no type is defined for the section group, return a base ConfigurationSectionGroup. // For example: // <configSections> // <sectionGroup name="mySectionGroup" /> // </configSections> // configSectionGroup = new ConfigurationSectionGroup(); } else { // // Create the section group of the desired type. // For example: // <configSections> // <sectionGroup name="mySectionGroup" type="MySectionGroupType, acme" /> // </configSections> // ConstructorInfo ctor = EnsureSectionGroupFactory(factoryRecord); try { configSectionGroup = (ConfigurationSectionGroup) TypeUtil.InvokeCtorWithReflectionPermission(ctor); } catch (Exception e) { throw new ConfigurationErrorsException(SR.GetString(SR.Config_exception_creating_section_handler, factoryRecord.ConfigKey), e, factoryRecord); } } configSectionGroup.AttachToConfigurationRecord(this, factoryRecord); // Add it to the collection SectionGroups[configKey] = configSectionGroup; } return configSectionGroup; }
// // Add a new configuration section group to this config file. // // Called from ConfigurationSectionGroupCollection.Add(). // Note this method DOES NOT update the associated ConfigurationSectionGroupCollection. // internal void AddConfigurationSectionGroup(string group, string name, ConfigurationSectionGroup configSectionGroup) { // <location> tags can't have a <configSections> declaration. if (IsLocationConfig) { throw new InvalidOperationException(SR.GetString(SR.Config_add_configurationsectiongroup_in_location_config)); } // Validate name argument. VerifySectionName(name, null, false); // Validate configSectionGroup argument. if (configSectionGroup == null) { throw ExceptionUtil.ParameterInvalid("name"); } // A section group can only belong to one section group collection. if (configSectionGroup.Attached) { throw new InvalidOperationException(SR.GetString(SR.Config_add_configurationsectiongroup_already_added)); } string configKey = BaseConfigurationRecord.CombineConfigKey(group, name); // Do not add if the section group already exists, even if it is of a different type. FactoryRecord factoryRecord = FindFactoryRecord(configKey, true); if (factoryRecord != null) { throw new ArgumentException(SR.GetString(SR.Config_add_configurationsectiongroup_already_exists)); } // Add to list of all section groups. if (_sectionGroupFactories != null) { _sectionGroupFactories.Add(configKey, new FactoryId(configKey, group, name)); } // Get the type name - if it is not specified explicitly, get it from the type of the object. string typeName = configSectionGroup.Type; if (typeName == null) { typeName = Host.GetConfigTypeName(configSectionGroup.GetType()); } // Create a factory record and add it to the collection of factory records. factoryRecord = new FactoryRecord(configKey, group, name, typeName, ConfigStreamInfo.StreamName, -1); EnsureFactories()[configKey] = factoryRecord; // Add it to list of evaluated configuration section groups. SectionGroups[configKey] = configSectionGroup; // Remove it from RemovedSectionGroups if it was previously removed. if (_removedSectionGroups != null) { _removedSectionGroups.Remove(configKey); } // Attach to the configuration record. configSectionGroup.AttachToConfigurationRecord(this, factoryRecord); }
public abstract void VisitConfigurationSectionGroup(ConfigurationSectionGroup group);
/// <summary> /// Registers the Http Handler in configuration. /// </summary> public virtual void RegisterHandlerInConfiguration() { // supported only at design time if (!this.DesignMode) { return; } // no point to add if http handler name or type is null if (string.IsNullOrEmpty(this.HttpHandlerName) || (null == this.HttpHandlerType)) { return; } // get the Web application configuration IWebApplication webApplication = (IWebApplication)this.Site.GetService(typeof(IWebApplication)); if (null != webApplication) { global::System.Configuration.Configuration webConfig = webApplication.OpenWebConfiguration(false); if (null == webConfig) { throw new ConfigurationErrorsException("web.config file not found to register the http handler."); } // get the <system.web> section ConfigurationSectionGroup systemWeb = webConfig.GetSectionGroup("system.web"); if (null == systemWeb) { systemWeb = new ConfigurationSectionGroup(); webConfig.SectionGroups.Add("system.web", systemWeb); } // get the <httpHandlers> section HttpHandlersSection httpHandlersSection = (HttpHandlersSection)systemWeb.Sections.Get("httpHandlers"); if (null == httpHandlersSection) { httpHandlersSection = new HttpHandlersSection(); systemWeb.Sections.Add("httpHandlers", httpHandlersSection); } // add the image handler httpHandlersSection.Handlers.Add(new HttpHandlerAction(this.HttpHandlerName, this.HttpHandlerType.AssemblyQualifiedName, "*")); // save the new web config webConfig.Save(); } }
private void AddSectionToSectionGroup(ConfigurationSectionGroup sectionGroup, string name, ConfigurationSection section) { if (sectionGroup.Sections[name] == null) { var configPath = string.Concat("config", Path.DirectorySeparatorChar, "imageprocessor", Path.DirectorySeparatorChar, name, ".config"); var xmlPath = IOHelper.MapPath(string.Concat("~/", configPath)); string xml; using (var reader = new StreamReader(xmlPath)) { xml = reader.ReadToEnd(); } section.SectionInformation.SetRawXml(xml); section.SectionInformation.ConfigSource = configPath; sectionGroup.Sections.Add(name, section); } }
/// <summary> /// Checks to determine if the group contains the section name requested. /// </summary> /// <param name="group"></param> /// <param name="name"></param> /// <returns></returns> private static bool SectionGroupMatch(ConfigurationSectionGroup group, string name) { foreach (ConfigurationSection section in group.Sections) if (section.SectionInformation.SectionName == name) return true; foreach (ConfigurationSectionGroup child in group.SectionGroups) if (SectionGroupMatch(child, name)) return true; return false; }
// // Public methods // // // Add a new section group to the collection. This will result in a new declaration and definition. // // It is an error if the section already exists. // public void Add(string name, ConfigurationSectionGroup sectionGroup) { VerifyIsAttachedToConfigRecord(); _configRecord.AddConfigurationSectionGroup(_configSectionGroup.SectionGroupName, name, sectionGroup); BaseAdd(name, name); }
internal void CreateSectionGroup (SectionGroupInfo parentGroup, string name, ConfigurationSectionGroup sec) { if (parentGroup.HasChild (name)) throw new ConfigurationErrorsException ("Cannot add a ConfigurationSectionGroup. A section or section group already exists with the name '" + name + "'"); if (sec.Type == null) sec.Type = system.Host.GetConfigTypeName (sec.GetType ()); sec.SetName (name); SectionGroupInfo section = new SectionGroupInfo (name, sec.Type); section.StreamName = streamName; section.ConfigHost = system.Host; parentGroup.AddChild (section); elementData [section] = sec; sec.Initialize (this, section); }
private string GetUpdatedSectionGroupDeclarationXml(FactoryRecord factoryRecord, ConfigurationSectionGroup configSectionGroup) { if (TargetFramework != null && !configSectionGroup.ShouldSerializeSectionGroupInTargetVersion(TargetFramework)) return null; StringBuilder sb = new StringBuilder(); sb.Append('<'); sb.Append(KEYWORD_SECTIONGROUP); sb.Append(' '); AppendAttribute(sb, KEYWORD_SECTIONGROUP_NAME, configSectionGroup.Name); string type = (configSectionGroup.Type != null) ? configSectionGroup.Type : factoryRecord.FactoryTypeName; if (TypeStringTransformerIsSet) type = TypeStringTransformer(type); AppendAttribute(sb, KEYWORD_SECTIONGROUP_TYPE, type); sb.Append('>'); return sb.ToString(); }