public static Func<dynamic> Evaluate(this Func<dynamic> unknown, Func<dynamic> fact)
        {
            if (unknown.FullMatch(fact))
                return unknown.CalculateFrom(fact);

            if (unknown.FullMatch(fact.Invert()))
                return unknown.CalculateFrom(fact.Invert());

            return null;
        }
        public static Func<dynamic> ConvertTo(this Func<dynamic> from, Func<dynamic> to)
        {
            if (from.LeftMatchesLeft(to))
                return from.ConvertRightPartToRight(to);

            if (from.LeftMatchesLeft(to.Invert()))
                return from.ConvertRightPartToRight(to.Invert());

            if (from.Invert().LeftMatchesLeft(to))
                return from.Invert().ConvertRightPartToRight(to);

            if (from.Invert().LeftMatchesLeft(to.Invert()))
                return from.Invert().ConvertRightPartToRight(to.Invert());

            return null;
        }
Example #3
0
 public static Delegate RemoveAll(this Delegate dlg, Func<Delegate, bool> pred)
 {
     return Delegate.Combine(dlg.GetInvocationList()
         .Where(pred.Invert())
         .ToArray());
 }