Пример #1
0
        /// <summary>
        ///   Reads a plugin's information from the configuration file.
        /// </summary>
        /// <param name="p_xndPlugin">The configuration file node corresponding to the plugin to read.</param>
        /// <returns>The plugin information.</returns>
        protected override PluginInfo parsePlugin(XmlNode p_xndPlugin)
        {
            var         strName = p_xndPlugin.Attributes["name"].InnerText;
            var         strDesc = p_xndPlugin.SelectSingleNode("description").InnerText.Trim();
            IPluginType iptType;
            var         xndTypeDescriptor = p_xndPlugin.SelectSingleNode("typeDescriptor").FirstChild;

            switch (xndTypeDescriptor.Name)
            {
            case "type":
                iptType =
                    new StaticPluginType(
                        (PluginType)Enum.Parse(typeof(PluginType), xndTypeDescriptor.Attributes["name"].InnerText));
                break;

            case "dependencyType":
                var ptpDefaultType =
                    (PluginType)
                    Enum.Parse(typeof(PluginType),
                               xndTypeDescriptor.SelectSingleNode("defaultType").Attributes["name"].InnerText);
                iptType = new DependencyPluginType(ptpDefaultType);
                var dptDependentType = (DependencyPluginType)iptType;

                var xnlPatterns = xndTypeDescriptor.SelectNodes("patterns/*");
                foreach (XmlNode xndPattern in xnlPatterns)
                {
                    var ptpType =
                        (PluginType)
                        Enum.Parse(typeof(PluginType), xndPattern.SelectSingleNode("type").Attributes["name"].InnerText);
                    var cdpDependency = loadDependency(xndPattern.SelectSingleNode("dependencies"));
                    dptDependentType.AddPattern(ptpType, cdpDependency);
                }
                break;

            default:
                throw new ParserException("Invalid plaug type descriptor node: " + xndTypeDescriptor.Name +
                                          ". At this point the config file has been validated against the schema, so there's something wrong with the parser.");
            }
            var   xndImage = p_xndPlugin.SelectSingleNode("image");
            Image imgImage = null;

            if (xndImage != null)
            {
                var strImageFilePath = xndImage.Attributes["path"].InnerText;
                imgImage = Fomod.GetImage(strImageFilePath);
            }
            var pifPlugin = new PluginInfo(strName, strDesc, imgImage, iptType);

            var xnlPluginFiles = p_xndPlugin.SelectNodes("files/*");

            pifPlugin.Files.AddRange(readFileInfo(xnlPluginFiles));

            var xnlPluginFlags = p_xndPlugin.SelectNodes("conditionFlags/*");

            pifPlugin.Flags.AddRange(readFlagInfo(xnlPluginFlags));

            return(pifPlugin);
        }
Пример #2
0
        /// <summary>
        ///   Reads a plugin's information from the configuration file.
        /// </summary>
        /// <param name="p_xndPlugin">The configuration file node corresponding to the plugin to read.</param>
        /// <returns>The plugin information.</returns>
        protected virtual PluginInfo parsePlugin(XmlNode p_xndPlugin)
        {
            var         strName           = p_xndPlugin.Attributes["name"].InnerText;
            var         strDesc           = p_xndPlugin.SelectSingleNode("description").InnerText.Trim();
            IPluginType iptType           = null;
            var         xndTypeDescriptor = p_xndPlugin.SelectSingleNode("typeDescriptor").FirstChild;

            switch (xndTypeDescriptor.Name)
            {
            case "type":
                iptType =
                    new StaticPluginType(
                        (PluginType)Enum.Parse(typeof(PluginType), xndTypeDescriptor.Attributes["name"].InnerText));
                break;

            case "dependancyType":
                var ptpDefaultType =
                    (PluginType)
                    Enum.Parse(typeof(PluginType),
                               xndTypeDescriptor.SelectSingleNode("defaultType").Attributes["name"].InnerText);
                iptType = new DependencyPluginType(ptpDefaultType);
                var dptDependentType = (DependencyPluginType)iptType;

                var xnlPatterns = xndTypeDescriptor.SelectNodes("patterns/*");
                foreach (XmlNode xndPattern in xnlPatterns)
                {
                    var ptpType =
                        (PluginType)
                        Enum.Parse(typeof(PluginType), xndPattern.SelectSingleNode("type").Attributes["name"].InnerText);
                    var cdpDependency = loadDependency(xndPattern.SelectSingleNode("dependancies"));
                    dptDependentType.AddPattern(ptpType, cdpDependency);
                }
                break;
            }
            var   xndImage = p_xndPlugin.SelectSingleNode("image");
            Image imgImage = null;

            if (xndImage != null)
            {
                var strImageFilePath = xndImage.Attributes["path"].InnerText;
                imgImage = Fomod.GetImage(strImageFilePath);
            }
            var pifPlugin = new PluginInfo(strName, strDesc, imgImage, iptType);

            var xnlPluginFiles = p_xndPlugin.SelectNodes("files/*");

            pifPlugin.Files.AddRange(readFileInfo(xnlPluginFiles));
            return(pifPlugin);
        }
Пример #3
0
        /// <summary>
        /// Reads a plugin's information from the configuration file.
        /// </summary>
        /// <param name="p_xndPlugin">The configuration file node corresponding to the plugin to read.</param>
        /// <returns>The plugin information.</returns>
        protected override PluginInfo parsePlugin(XmlNode p_xndPlugin)
        {
            string strName = p_xndPlugin.Attributes["name"].InnerText;
            string strDesc = p_xndPlugin.SelectSingleNode("description").InnerText.Trim();
            IPluginType iptType = null;
            XmlNode xndTypeDescriptor = p_xndPlugin.SelectSingleNode("typeDescriptor").FirstChild;
            switch (xndTypeDescriptor.Name)
            {
                case "type":
                    iptType = new StaticPluginType((PluginType)Enum.Parse(typeof(PluginType), xndTypeDescriptor.Attributes["name"].InnerText));
                    break;
                case "dependencyType":
                    PluginType ptpDefaultType = (PluginType)Enum.Parse(typeof(PluginType), xndTypeDescriptor.SelectSingleNode("defaultType").Attributes["name"].InnerText);
                    iptType = new DependencyPluginType(ptpDefaultType);
                    DependencyPluginType dptDependentType = (DependencyPluginType)iptType;

                    XmlNodeList xnlPatterns = xndTypeDescriptor.SelectNodes("patterns/*");
                    foreach (XmlNode xndPattern in xnlPatterns)
                    {
                        PluginType ptpType = (PluginType)Enum.Parse(typeof(PluginType), xndPattern.SelectSingleNode("type").Attributes["name"].InnerText);
                        CompositeDependency cdpDependency = loadDependency(xndPattern.SelectSingleNode("dependencies"));
                        dptDependentType.AddPattern(ptpType, cdpDependency);
                    }
                    break;
                default:
                    throw new ParserException("Invalid plaug type descriptor node: " + xndTypeDescriptor.Name + ". At this point the config file has been validated against the schema, so there's something wrong with the parser.");
            }
            XmlNode xndImage = p_xndPlugin.SelectSingleNode("image");
            Image imgImage = null;
            if (xndImage != null)
            {
                string strImageFilePath = xndImage.Attributes["path"].InnerText;
                imgImage = Fomod.GetImage(strImageFilePath);
            }
            PluginInfo pifPlugin = new PluginInfo(strName, strDesc, imgImage, iptType);

            XmlNodeList xnlPluginFiles = p_xndPlugin.SelectNodes("files/*");
            pifPlugin.Files.AddRange(readFileInfo(xnlPluginFiles));

            XmlNodeList xnlPluginFlags = p_xndPlugin.SelectNodes("conditionFlags/*");
            pifPlugin.Flags.AddRange(readFlagInfo(xnlPluginFlags));

            return pifPlugin;
        }
Пример #4
0
        /// <summary>
        /// Reads a plugin's information from the configuration file.
        /// </summary>
        /// <param name="p_xndPlugin">The configuration file node corresponding to the plugin to read.</param>
        /// <returns>The plugin information.</returns>
        protected virtual PluginInfo parsePlugin(XmlNode p_xndPlugin)
        {
            string strName = p_xndPlugin.Attributes["name"].InnerText;
            string strDesc = p_xndPlugin.SelectSingleNode("description").InnerText.Trim();
            IPluginType iptType = null;
            XmlNode xndTypeDescriptor = p_xndPlugin.SelectSingleNode("typeDescriptor").FirstChild;
            switch (xndTypeDescriptor.Name)
            {
                case "type":
                    iptType = new StaticPluginType((PluginType)Enum.Parse(typeof(PluginType), xndTypeDescriptor.Attributes["name"].InnerText));
                    break;
                case "dependancyType":
                    PluginType ptpDefaultType = (PluginType)Enum.Parse(typeof(PluginType), xndTypeDescriptor.SelectSingleNode("defaultType").Attributes["name"].InnerText);
                    iptType = new DependencyPluginType(ptpDefaultType);
                    DependencyPluginType dptDependentType = (DependencyPluginType)iptType;

                    XmlNodeList xnlPatterns = xndTypeDescriptor.SelectNodes("patterns/*");
                    foreach (XmlNode xndPattern in xnlPatterns)
                    {
                        PluginType ptpType = (PluginType)Enum.Parse(typeof(PluginType), xndPattern.SelectSingleNode("type").Attributes["name"].InnerText);
                        CompositeDependency cdpDependency = loadDependency(xndPattern.SelectSingleNode("dependancies"));
                        dptDependentType.AddPattern(ptpType, cdpDependency);
                    }
                    break;
            }
            XmlNode xndImage = p_xndPlugin.SelectSingleNode("image");
            Image imgImage = null;
            if (xndImage != null)
            {
                string strImageFilePath = xndImage.Attributes["path"].InnerText;
                imgImage = Fomod.GetImage(strImageFilePath);
            }
            PluginInfo pifPlugin = new PluginInfo(strName, strDesc, imgImage, iptType);

            XmlNodeList xnlPluginFiles = p_xndPlugin.SelectNodes("files/*");
            pifPlugin.Files.AddRange(readFileInfo(xnlPluginFiles));
            return pifPlugin;
        }