我可以从两个方面来解释系统调用的含义:
-
ISystemTarget
-
对Orleans程序集中定义的接口的任何调用
在这两种情况下,确定调用是否符合该条件的最简单方法是使用
InterfaceMethod
传递给调用筛选器以检查
DeclaringType
MethodInfo
.
例如:
siloBuilder.AddOutgoingGrainCallFilter(async context =>
{
var declaringType = context.InterfaceMethod?.DeclaringType;
// Check if the type being called belongs to one of the Orleans assemblies
// systemAssemblies here is a HashSet<Assembly> containing the Orleans assemblies
var isSystemAssembly = declaringType != null
&& systemAssemblies.Contains(declaringType.Assembly);
// Check if the type is an ISystemTarget
var systemTarget = declaringType != null
&& typeof(ISystemTarget).IsAssignableFrom(declaringType);
if (isSystemAssembly || systemTarget)
{
// This is a system call, so just continue invocation without any further action
await context.Invoke();
}
else
{
// This is an application call
// ... Inspect/modify the arguments here ...
await context.Invoke();
// ... inspect/modify return value here ...
}
})