internal class SectionInfo: ConfigInfo
{
bool allowLocation = true;
- bool? requirePermission = true;
+ bool requirePermission = true;
+ bool restartOnExternalChanges;
ConfigurationAllowDefinition allowDefinition = ConfigurationAllowDefinition.Everywhere;
ConfigurationAllowExeDefinition allowExeDefinition = ConfigurationAllowExeDefinition.MachineToApplication;
this.allowDefinition = info.AllowDefinition;
this.allowExeDefinition = info.AllowExeDefinition;
this.requirePermission = info.RequirePermission;
+ this.restartOnExternalChanges = info.RestartOnExternalChanges;
}
public override object CreateInstance ()
sec.SectionInformation.AllowLocation = allowLocation;
sec.SectionInformation.AllowDefinition = allowDefinition;
sec.SectionInformation.AllowExeDefinition = allowExeDefinition;
- if (requirePermission != null)
- sec.SectionInformation.RequirePermission = requirePermission.Value;
+ sec.SectionInformation.RequirePermission = requirePermission;
+ sec.SectionInformation.RestartOnExternalChanges = restartOnExternalChanges;
sec.SectionInformation.SetName (Name);
}
return ob;
return StreamName == cfg.FileName;
}
- public override void ReadConfig (Configuration cfg, string streamName, XmlTextReader reader)
+ public override void ReadConfig (Configuration cfg, string streamName, XmlReader reader)
{
StreamName = streamName;
ConfigHost = cfg.ConfigHost;
requirePermission = reqPermValue;
break;
+ case "restartOnExternalChanges":
+ string restart = reader.Value;
+ bool restartValue = (restart == "true");
+ if (!restartValue && restart != "false")
+ ThrowException ("Invalid attribute value", reader);
+ restartOnExternalChanges = restartValue;
+ break;
+
default:
ThrowException (String.Format ("Unrecognized attribute: {0}", reader.Name), reader);
break;
writer.WriteAttributeString ("allowDefinition", allowDefinition.ToString ());
if (allowExeDefinition != ConfigurationAllowExeDefinition.MachineToApplication)
writer.WriteAttributeString ("allowExeDefinition", allowExeDefinition.ToString ());
- if (requirePermission != null)
- writer.WriteAttributeString ("requirePermission", requirePermission.Value ? "true" : "false");
+ if (!requirePermission)
+ writer.WriteAttributeString ("requirePermission", "false");
writer.WriteEndElement ();
}
- public override void ReadData (Configuration config, XmlTextReader reader, bool overrideAllowed)
+ public override void ReadData (Configuration config, XmlReader reader, bool overrideAllowed)
{
if (!config.HasFile && !allowLocation)
throw new ConfigurationErrorsException ("The configuration section <" + Name + "> cannot be defined inside a <location> element.", reader);
ConfigurationSection parentSection = config.Parent != null ? config.Parent.GetSectionInstance (this, false) : null;
xml = section.SerializeSection (parentSection, Name, mode);
+ string externalDataXml = section.ExternalDataXml;
+ string filePath = config.FilePath;
+
+ if (!String.IsNullOrEmpty (filePath) && !String.IsNullOrEmpty (externalDataXml)) {
+ string path = Path.Combine (Path.GetDirectoryName (filePath), section.SectionInformation.ConfigSource);
+ using (StreamWriter sw = new StreamWriter (path)) {
+ sw.Write (externalDataXml);
+ }
+ }
+
if (section.SectionInformation.IsProtected) {
StringBuilder sb = new StringBuilder ();
sb.AppendFormat ("<{0} configProtectionProvider=\"{1}\">\n",
tr.Close ();*/
}
}
+
+ internal override void Merge (ConfigInfo data)
+ {}
}
}