Read() static private method

static private Read ( AddIn addIn, XmlReader reader, string hintPath, Stack conditionStack ) : Runtime
addIn AddIn
reader XmlReader
hintPath string
conditionStack Stack
return Runtime
示例#1
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);
        }
示例#2
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));
                        }
                    }
                }
            }
        }