public DefaultConfigFile (string name, string fileName, FeatureTarget target, Section sections) { this.name = name; this.fileName = fileName; this.target = target; this.sections = sections; }
public void StoreConfiguration () { AssertStorage (); ConfigBlockBlock block = new ConfigBlockBlock (name, requirements, contents); if (storage.ContainsKey (name)) storage [name] = block; // allow for silent override else storage.Add (name, block); // Prepare to handle more sections requirements = new Section (); contents = null; }
public void ReadConfiguration (XPathNavigator nav) { name = Helpers.GetRequiredNonEmptyAttribute (nav, "name"); requirements = new Section (); Helpers.BuildSectionTree (nav.Select ("requires/section[string-length(@name) > 0]"), requirements); XPathNodeIterator iter = nav.Select ("contents/text()"); StringBuilder sb = new StringBuilder (); while (iter.MoveNext ()) sb.Append (iter.Current.Value); if (sb.Length > 0) contents = sb.ToString (); }
public void StoreConfiguration () { AssertStorage (); DefaultConfigFile dcf = new DefaultConfigFile (name, fileName, target, sections); if (storage.ContainsKey (name)) storage [name] = dcf; else storage.Add (name, dcf); name = null; fileName = null; sections = null; }
public void ReadConfiguration (XPathNavigator nav) { name = Helpers.GetRequiredNonEmptyAttribute (nav, "name"); target = Helpers.ConvertEnum <FeatureTarget> (Helpers.GetRequiredNonEmptyAttribute (nav, "target"), "target"); fileName = Helpers.GetOptionalAttribute (nav, "fileName"); if (String.IsNullOrEmpty (fileName)) fileName = name; sections = new Section (); Helpers.BuildSectionTree (nav.Select ("./section[string-length (@name) > 0]"), sections); }
public ConfigBlockBlock (string name, Section requires, string contents) { this.name = name; this.requires = requires; this.contents = contents; }
void ProcessSections (XmlDocument doc, XmlNode parent, string topPath, Section top, IDefaultContainer[] defaults, string blockName, ref XmlNode attachPoint) { List <Section> topChildren, children; if (top == null || (topChildren = top.Children) == null) return; XmlNode node; string curPath; foreach (Section s in topChildren) { curPath = String.Format ("{0}/{1}", topPath, s.Name); node = FindNodeOrAddDefault (doc, s.DefaultBlockName, curPath, defaults); if (node != null && s.AttachPoint) { if (attachPoint != null) throw new ApplicationException ( String.Format ("Config block '{0}' has more than one attachment point", blockName)); attachPoint = node; } parent.AppendChild (node); if ((children = s.Children) != null && children.Count > 0) ProcessSections (doc, node, curPath, s, defaults, blockName, ref attachPoint); } return; }
XmlNode FindDefaultAttachPoint (XmlDocument doc, Section req) { List <Section> children = req.Children; if (children == null || children.Count == 0) return null; StringBuilder sb = new StringBuilder ("/"); BuildPathToLastRequirement (sb, children); return doc.SelectSingleNode (sb.ToString ()); }