Esempio n. 1
0
        internal ImplicationStep(WildcardTriplet implicationCondition, TripletTree implicationResult, WildcardTriplet target, Context context)
            : base(target, context)
        {
            _conditionReader = CreateRequirement(implicationCondition);
            _implicationResult = implicationResult;

            _conditionReader.AttachHandler(_handler_Condition);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        /// <summary>
        /// Handler for received triplet on given reader.
        /// </summary>
        /// <param name="receivedTriplet">Triplet which was received.</param>
        /// <param name="handledReader">The reader to handle.</param>
        private void reader_Handler(TripletTree receivedTriplet, TripletTreeReader handledReader)
        {
            var otherReader = handledReader == _reader1 ? _reader2 : _reader1;
            var generateReverseOrder = handledReader == _reader2;

            var substitutions = handledReader.Condition.GetSubstitutionMapping(receivedTriplet);
            var otherConditionRequest = substitutions.Substitute(otherReader.Condition);

            foreach (var substitutedRequestedTriplet in otherReader.RequestSubstituted(otherConditionRequest))
            {
                var mapping = otherConditionRequest.GetSubstitutionMapping(substitutedRequestedTriplet);
                var substitutedReceivedTriplet = mapping.Substitute(receivedTriplet);

                if (generateReverseOrder)
                    Produce(TripletTree.From(substitutedRequestedTriplet, Predicate.And, substitutedReceivedTriplet));
                else
                    Produce(TripletTree.From(substitutedReceivedTriplet, Predicate.And, substitutedRequestedTriplet));
            }
        }
Esempio n. 4
0
        internal TripletTreeReader GetReader(WildcardTriplet wildcard, TripletTreeReaderEvent handler = null)
        {
            TripletTreeReader reader;
            if (!_wildcardReaders.TryGetValue(wildcard, out reader))
                _wildcardReaders[wildcard] = reader = new TripletTreeReader(wildcard);

            if (handler != null)
                reader.AttachHandler(handler);
            return reader;
        }