/// <summary> /// Parses a configuration section belonging to the MySql library. /// </summary> /// <param name="result">A configuration context.</param> /// <param name="context">The context of the configuration created by Phalanger Core.</param> /// <param name="section">A XML node containing the configuration or its part.</param> /// <returns>Updated configuration context.</returns> protected override ConfigContextBase ParseConfig(ConfigContextBase result, PhpConfigurationContext context, XmlNode section) { // parses XML tree: ConfigUtils.ParseNameValueList(section, context, (PDOLocalConfig)result.Local, (PDOGlobalConfig)result.Global); return result; }
private PhpConfigurationContext Create(PhpConfigurationContext parent, HttpConfigurationContext context, XmlNode/*!*/ section) { PhpConfigurationContext result; // determines virtual path to the .config file (null means Machine.config or not applicable): string virtual_path = (context != null) ? context.VirtualPath : null; Debug.WriteLine("CONFIG", "Parsing configuration in '{0}'. Parent config is '{1}'", virtual_path ?? "Machine.config", (parent != null) ? parent.VirtualPath : "null"); // initialization: if (parent != null) { result = new PhpConfigurationContext(applicationContext, virtual_path, parent); } else { result = new PhpConfigurationContext(applicationContext, virtual_path); } GlobalConfiguration global = result.Global; LocalConfiguration local = result.Local; // configuration loading is assumed to be synchronized: ApplicationConfiguration app = Configuration.application; // same with script libraries - these need to be parsed after <sourceRoot> XmlNode node_ScriptLibrary = null; // determine configuration modification time: result.Global.LastConfigurationModificationTime = ConfigUtils.GetConfigModificationTime(section, result.Global.LastConfigurationModificationTime); // parses XML tree: foreach (XmlNode node in section.ChildNodes) { if (node.NodeType == XmlNodeType.Element) { switch (node.Name) { case NodePaths: // options can be specified only in application root config and above: result.EnsureApplicationConfig(node); ConfigUtils.ParseNameValueList(node, result, app.Paths); break; case NodeClassLibrary: // libraries can be loaded only in application root config and above: result.EnsureApplicationConfig(node); // parses and loads libraries contained in the list (lazy): ConfigUtils.ParseLibraryAssemblyList( node, result.librariesList, app.Paths.ExtWrappers, app.Paths.Libraries); break; case NodeScriptLibrary: // script libraries can be loaded only in application root config and above: result.EnsureApplicationConfig(node); node_ScriptLibrary = node; break; case NodeCompiler: // options can be specified only in application root: result.EnsureApplicationConfig(node); ConfigUtils.ParseNameValueList(node, result, app.Compiler); break; case NodeGlobalization: // options can be specified only in application root: result.EnsureApplicationConfig(node); ConfigUtils.ParseNameValueList(node, result, app.Globalization); break; case NodeOutputControl: ConfigUtils.ParseNameValueList(node, result, local.OutputControl); break; case NodeRequestControl: ConfigUtils.ParseNameValueList(node, result, local.RequestControl); break; case NodeErrorControl: ConfigUtils.ParseNameValueList(node, result, local.ErrorControl); break; case NodeSessionControl: ConfigUtils.ParseNameValueList(node, result, local.Session); break; case NodeFileSystem: ConfigUtils.ParseNameValueList(node, result, local.FileSystem); break; case NodeAssertion: ConfigUtils.ParseNameValueList(node, result, local.Assertion); break; case NodeVariables: ConfigUtils.ParseNameValueList(node, result, local.Variables, global.GlobalVariables); break; case NodePostedFiles: ConfigUtils.ParseNameValueList(node, result, global.PostedFiles); break; case NodeSafeMode: ConfigUtils.ParseNameValueList(node, result, global.SafeMode); break; default: // processes library section: result.librariesList.AddSection(node); break; } } } // and script library after that if (node_ScriptLibrary != null) { ConfigUtils.ParseScriptLibraryAssemblyList(node_ScriptLibrary, applicationContext.ScriptLibraryDatabase); } return result; }
/// <summary> /// Makes a copy (child) of this instance (parent) deeply copying the confgiuration fields. /// </summary> internal PhpConfigurationContext(ApplicationContext/*!*/ applicationContext, string virtualPath, PhpConfigurationContext parent) { Debug.Assert(applicationContext != null); this.virtualPath = virtualPath; this.applicationContext = applicationContext; // section tables are shared: this.sections = parent.sections; this.sealedSections = parent.sealedSections; this.librariesList = parent.librariesList; // configuration records are copied: this.local = (LocalConfiguration)parent.local.DeepCopy(); this.global = (GlobalConfiguration)parent.global.DeepCopy(); }
/// <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> /// <set name="{string}" value="{string}" [allowOverride="{bool}"] /> /// <set name="{string}" [allowOverride="{bool}"] > ... </set> /// </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); } } }
/// <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); }
/// <summary> /// Parses a configuration section belonging to the library. /// </summary> /// <param name="result">A library configuration context.</param> /// <param name="context">The context of the configuration created by Phalanger Core.</param> /// <param name="section">A XML node containing the configuration or its part.</param> /// <returns>Updated library configuration context.</returns> protected override ConfigContextBase ParseConfig(ConfigContextBase result, PhpConfigurationContext context, XmlNode section) { LibraryConfiguration local = (LibraryConfiguration)result.Local; // parses XML tree: foreach (XmlNode node in section.ChildNodes) { if (node.NodeType == XmlNodeType.Element) { switch (node.Name) { case "mailer": ConfigUtils.ParseNameValueList(node, context, local.Mailer); break; case "highlighting": ConfigUtils.ParseNameValueList(node, context, local.Highlighting); break; case "session": // allowed only in web application configuration: if (HttpContext.Current == null) throw new ConfigurationErrorsException(CoreResources.GetString("web_only_option"), node); ConfigUtils.ParseNameValueList(node, context, local.Session); break; case "date": ConfigUtils.ParseNameValueList(node, context, local.Date); break; case "serialization": ConfigUtils.ParseNameValueList(node, context, local.Serialization); break; default: throw new ConfigUtils.InvalidNodeException(node); } } } return result; }
/// <summary> /// Parses a configuration section belonging to the XmlDom library. /// </summary> /// <param name="result">A configuration context.</param> /// <param name="context">The context of the configuration created by Phalanger Core.</param> /// <param name="section">A XML node containing the configuration or its part.</param> /// <returns>Updated configuration context.</returns> protected override ConfigContextBase ParseConfig(ConfigContextBase result, PhpConfigurationContext context, XmlNode section) { return result; }
/// <summary> /// Parses a configuration section belonging to the library. /// </summary> /// <param name="userContext"> /// User specified configuration context. Contains a <B>null</B> reference if the method is called for the first time /// or an instance of the user configuration type partially filled with configuration values which has /// been already processed. /// </param> /// <param name="context">The Core configuration context.</param> /// <param name="section">XML node containing the configuration or its part.</param> /// <returns> /// The library configuration context which is is passed to the next iteration of the method if any. /// </returns> /// <remarks> /// The method is called for each configuration file and each XML node containing configuration of the library /// as they are processed by .NET configuration loader. Note that the method may not be called at all. /// </remarks> internal protected abstract ConfigContextBase ParseConfig(ConfigContextBase userContext, PhpConfigurationContext context, XmlNode section);
internal protected override ConfigContextBase ParseConfig(ConfigContextBase userContext, PhpConfigurationContext context, System.Xml.XmlNode section) { return null; }