internal NpletProducerNode(Context context, NpletQueryNode target, NpletFactory factory, IEnumerable<NpletTree> dependencies)
        {
            TargetQuery = target;
            _factory = factory;

            Dependencies = (from nplet in dependencies select context.CreateQueryNode(nplet)).ToArray();
            _dependencyReaders = (from dependency in Dependencies select context.CreateReader(dependency)).ToArray();
        }
        /// <inheritdoc/>
        internal override IEnumerable<NpletProducerNode> CreateProducers(NpletQueryNode query, Context context)
        {
            //creates query which will match to implication targeting the query
            var implicationQuery = NpletTree.From(Edge.Then, Edge.TempVariable(), Edge.To(query.Query));
            //fetches those implications from database
            var implications = context.Fetch(implicationQuery);

            var producers = new List<NpletProducerNode>();
            foreach (var implication in implications)
            {
                var condition = implication.GetEdge(0).TargetAsNplet;
                var producer = new NpletProducerNode(context, query, null, new[] { condition });

                producers.Add(producer);
            }

            return producers;
        }
        /// <inheritdoc/>
        internal override IEnumerable<NpletProducerNode> CreateProducers(NpletQueryNode query, Context context)
        {

            throw new NotImplementedException();
        }
Beispiel #4
0
 internal abstract IEnumerable<NpletProducerNode> CreateProducers(NpletQueryNode query, Context context);
Beispiel #5
0
 internal QueryReader(NpletQueryNode source)
 {
     _source = source;
 }
Beispiel #6
0
        /// <summary>
        /// Creates reader for given query.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <returns>The reader.</returns>
        internal QueryReader CreateReader(NpletQueryNode query)
        {
            var reader = new QueryReader(query);

            return reader;
        }
Beispiel #7
0
 private IEnumerable<NpletProducerNode> createProducers(NpletQueryNode query)
 {
     var result = new List<NpletProducerNode>();
     foreach (var rule in _engine.Rules)
     {
         result.AddRange(rule.CreateProducers(query, this));
     }
     return result;
 }