Exemplo n.º 1
0
        public Either <Error, List <string> > GetRevocationIdentifiers()
        {
            List <string> ids = new List <string>();

            Builder.RuleBuilder getRevocationIds = Utils.Rule(
                "revocation_id",
                Arrays.AsList(Utils.Var("id")),
                Arrays.AsList(Utils.Pred("revocation_id", Arrays.AsList(Utils.Var("id"))))
                );

            Either <Error, HashSet <FactBuilder> > queryRes = this.Query(getRevocationIds);

            if (queryRes.IsLeft)
            {
                return(queryRes.Left);
            }

            foreach (var fact in queryRes.Right)
            {
                foreach (var id in fact.Ids.Where(id => id is Term.Str))
                {
                    ids.Add(((Term.Str)id).Value);
                }
            }

            return(ids);
        }
Exemplo n.º 2
0
        public static CheckBuilder ConvertFrom(Check r, SymbolTable symbols)
        {
            List <RuleBuilder> queries = new List <RuleBuilder>();

            foreach (Rule q in r.Queries)
            {
                queries.Add(RuleBuilder.ConvertFrom(q, symbols));
            }

            return(new CheckBuilder(queries));
        }
Exemplo n.º 3
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || !(o is RuleBuilder))
            {
                return(false);
            }

            RuleBuilder rule = (RuleBuilder)o;

            if (Head != null ? !Head.Equals(rule.Head) : rule.Head != null)
            {
                return(false);
            }
            if (Body != null ? !Body.SequenceEqual(rule.Body) : rule.Body != null)
            {
                return(false);
            }
            return(Expressions != null?Expressions.SequenceEqual(rule.Expressions) : rule.Expressions == null);
        }
Exemplo n.º 4
0
 public void AddRule(RuleBuilder rule)
 {
     this.rules.Add(rule.Convert(this.symbols));
 }
Exemplo n.º 5
0
 public static CheckBuilder Check(RuleBuilder rule)
 {
     return(new CheckBuilder(rule));
 }