Пример #1
0
            public IProcessor CreateFromXML(XmlElement element)
            {
                if (element.Name != cElementName)
                {
                    throw new ArgumentException(string.Format("argument must be a {0} element", cElementName), "element");
                }

                return(new CombineProcessor(TextParser.ParseMultilineElementText(element.InnerText)));
            }
Пример #2
0
        public static Task CreateFromXML(XmlElement taskElement, Menu parentMenu)
        {
            if (taskElement.Name != "task")
            {
                throw new ArgumentException("argument must be a task element", "taskElement");
            }

            MenuItemBaseProperties baseProperties = new MenuItemBaseProperties();

            baseProperties.FillFromXml(taskElement, parentMenu);

            DecoratedMessage postMessage = null;

            XmlElement postMessageElement = taskElement["postMessage"];

            if (postMessageElement != null)
            {
                MessageBoxIcon?messageTypeIcon = null;

                XmlAttribute messageTypeAttribute = postMessageElement.Attributes["messageType"];
                if (messageTypeAttribute != null)
                {
                    switch (messageTypeAttribute.Value)
                    {
                    case "neutral":
                        messageTypeIcon = MessageBoxIcon.None;
                        break;

                    case "information":
                        messageTypeIcon = MessageBoxIcon.Information;
                        break;

                    case "warning":
                        messageTypeIcon = MessageBoxIcon.Warning;
                        break;
                    }
                }

                postMessage = new DecoratedMessage(TextParser.ParseMultilineElementText(postMessageElement.InnerText.Trim()), postMessageElement.Attributes["caption"].Value,
                                                   false, TextParser.ParseNullableXmlBoolean(postMessageElement.Attributes["showIfFailed"]), null, messageTypeIcon);
            }


            return(new Task(baseProperties, taskElement.Attributes["progressCaption"].Value,
                            TextParser.ParseActivities(taskElement["activities"].InnerText), TextParser.ParseNullableXmlBoolean(taskElement.Attributes["continueOnError"]), postMessage));
        }
Пример #3
0
            public IProcessor CreateFromXML(XmlElement element)
            {
                if (element.Name != cElementName)
                {
                    throw new ArgumentException(string.Format("argument must be a {0} element", cElementName), "element");
                }

                XmlElement defaultTextElement = element["defaultText"];

                TranslateProcessor processor = new TranslateProcessor(defaultTextElement != null ? TextParser.ParseMultilineElementText(defaultTextElement.InnerText) ?? "" : null);

                foreach (XmlNode node in element)
                {
                    if (node is XmlElement childElement && childElement.Name == "item")
                    {
                        processor.Items[childElement.Attributes["from"].Value] = TextParser.ParseMultilineElementText(childElement.InnerText);
                    }
                }

                return(processor);
            }
Пример #4
0
        public virtual void FillFromXml(XmlElement element, Menu parentMenu)
        {
            ParentMenu = parentMenu;

            XmlAttribute compatibleProductModelsAttribute = element.Attributes["compatibleProductModels"];

            string[] compatibleProductModels = null;
            if (compatibleProductModelsAttribute != null)
            {
                compatibleProductModels = TextParser.ParseProductModels(compatibleProductModelsAttribute.Value);
            }

            CompatibleProductModels = compatibleProductModels;

            XmlNamespaceManager namespaceManager = new XmlNamespaceManager(new NameTable());

            namespaceManager.AddNamespace("cf", "http://schema.vanbergen.local/Tools/CherryUpdater/CommandFile");

            List <Requirement> requirementList = new List <Requirement>();
            XmlNodeList        requireNodes    = element.SelectNodes("child::cf:require", namespaceManager);

            foreach (XmlElement requireElement in requireNodes)
            {
                requirementList.Add(Requirement.CreateFromXML(requireElement));
            }

            Requirements = requirementList.Count > 0 ? requirementList.ToArray() : null;

            XmlElement helpTextElement = element["helpText"];
            string     helpText        = null;

            if (helpTextElement != null)
            {
                helpText = TextParser.ParseMultilineElementText(helpTextElement.InnerText.Trim());
            }

            HelpText = helpText;

            XmlElement preMessageElement = element["preMessage"];

            if (preMessageElement != null)
            {
                MessageBoxButtons?showButtons = null;

                XmlAttribute showButtonsAttribute = preMessageElement.Attributes["showButtons"];
                if (showButtonsAttribute != null)
                {
                    switch (showButtonsAttribute.Value)
                    {
                    case "ok":
                        showButtons = MessageBoxButtons.OK;
                        break;

                    case "okCancel":
                        showButtons = MessageBoxButtons.OKCancel;
                        break;

                    case "yesNo":
                        showButtons = MessageBoxButtons.YesNo;
                        break;
                    }
                }

                MessageBoxIcon?messageTypeIcon = null;

                XmlAttribute messageTypeAttribute = preMessageElement.Attributes["messageType"];
                if (messageTypeAttribute != null)
                {
                    switch (messageTypeAttribute.Value)
                    {
                    case "neutral":
                        messageTypeIcon = MessageBoxIcon.None;
                        break;

                    case "information":
                        messageTypeIcon = MessageBoxIcon.Information;
                        break;

                    case "question":
                        messageTypeIcon = MessageBoxIcon.Question;
                        break;

                    case "warning":
                        messageTypeIcon = MessageBoxIcon.Warning;
                        break;
                    }
                }

                PreMessage = new DecoratedMessage(TextParser.ParseMultilineElementText(preMessageElement.InnerText.Trim()), preMessageElement.Attributes["caption"].Value,
                                                  TextParser.ParseNullableXmlBoolean(preMessageElement.Attributes["showOnce"]), false, showButtons, messageTypeIcon);
            }

            Title = element.Attributes["title"].Value;
        }
Пример #5
0
        public override void FillFromXml(XmlElement element)
        {
            base.FillFromXml(element);

            Message = TextParser.ParseMultilineElementText(element.InnerText);
        }