示例#1
0
        internal ImplicationStep(WildcardTriplet implicationCondition, TripletTree implicationResult, WildcardTriplet target, Context context)
            : base(target, context)
        {
            _conditionReader = CreateRequirement(implicationCondition);
            _implicationResult = implicationResult;

            _conditionReader.AttachHandler(_handler_Condition);
        }
示例#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);
        }
示例#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));
            }
        }
示例#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;
        }