public static ICondition[] ReadConditionList(XmlReader reader, string endElement)
        {
            List <ICondition> conditions = new List <ICondition>();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.EndElement:
                    if (reader.LocalName == endElement)
                    {
                        return(conditions.ToArray());
                    }
                    break;

                case XmlNodeType.Element:
                    switch (reader.LocalName)
                    {
                    case "And":
                        conditions.Add(AndCondition.Read(reader));
                        break;

                    case "Or":
                        conditions.Add(OrCondition.Read(reader));
                        break;

                    case "Not":
                        conditions.Add(NegatedCondition.Read(reader));
                        break;

                    case "Condition":
                        conditions.Add(Condition.Read(reader));
                        break;

                    default:
                        throw new AddInLoadException("Invalid element name '" + reader.LocalName
                                                     + "', entries in a <" + endElement + "> " +
                                                     "must be <And>, <Or>, <Not> or <Condition>");
                    }
                    break;
                }
            }
            return(conditions.ToArray());
        }
        public static ICondition ReadComplexCondition(XmlReader reader)
        {
            Properties properties = Properties.ReadFromAttributes(reader);

            reader.Read();
            ICondition condition = null;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    switch (reader.LocalName)
                    {
                    case "And":
                        condition = AndCondition.Read(reader);
                        goto exit;

                    case "Or":
                        condition = OrCondition.Read(reader);
                        goto exit;

                    case "Not":
                        condition = NegatedCondition.Read(reader);
                        goto exit;

                    default:
                        throw new AddInLoadException("Invalid element name '" + reader.LocalName
                                                     + "', the first entry in a ComplexCondition " +
                                                     "must be <And>, <Or> or <Not>");
                    }
                }
            }
exit:
            if (condition != null)
            {
                ConditionFailedAction action = properties.Get("action", ConditionFailedAction.Exclude);
                condition.Action = action;
            }
            return(condition);
        }