/// <summary> /// Performs evaluation & replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> public static Expression PartialEval(Expression expression) { using (var ls = new LoggingScope("Evaluator.PartialEval1")) { return PartialEval(expression, CanBeEvaluatedLocally); } }
/// <summary> /// Performs evaluation & replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> public static Expression PartialEval(Expression expression) { using (var ls = new LoggingScope("Evaluator.PartialEval1")) { return(PartialEval(expression, CanBeEvaluatedLocally)); } }
/// <summary> /// Performs evaluation & replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <param name="fnCanBeEvaluated">A function that decides whether a given expression node can be part of the local function.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> public static Expression PartialEval(Expression expression, Func<Expression, bool> fnCanBeEvaluated) { using (var ls = new LoggingScope("Evaluator.PartialEval3")) { return new SubtreeEvaluator(new Nominator(fnCanBeEvaluated).Nominate(expression)).Eval(expression); } }
/// <summary> /// Performs evaluation & replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <param name="fnCanBeEvaluated">A function that decides whether a given expression node can be part of the local function.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> public static Expression PartialEval(Expression expression, Func <Expression, bool> fnCanBeEvaluated) { using (var ls = new LoggingScope("Evaluator.PartialEval3")) { return(new SubtreeEvaluator(new Nominator(fnCanBeEvaluated).Nominate(expression)).Eval(expression)); } }
public static Func <T, T> On <T>(this Func <T, T> inner, Func <T, T> outer) { using (var ls = new LoggingScope("On")) { return(t => outer(inner(t))); } }
public static bool ContainsAnyOf <T>(this IEnumerable <T> seq, IEnumerable <T> x) { using (var ls = new LoggingScope("ContainsAnyOf")) { bool result = false; x.ForEach(a => result |= seq.Contains(a)); return(result); } }
public static void ForEach <T>(this IEnumerable <T> seq, Action <T> task) { using (var ls = new LoggingScope("ForEach")) { foreach (T t in seq) { task(t); } } }
/// <summary> /// Applies a function <see cref="f"/> to the sequence <see cref="seq"/> yielding a new sequence of <see cref="R"/>. /// </summary> /// <typeparam name="T">The type of the original sequence</typeparam> /// <typeparam name="R">the type of the new sequence</typeparam> /// <param name="seq">The sequence on which the function <see cref="f"/> will be applied.</param> /// <param name="f">The function to apply to each element of <see cref="seq"/>.</param> /// <returns>a new sequence containing the results of applying <see cref="f"/> to <see cref="seq"/></returns> public static IEnumerable <R> Map <T, R>(this IEnumerable <T> seq, Func <T, R> f) { using (var ls = new LoggingScope("Map")) { foreach (T t in seq) { yield return(f(t)); } } }
public static void Add(this IInMemoryQueryableStore ms, OwlInstanceSupertype oc) { using (var ls = new LoggingScope("MemoryStoreExtensions.Add")) { Type t = oc.GetType(); Console.WriteLine(oc.InstanceUri); PropertyInfo[] pia = t.GetProperties(); IGraph g = ms.GetDefaultGraph(); g.Assert(g.CreateUriNode(new Uri(oc.InstanceUri)), g.CreateUriNode(new Uri(RdfSpecsHelper.RdfType)), g.CreateUriNode(new Uri(OwlClassSupertype.GetOwlClassUri(t)))); foreach (PropertyInfo pi in pia) { if (pi.IsOntologyResource()) { AddPropertyToStore(oc, pi, ms); } } } }