再FakeMethodOperator基础上,构建了DelegateOperator
Delegate(
string content,
params NamespaceConverter[] usings
)
Delegate(
string content,
AssemblyDomain domain = default,
bool inCache = false,
bool complieInFile = false,
params NamespaceConverter[] usings
)
var action = DelegateOpeartor<Func<string>>.Delegate("return \"1\";");
action(); //结果是1
同时还有几个方法:
//异步方法
DelegateOpeartor<T>.AsyncDelegate
//非托管方法
DelegateOpeartor<T>.UnsafeDelegate
//异步非托管方法
DelegateOpeartor<T>.UnsafeAsyncDelegate
NamespaceConverter,可以直接扔一个Assembly,或者精确的传Type,或者直接写String.
method(script, "System", assembly, tyypeof(Console));
由于是可变参数,所以你可以传多种多个
method(script, "System", "System", "System");
method(script, assembly, assembly, assembly);
method(script, tyypeof(Console), tyypeof(Console), tyypeof(Console));