コード例 #1
0
ファイル: Utils.CLR.cs プロジェクト: jdluzen/Phalanger
		/// <summary>
		/// Parses a configuration contained in the specified node.
		/// The section is expected to follow Phalanger configuration schema.
		/// </summary>
		/// <param name="node">The node to parse.</param>
		/// <param name="context">The configuration context or a <B>null</B> reference.</param>
		/// <param name="section1">The first section to fill in.</param>
		/// <param name="section2">The second section to fill in if the first doesn't contain the option. Can be <B>null</B>.</param>
		/// <param name="section3">The third section to fill in if neither the first not the second contain the option. Can be <B>null</B>.</param>
		/// <remarks>
		/// The following node type is allowed to be contained in the <paramref name="node"/>:
		/// <code>
		///   &lt;set name="{string}" value="{string}" [allowOverride="{bool}"] /&gt;
		///   &lt;set name="{string}" [allowOverride="{bool}"] &gt; ... &lt;/set&gt;
		/// </code>                                          
		/// </remarks>
		public static void ParseNameValueList(XmlNode/*!*/ node, PhpConfigurationContext context,
			IPhpConfigurationSection/*!*/ section1, IPhpConfigurationSection section2, IPhpConfigurationSection section3)
		{
			if (node == null)
				throw new ArgumentNullException("node");
			if (section1 == null)
				throw new ArgumentNullException("section1");

			foreach (XmlNode child in node.ChildNodes)
			{
				if (child.Name == "set")
				{
					string name = MandatoryAttribute(child, "name");
					string allow_override = OptionalAttribute(child, "allowOverride");
					string/*!*/value = OptionalAttribute(child, "value") ?? string.Empty;

					// checks for sealed nodes:
					if (context != null)
					{
						if (context.IsOptionSealed(name))
							throw new ConfigurationErrorsException(CoreResources.GetString("cannot_modify_option", context.GetSealingLocation(name)), child);

						if (allow_override != null && context.IsSubApplicationConfig())
							throw new ConfigurationErrorsException(CoreResources.GetString("invalid_attribute_location", context.VirtualPath, "allowOverride"), node);

						if (allow_override == "false")
							context.SealOption(name);
					}

					// processes the option:                             					
					if ((/*section1 == null ||*/ !section1.Parse(name, value, child)) &&
						(section2 == null || !section2.Parse(name, value, child)) &&
						(section3 == null || !section3.Parse(name, value, child)))
						throw new InvalidAttributeValueException(child, "name");
				}
				else if (child.NodeType == XmlNodeType.Element)
				{
					throw new InvalidNodeException(child);
				}
			}
		}
コード例 #2
0
ファイル: Utils.CLR.cs プロジェクト: jdluzen/Phalanger
		/// <summary>
		/// Parses a configuration contained in the specified node.
		/// The section is expected to follow Phalanger configuration schema.
		/// </summary>
		/// <param name="node">The node to parse.</param>
		/// <param name="context">The configuration context or a <B>null</B> reference.</param>
		/// <param name="section1">The first section to fill in.</param>
		/// <param name="section2">The second section to fill in if the first doesn't contain the option.</param>
		public static void ParseNameValueList(XmlNode/*!*/ node, PhpConfigurationContext context,
			IPhpConfigurationSection/*!*/ section1, IPhpConfigurationSection section2)
		{
			ParseNameValueList(node, context, section1, section2, null);
		}