Example #1
0
        /// <summary>
        /// Trace the output of the computation that transformed the given input with the given transformation type
        /// </summary>
        /// <param name="rule">The rule that transformed the argument</param>
        /// <param name="input">The input arguments</param>
        /// <param name="trace">The trace component that is used as basis</param>
        /// <returns>The output of the computation with the specified input argument or null, if there is none such</returns>
        public static object ResolveIn(this ITransformationTrace trace, GeneralTransformationRule rule, object[] input)
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            var comp = trace.TraceIn(rule, input).FirstOrDefault();

            return(comp != null ? comp.Output : null);
        }
Example #2
0
        public static IEnumerable <TOut> ResolveManyIn <TIn, TOut>(this ITransformationTrace trace, TransformationRuleBase <TIn, TOut> rule, TIn input)
            where TIn : class
            where TOut : class
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            return(from ITraceEntry c in trace.TraceIn(rule, input)
                   select c.Output as TOut);
        }
Example #3
0
        public static TOut ResolveIn <TOut>(this ITransformationTrace trace, TransformationRuleBase <TOut> rule, object[] input)
            where TOut : class
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            var comp = trace.TraceIn(rule, input).FirstOrDefault();

            return(comp != null ? comp.Output as TOut : null);
        }
Example #4
0
        public void Transformations_AbstractTrace_TraceIn()
        {
            Assert.AreEqual(c_a, trace.TraceIn(ruleT1, "a").FirstOrDefault());
            Assert.AreEqual(c_b, trace.TraceIn(ruleT1, "b").FirstOrDefault());
            Assert.AreEqual(c_ab, trace.TraceIn(ruleT2, "a", "b").FirstOrDefault());
            Assert.AreEqual(c_bc, trace.TraceIn(ruleT2, "b", "c").FirstOrDefault());
            Assert.AreEqual(c_abc, trace.TraceIn(ruleTN, "a", "b", "c").FirstOrDefault());
            Assert.AreEqual(c_bcd, trace.TraceIn(ruleTN, "b", "c", "d").FirstOrDefault());

            Assert.AreEqual(null, trace.TraceIn(ruleT1, "c").FirstOrDefault());
            Assert.AreEqual(null, trace.TraceIn(ruleT2, "a", "a").FirstOrDefault());
            Assert.AreEqual(null, trace.TraceIn(ruleTN, "a", "a", "a").FirstOrDefault());

            Assert.AreEqual(null, trace.TraceIn(ruleT2, "a").FirstOrDefault());
            Assert.AreEqual(null, trace.TraceIn(ruleT2, "b").FirstOrDefault());
            Assert.AreEqual(null, trace.TraceIn(ruleTN, "a", "b").FirstOrDefault());
            Assert.AreEqual(null, trace.TraceIn(ruleTN, "b", "c").FirstOrDefault());
            Assert.AreEqual(null, trace.TraceIn(ruleT1, "a", "b", "c").FirstOrDefault());
            Assert.AreEqual(null, trace.TraceIn(ruleT1, "b", "c", "d").FirstOrDefault());

            Assert.AreEqual(null, trace.TraceIn(ruleTN, "a").FirstOrDefault());
            Assert.AreEqual(null, trace.TraceIn(ruleTN, "b").FirstOrDefault());
            Assert.AreEqual(null, trace.TraceIn(ruleT1, "a", "b").FirstOrDefault());
            Assert.AreEqual(null, trace.TraceIn(ruleT1, "b", "c").FirstOrDefault());
            Assert.AreEqual(null, trace.TraceIn(ruleT2, "a", "b", "c").FirstOrDefault());
            Assert.AreEqual(null, trace.TraceIn(ruleT2, "b", "c", "d").FirstOrDefault());
        }