Beispiel #1
0
        public static IEnumerable <TOut> FindAllIn <TOut>(this ITransformationTrace trace, TransformationRuleBase <TOut> rule) where TOut : class
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            return(trace.TraceAllIn(rule).Select(c => c.Output as TOut));
        }
Beispiel #2
0
        public void Transformations_AbstractTrace_TraceAll()
        {
            trace.TraceAllIn(ruleT1).AssertContainsOnly(c_a, c_b);
            trace.TraceAllIn(ruleT2).AssertContainsOnly(c_ab, c_bc);
            trace.TraceAllIn(ruleTN).AssertContainsOnly(c_abc, c_bcd);

            trace.TraceInWhere(ruleT1, s => true).AssertContainsOnly(c_a, c_b);
            trace.TraceInWhere(ruleT2, (s1, s2) => true).AssertContainsOnly(c_ab, c_bc);
            trace.TraceInWhere(ruleTN, strings => true).AssertContainsOnly(c_abc, c_bcd);

            trace.TraceInWhere(ruleT1, null).AssertContainsOnly(c_a, c_b);
            trace.TraceInWhere(ruleT2, null).AssertContainsOnly(c_ab, c_bc);
            trace.TraceInWhere(ruleTN, null).AssertContainsOnly(c_abc, c_bcd);

            trace.TraceInWhere(ruleT1, s => false).AssertEmpty();
            trace.TraceInWhere(ruleT2, (s1, s2) => false).AssertEmpty();
            trace.TraceInWhere(ruleTN, strings => false).AssertEmpty();
        }
Beispiel #3
0
        public static IEnumerable <TOut> FindInWhere <TOut>(this ITransformationTrace trace, TransformationRuleBase <TOut> rule, Predicate <TOut> filter)
            where TOut : class
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            return(trace.TraceAllIn(rule).Select(c => c.Output as TOut).Where(o => filter == null || filter(o)));
        }
Beispiel #4
0
        /// <summary>
        /// Trace the output of the computation that transformed any input that matches the filter with the given transformation type
        /// </summary>
        /// <param name="trace">The trace component that is used as basis</param>
        /// <param name="rule">The transformation rule that was used to transform the outputs</param>
        /// <param name="filter">The filter that should filter the inputs</param>
        /// <returns>All outputs of computations with suitable input arguments or null, if there are none</returns>
        public static IEnumerable <object> ResolveInWhere(this ITransformationTrace trace, GeneralTransformationRule rule, Predicate <ITraceEntry> filter)
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            return(from ITraceEntry c in trace.TraceAllIn(rule)
                   where filter == null || filter(c)
                   select c.Output);
        }
Beispiel #5
0
        public static IEnumerable <ITraceEntry> TraceInWhere <TIn>(this ITransformationTrace trace, GeneralTransformationRule <TIn> rule, Predicate <TIn> filter) where TIn : class
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            return(from ITraceEntry c in trace.TraceAllIn(rule)
                   where filter == null || filter(c.GetInput(0) as TIn)
                   select c);
        }
Beispiel #6
0
        public static IEnumerable <TOut> ResolveInWhere <TOut>(this ITransformationTrace trace, TransformationRuleBase <TOut> rule, Predicate <object[]> filter)
            where TOut : class
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            return(from ITraceEntry c in trace.TraceAllIn(rule)
                   where filter == null || filter(c.CreateInputArray())
                   select c.Output as TOut);
        }
Beispiel #7
0
        public static IEnumerable <TOut> ResolveInWhere <TIn1, TIn2, TOut>(this ITransformationTrace trace, TransformationRuleBase <TIn1, TIn2, TOut> rule, Func <TIn1, TIn2, bool> filter)
            where TIn1 : class
            where TIn2 : class
            where TOut : class
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            return(from ITraceEntry c in trace.TraceAllIn(rule)
                   where (filter == null || filter(c.GetInput(0) as TIn1, c.GetInput(1) as TIn2))
                   select c.Output as TOut);
        }