С учетом
Action<BaseText,List<object>> f = (BaseTest baseO, List<object> objects) => {
foreach(var t in objects) {
baseTest.IsNotNull = t;
}
};
Тогда f.Method
должно быть то, что вам нужно, я думаю:
var t = Utils.DynamicInherit<BaseTest>("Extended",f.Method, extendwith);
Кроме того, вы можете объединить все это:
var t = Utils.DynamicInherit<BaseTest>("Extended",((Action<BaseTest,List<object>>)((baseO, objects) => {foreach(var t in objects)
{
baseTest.IsNotNull = t;
}})).Method,
extendwith);
Использование имеющегося у меня служебного класса немного облегчает чтение:
public static class To {
public static Func<TResult> Func<TResult>(Func<TResult> func) => func;
public static Func<T, TResult> Func<T, TResult>(Func<T, TResult> func) => func;
public static Func<T1, T2, TResult> Func<T1, T2, TResult>(Func<T1, T2, TResult> func) => func;
public static Func<T1, T2, T3, TResult> Func<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> func) => func;
public static Func<T1, T2, T3, T4, TResult> Func<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> func) => func;
public static Func<T1, T2, T3, T4, T5, TResult> Func<T1, T2, T3, T4, T5, TResult>(Func<T1, T2, T3, T4, T5, TResult> func) => func;
public static Func<T1, T2, T3, T4, T5, T6, TResult> Func<T1, T2, T3, T4, T5, T6, TResult>(Func<T1, T2, T3, T4, T5, T6, TResult> func) => func;
public static Func<T1, T2, T3, T4, T5, T6, T7, TResult> Func<T1, T2, T3, T4, T5, T6, T7, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, TResult> func) => func;
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> func) => func;
public static Action<T> Action<T>(Action<T> act) => act;
public static Action<T1, T2> Action<T1, T2>(Action<T1, T2> act) => act;
public static Action<T1, T2, T3> Action<T1, T2, T3>(Action<T1, T2, T3> act) => act;
public static Action<T1, T2, T3, T4> Action<T1, T2, T3, T4>(Action<T1, T2, T3, T4> act) => act;
public static Action<T1, T2, T3, T4, T5> Action<T1, T2, T3, T4, T5>(Action<T1, T2, T3, T4, T5> act) => act;
public static Action<T1, T2, T3, T4, T5, T6> Action<T1, T2, T3, T4, T5, T6>(Action<T1, T2, T3, T4, T5, T6> act) => act;
public static Action<T1, T2, T3, T4, T5, T6, T7> Action<T1, T2, T3, T4, T5, T6, T7>(Action<T1, T2, T3, T4, T5, T6, T7> act) => act;
public static Action<T1, T2, T3, T4, T5, T6, T7, T8> Action<T1, T2, T3, T4, T5, T6, T7, T8>(Action<T1, T2, T3, T4, T5, T6, T7, T8> act) => act;
}
Тогда у вас просто есть:
var t = Utils.DynamicInherit<BaseTest>("Extended", To.Action((baseO, objects) => {
foreach(var t in objects) {
baseTest.IsNotNull = t;
}}).Method,
extendwith);