/// <summary> /// The factory method that returns the appropriate parser for the given configuration file. /// </summary> /// <param name="p_xmlConfig">The configuration file for which to return a parser.</param> /// <param name="p_fomodMod">The mod whose configuration file is being parsed.</param> /// <param name="p_dsmSate">The state of the install.</param> /// <returns>The appropriate parser for the given configuration file.</returns> /// <exception cref="ParserException">Thrown if no parser is found for the given configuration file.</exception> public static Parser GetParser(XmlDocument p_xmlConfig, fomod p_fomodMod, DependencyStateManager p_dsmSate) { var strConfigVersion = "1.0"; var strSchemaName = p_xmlConfig.SelectSingleNode("config").Attributes["xsi:noNamespaceSchemaLocation"].InnerText.ToLowerInvariant(); var intStartPos = strSchemaName.LastIndexOf("modconfig") + 9; if (intStartPos > 8) { var intLength = strSchemaName.Length - intStartPos - 4; if (intLength > 0) { strConfigVersion = strSchemaName.Substring(intStartPos, intLength); } } var pexParserExtension = Program.GameMode.GetParserExtension(strConfigVersion); switch (strConfigVersion) { case "1.0": return new Parser10(p_xmlConfig, p_fomodMod, p_dsmSate, pexParserExtension); case "2.0": return new Parser20(p_xmlConfig, p_fomodMod, p_dsmSate, pexParserExtension); case "3.0": return new Parser30(p_xmlConfig, p_fomodMod, p_dsmSate, pexParserExtension); case "4.0": return new Parser40(p_xmlConfig, p_fomodMod, p_dsmSate, pexParserExtension); case "5.0": return new Parser50(p_xmlConfig, p_fomodMod, p_dsmSate, pexParserExtension); } throw new ParserException("Unrecognized Module Configuration version (" + strConfigVersion + "). Perhaps a newer version of FOMM is required."); }
/// <summary> /// A simple constructor that initializes teh object with the given values. /// </summary> /// <param name="p_xmlConfig">The modules configuration file.</param> /// <param name="p_fomodMod">The mod whose configuration file we are parsing.</param> /// <param name="p_dsmSate">The state of the install.</param> /// <param name="p_pexParserExtension">The parser extension that provides game-specific config file parsing.</param> public Parser(XmlDocument p_xmlConfig, fomod p_fomodMod, DependencyStateManager p_dsmSate, ParserExtension p_pexParserExtension) { m_pexParserExtension = p_pexParserExtension; m_xmlConfig = p_xmlConfig; m_fomodMod = p_fomodMod; m_dsmSate = p_dsmSate; validateModuleConfig(); }
/// <summary> /// A simple constructor that initializes teh object with the given values. /// </summary> /// <param name="p_xmlConfig">The modules configuration file.</param> /// <param name="p_fomodMod">The mod whose configuration file we are parsing.</param> /// <param name="p_dsmSate">The state of the install.</param> /// <param name="p_pexParserExtension">The parser extension that provides game-specific config file parsing.</param> public Parser(XmlDocument p_xmlConfig, fomod p_fomodMod, DependencyStateManager p_dsmSate, ParserExtension p_pexParserExtension) { m_pexParserExtension = p_pexParserExtension; XmlConfig = p_xmlConfig; Fomod = p_fomodMod; StateManager = p_dsmSate; validateModuleConfig(); }
/// <summary> /// Parses the given dependency. /// </summary> /// <param name="p_xndDependency">The dependency to parse.</param> /// <param name="p_dsmSate">The state manager for this install.</param> /// <returns>the dependency represented by the given node.</returns> public override IDependency ParseDependency(XmlNode p_xndDependency, DependencyStateManager p_dsmSate) { switch (p_xndDependency.Name) { case "foseDependancy": var verMinFoseVersion = new Version(p_xndDependency.Attributes["version"].InnerText); return(new FoseDependency((Fallout3DependencyStateManager)p_dsmSate, verMinFoseVersion)); } return(null); }
/// <summary> /// The factory method that returns the appropriate parser for the given configuration file. /// </summary> /// <param name="p_xmlConfig">The configuration file for which to return a parser.</param> /// <param name="p_fomodMod">The mod whose configuration file is being parsed.</param> /// <param name="p_dsmSate">The state of the install.</param> /// <returns>The appropriate parser for the given configuration file.</returns> /// <exception cref="ParserException">Thrown if no parser is found for the given configuration file.</exception> public static Parser GetParser(XmlDocument p_xmlConfig, fomod p_fomodMod, DependencyStateManager p_dsmSate) { var strConfigVersion = "1.0"; var strSchemaName = p_xmlConfig.SelectSingleNode("config").Attributes["xsi:noNamespaceSchemaLocation"].InnerText.ToLowerInvariant(); var intStartPos = strSchemaName.LastIndexOf("modconfig") + 9; if (intStartPos > 8) { var intLength = strSchemaName.Length - intStartPos - 4; if (intLength > 0) { strConfigVersion = strSchemaName.Substring(intStartPos, intLength); } } var pexParserExtension = Program.GameMode.GetParserExtension(strConfigVersion); switch (strConfigVersion) { case "1.0": return(new Parser10(p_xmlConfig, p_fomodMod, p_dsmSate, pexParserExtension)); case "2.0": return(new Parser20(p_xmlConfig, p_fomodMod, p_dsmSate, pexParserExtension)); case "3.0": return(new Parser30(p_xmlConfig, p_fomodMod, p_dsmSate, pexParserExtension)); case "4.0": return(new Parser40(p_xmlConfig, p_fomodMod, p_dsmSate, pexParserExtension)); case "5.0": return(new Parser50(p_xmlConfig, p_fomodMod, p_dsmSate, pexParserExtension)); } throw new ParserException("Unrecognized Module Configuration version (" + strConfigVersion + "). Perhaps a newer version of FOMM is required."); }
/// <summary> /// A simple constructor that initializes teh object with the given values. /// </summary> /// <param name="p_xmlConfig">The modules configuration file.</param> /// <param name="p_fomodMod">The mod whose configuration file we are parsing.</param> /// <param name="p_dsmSate">The state of the install.</param> /// <param name="p_pexParserExtension">The parser extension that provides game-specific config file parsing.</param> public Parser10(XmlDocument p_xmlConfig, fomod p_fomodMod, DependencyStateManager p_dsmSate, ParserExtension p_pexParserExtension) : base(p_xmlConfig, p_fomodMod, p_dsmSate, p_pexParserExtension) { }
/// <summary> /// A simple constructor that initializes teh object with the given values. /// </summary> /// <param name="p_xmlConfig">The modules configuration file.</param> /// <param name="p_fomodMod">The mod whose configuration file we are parsing.</param> /// <param name="p_dsmSate">The state of the install.</param> /// <param name="p_pexParserExtension">The parser extension that provides game-specific config file parsing.</param> public Parser50(XmlDocument p_xmlConfig, fomod p_fomodMod, DependencyStateManager p_dsmSate, ParserExtension p_pexParserExtension) : base(p_xmlConfig, p_fomodMod, p_dsmSate, p_pexParserExtension) {}
/// <summary> /// Parses the given dependency. /// </summary> /// <param name="p_xndDependency">The dependency to parse.</param> /// <param name="p_dsmSate">The state manager for this install.</param> /// <returns>the dependency represented by the given node.</returns> public virtual IDependency ParseDependency(XmlNode p_xndDependency, DependencyStateManager p_dsmSate) { return null; }
/// <summary> /// Parses the given dependency. /// </summary> /// <param name="p_xndDependency">The dependency to parse.</param> /// <param name="p_dsmSate">The state manager for this install.</param> /// <returns>the dependency represented by the given node.</returns> public virtual IDependency ParseDependency(XmlNode p_xndDependency, DependencyStateManager p_dsmSate) { return(null); }