ReadComplexCondition() публичный статический Метод

public static ReadComplexCondition ( XmlReader reader ) : ICondition
reader System.Xml.XmlReader
Результат ICondition
Пример #1
0
		void DoSetUp(XmlReader reader, string endElement, Stack<ICondition> conditionStack)
		{
			List<Codon> innerCodons = new List<Codon>();
			while (reader.Read()) {
				switch (reader.NodeType) {
					case XmlNodeType.EndElement:
						if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition") {
							conditionStack.Pop();
						} else if (reader.LocalName == endElement) {
							if (innerCodons.Count > 0)
								this.codons.Add(innerCodons);
							return;
						}
						break;
					case XmlNodeType.Element:
						string elementName = reader.LocalName;
						if (elementName == "Condition") {
							conditionStack.Push(Condition.Read(reader));
						} else if (elementName == "ComplexCondition") {
							conditionStack.Push(Condition.ReadComplexCondition(reader));
						} else {
							Codon newCodon = new Codon(this.AddIn, elementName, Properties.ReadFromAttributes(reader), conditionStack.ToArray());
							innerCodons.Add(newCodon);
							if (!reader.IsEmptyElement) {
								ExtensionPath subPath = this.AddIn.GetExtensionPath(this.Name + "/" + newCodon.Id);
								subPath.DoSetUp(reader, elementName, conditionStack);
							}
						}
						break;
				}
			}
			if (innerCodons.Count > 0)
				this.codons.Add(innerCodons);
		}
Пример #2
0
        public static void SetUp(ExtensionPath extensionPath, XmlReader reader, string endElement)
        {
            Stack <ICondition> stack = new Stack <ICondition>();

            while (reader.Read())
            {
                XmlNodeType nodeType = reader.NodeType;
                if (nodeType != XmlNodeType.Element)
                {
                    if (nodeType == XmlNodeType.EndElement)
                    {
                        if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition")
                        {
                            stack.Pop();
                        }
                        else
                        {
                            if (reader.LocalName == endElement)
                            {
                                return;
                            }
                        }
                    }
                }
                else
                {
                    string localName = reader.LocalName;
                    if (localName == "Condition")
                    {
                        stack.Push(Condition.Read(reader));
                    }
                    else
                    {
                        if (localName == "ComplexCondition")
                        {
                            stack.Push(Condition.ReadComplexCondition(reader));
                        }
                        else
                        {
                            Codon codon = new Codon(extensionPath.AddIn, localName, Properties.ReadFromAttributes(reader), stack.ToArray());
                            extensionPath.codons.Add(codon);
                            if (!reader.IsEmptyElement)
                            {
                                ExtensionPath extensionPath2 = extensionPath.AddIn.GetExtensionPath(extensionPath.Name + "/" + codon.Id);
                                ExtensionPath.SetUp(extensionPath2, reader, localName);
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
        internal static List <Runtime> ReadSection(XmlReader reader, AddIn addIn, string hintPath)
        {
            List <Runtime>     runtimes       = new List <Runtime>();
            Stack <ICondition> conditionStack = new Stack <ICondition>();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.EndElement:
                    if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition")
                    {
                        conditionStack.Pop();
                    }
                    else if (reader.LocalName == "Runtime")
                    {
                        return(runtimes);
                    }
                    break;

                case XmlNodeType.Element:
                    switch (reader.LocalName)
                    {
                    case "Condition":
                        conditionStack.Push(Condition.Read(reader, addIn));
                        break;

                    case "ComplexCondition":
                        conditionStack.Push(Condition.ReadComplexCondition(reader, addIn));
                        break;

                    case "Import":
                        runtimes.Add(Runtime.Read(addIn, reader, hintPath, conditionStack));
                        break;

                    case "DisableAddIn":
                        if (Condition.GetFailedAction(conditionStack, addIn) == ConditionFailedAction.Nothing)
                        {
                            // The DisableAddIn node not was not disabled by a condition
                            addIn.CustomErrorMessage = reader.GetAttribute("message");
                        }
                        break;

                    default:
                        throw new AddInLoadException("Unknown node in runtime section :" + reader.LocalName);
                    }
                    break;
                }
            }
            return(runtimes);
        }
Пример #4
0
        public static void SetUp(ExtensionPath extensionPath, XmlReader reader, string endElement)
        {
            Stack <ICondition> conditionStack = new Stack <ICondition>();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.EndElement:
                    if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition")
                    {
                        conditionStack.Pop();
                    }
                    else if (reader.LocalName == endElement)
                    {
                        return;
                    }
                    break;

                case XmlNodeType.Element:
                    string elementName = reader.LocalName;
                    if (elementName == "Condition")
                    {
                        conditionStack.Push(Condition.Read(reader));
                    }
                    else if (elementName == "ComplexCondition")
                    {
                        conditionStack.Push(Condition.ReadComplexCondition(reader));
                    }
                    else
                    {
                        Codon newCodon = new Codon(extensionPath.AddIn, elementName, Properties.ReadFromAttributes(reader), conditionStack.ToArray());
                        extensionPath.codons.Add(newCodon);
                        if (!reader.IsEmptyElement)
                        {
                            ExtensionPath subPath = extensionPath.AddIn.GetExtensionPath(extensionPath.Name + "/" + newCodon.Id);
                            //foreach (ICondition condition in extensionPath.conditionStack) {
                            //	subPath.conditionStack.Push(condition);
                            //}
                            SetUp(subPath, reader, elementName);
                            //foreach (ICondition condition in extensionPath.conditionStack) {
                            //	subPath.conditionStack.Pop();
                            //}
                        }
                    }
                    break;
                }
            }
        }
Пример #5
0
        internal static void ReadSection(XmlReader reader, AddIn addIn, string hintPath)
        {
            Stack <ICondition> stack = new Stack <ICondition>();

            while (reader.Read())
            {
                XmlNodeType nodeType = reader.NodeType;
                if (nodeType != XmlNodeType.Element)
                {
                    if (nodeType == XmlNodeType.EndElement)
                    {
                        if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition")
                        {
                            stack.Pop();
                        }
                        else
                        {
                            if (reader.LocalName == "Runtime")
                            {
                                return;
                            }
                        }
                    }
                }
                else
                {
                    string localName;
                    if ((localName = reader.LocalName) != null)
                    {
                        if (!(localName == "Condition"))
                        {
                            if (!(localName == "ComplexCondition"))
                            {
                                if (!(localName == "Import"))
                                {
                                    if (localName == "DisableAddIn")
                                    {
                                        if (Condition.GetFailedAction(stack, addIn) == ConditionAction.Nothing)
                                        {
                                            addIn.CustomErrorMessage = reader.GetAttribute("message");
                                        }
                                    }
                                }
                                else
                                {
                                    addIn.Runtimes.Add(Runtime.Read(addIn, reader, hintPath, stack));
                                }
                            }
                            else
                            {
                                stack.Push(Condition.ReadComplexCondition(reader));
                            }
                        }
                        else
                        {
                            stack.Push(Condition.Read(reader));
                        }
                    }
                }
            }
        }