public DefaultConfigFile (string name, string fileName, FeatureTarget target, Section sections)
		{
			this.name = name;
			this.fileName = fileName;
			this.target = target;
			this.sections = sections;
		}
示例#2
0
		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;
		}
示例#3
0
		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);
		}
示例#6
0
		public ConfigBlockBlock (string name, Section requires, string contents)
		{
			this.name = name;
			this.requires = requires;
			this.contents = contents;
		}
示例#7
0
		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;
		}
示例#8
0
		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 ());
		}