Ejemplo n.º 1
0
 internal InferenceLevel(InferenceLevel parent, WildcardTriplet condition, IEnumerable<InferenceStep> steps, Context context)
 {
     Condition = condition;
     Depth = parent == null ? 0 : parent.Depth + 1;
     _context = context;
     _steps = steps.ToArray();
 }
Ejemplo n.º 2
0
        internal ImplicationStep(WildcardTriplet implicationCondition, TripletTree implicationResult, WildcardTriplet target, Context context)
            : base(target, context)
        {
            _conditionReader = CreateRequirement(implicationCondition);
            _implicationResult = implicationResult;

            _conditionReader.AttachHandler(_handler_Condition);
        }
Ejemplo n.º 3
0
        internal AndStep(WildcardTriplet condition1, WildcardTriplet condition2, WildcardTriplet target, Context context)
            : base(target, context)
        {
            _reader1 = CreateRequirement(condition1);
            _reader2 = CreateRequirement(condition2);

            _reader1.AttachHandler(reader1_Handler);
            _reader2.AttachHandler(reader2_Handler);
        }
Ejemplo n.º 4
0
        internal static IEnumerable<InferenceStep> Provider(WildcardTriplet target, Context context)
        {
            if (!Predicate.And.Equals(target.SearchedPredicate))
                yield break;

            var condition1Tree = target.SearchedSubject as TripletTree;
            var condition2Tree = target.SearchedObject as TripletTree;

            if (condition1Tree == null || condition2Tree == null)
                yield break;

            yield return new AndStep(WildcardTriplet.Exact(condition1Tree), WildcardTriplet.Exact(condition2Tree), target, context);
        }
Ejemplo n.º 5
0
        internal static IEnumerable<InferenceStep> Provider(WildcardTriplet target, Context context)
        {
            foreach (var substitutedTree in context.FindSubstitutedSubtreeParents(target))
            {
                //find matching trees
                var thenTrees = new List<TripletTree>();
                substitutedTree.Each(t =>
                {
                    if (Predicate.Then.Equals(t.Predicate))
                        thenTrees.Add(t);
                });

                //create steps according to database
                foreach (var thenTree in thenTrees)
                {
                    var condition = thenTree.Subject as TripletTree;
                    var implicationResult = thenTree.Object as TripletTree;
                    if (condition != null && implicationResult != null && target.IsSatisfiedBy(thenTree.Object as TripletTree))
                    {
                        yield return new ImplicationStep(WildcardTriplet.Exact(condition), implicationResult, target, context);
                    }
                }
            }
        }
Ejemplo n.º 6
0
 internal InferenceStep(WildcardTriplet target, Context context)
 {
     Target = target;
     _context = context;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Gets preconditions to given wildcard.
 /// </summary>
 /// <param name="wildcard">Wildcard which preconditions are requested.</param>
 /// <returns></returns>
 public IEnumerable<Precondition> Preconditions(WildcardTriplet wildcard)
 {
     var inference = new Context(this, wildcard);
     return inference.Preconditions();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Finds triplets according to given wildcard.
 /// Including the inference.
 /// </summary>
 /// <param name="wildcard">The wildcard for search.</param>
 /// <returns>Found triplets.</returns>
 public IEnumerable<TripletTree> Find(WildcardTriplet wildcard)
 {
     var inference = new Context(this, wildcard);
     return inference.Find();
 }
Ejemplo n.º 9
0
 internal OrStep(Context context)
     : base(null, context)
 {
 }
Ejemplo n.º 10
0
 internal static IEnumerable<InferenceStep> Provider(WildcardTriplet wildcard, Context context)
 {
     yield return new LookupStep(wildcard, context);
 }
Ejemplo n.º 11
0
 private LookupStep(WildcardTriplet target, Context context) :
     base(target, context)
 {
     _context = context;
     _triplets = lazyFindTriplets().GetEnumerator();
 }