Exemple #1
0
        public static Term Load(XmlReader reader)
        {
            _ = reader ?? throw new ArgumentNullException(nameof(reader));

            Term evalExp = null;

            reader.MoveToStartElement();

            if (reader.IsRequiredStartElement(AuthorizationConstants.Elements.Rule))
            {
                Rule rule = new Rule();
                rule.ReadXml(reader);
                evalExp = rule;
            }

            if (reader.IsRequiredStartElement(AuthorizationConstants.Elements.LogicalAnd))
            {
                LogicalAndCollection logicalAnd = new LogicalAndCollection();
                logicalAnd.ReadXml(reader);
                evalExp = logicalAnd;
            }

            if (reader.IsRequiredStartElement(AuthorizationConstants.Elements.LogicalOr))
            {
                LogicalOrCollection logicalOr = new LogicalOrCollection();
                logicalOr.ReadXml(reader);
                evalExp = logicalOr;
            }

            if (evalExp != null)
            {
                return(evalExp);
            }

            throw new SerializationException("Invalid evaluation expression element.");
        }