internal void CreateSection (SectionGroupInfo group, string name, ConfigurationSection sec)
{
if (group.HasChild (name))
throw new ConfigurationException ("Cannot add a ConfigurationSection. A section or section group already exists with the name '" + name + "'");
if (!HasFile && !sec.SectionInformation.AllowLocation)
throw new ConfigurationErrorsException ("The configuration section <" + name + "> cannot be defined inside a <location> element.");
if (!system.Host.IsDefinitionAllowed (configPath, sec.SectionInformation.AllowDefinition, sec.SectionInformation.AllowExeDefinition)) {
object ctx = sec.SectionInformation.AllowExeDefinition != ConfigurationAllowExeDefinition.MachineToApplication ? (object) sec.SectionInformation.AllowExeDefinition : (object) sec.SectionInformation.AllowDefinition;
throw new ConfigurationErrorsException ("The section <" + name + "> can't be defined in this configuration file (the allowed definition context is '" + ctx + "').");
}
if (sec.SectionInformation.Type == null)
sec.SectionInformation.Type = system.Host.GetConfigTypeName (sec.GetType ());
SectionInfo section = new SectionInfo (name, sec.SectionInformation);
section.StreamName = streamName;
section.ConfigHost = system.Host;
group.AddChild (section);
elementData [section] = sec;
}