本文整理汇总了C#中CallSite类的典型用法代码示例。如果您正苦于以下问题:C# CallSite类的具体用法?C# CallSite怎么用?C# CallSite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CallSite类属于命名空间,在下文中一共展示了CallSite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStandAloneSignature
public MetadataToken GetStandAloneSignature(CallSite call_site)
{
var signature = metadata.GetCallSiteBlobIndex(call_site);
var token = GetStandAloneSignatureToken(signature);
call_site.MetadataToken = token;
return token;
}
示例2: Create
public Instruction Create (OpCode opcode, CallSite site)
{
if (site == null)
throw new ArgumentNullException ("site");
if (opcode.Code != Code.Calli)
throw new ArgumentException ("code");
return FinalCreate (opcode, site);
}
示例3: Invoke
internal object Invoke(object[] args) {
Debug.Assert(args != null);
// If it is a delegate, just let DynamicInvoke do the binding.
var d = _callable as Delegate;
if (d != null) {
return d.DynamicInvoke(args);
}
// Otherwise, create a CallSite and invoke it.
if (_site == null) {
_site = CallSite<Func<CallSite, object, object[], object>>.Create(SplatInvokeBinder.Instance);
}
return _site.Target(_site, _callable, args);
}
示例4: FunctionPointerEvaluator
public FunctionPointerEvaluator(StackValue pointer, Interpreter dsi)
{
Validity.Assert(pointer.optype == AddressType.FunctionPointer);
mRunTime = dsi;
Core core = dsi.runtime.Core;
int fptr = (int)pointer.opdata;
ProtoCore.DSASM.FunctionPointerNode fptrNode;
if (core.FunctionPointerTable.functionPointerDictionary.TryGetByFirst(fptr, out fptrNode))
{
int blockId = fptrNode.blockId;
int procId = fptrNode.procId;
mProcNode = dsi.runtime.exe.procedureTable[blockId].procList[procId];
}
mCallSite = new ProtoCore.CallSite(ProtoCore.DSASM.Constants.kGlobalScope, Name, core.FunctionTable, core.Options.ExecutionMode);
}
示例5: FunctionPointerEvaluator
public FunctionPointerEvaluator(StackValue pointer, Interpreter dsi)
{
Validity.Assert(pointer.IsFunctionPointer);
interpreter = dsi;
RuntimeCore runtimeCore = dsi.runtime.RuntimeCore;
int fptr = (int)pointer.opdata;
FunctionPointerNode fptrNode;
int classScope = Constants.kGlobalScope;
if (runtimeCore.DSExecutable.FuncPointerTable.functionPointerDictionary.TryGetByFirst(fptr, out fptrNode))
{
int blockId = fptrNode.blockId;
int procId = fptrNode.procId;
classScope = fptrNode.classScope;
procNode = dsi.runtime.GetProcedureNode(blockId, classScope, procId);
}
callsite = new ProtoCore.CallSite(classScope, Name, interpreter.runtime.exe.FunctionTable, runtimeCore.Options.ExecutionMode);
}
示例6: Action1
// readonly CSharpBinderFlags flags;
// List<CSharpArgumentInfo> argumentInfo;
// Type callingContext;
public static void Action1 (CallSite site, object o1)
{
((Delegate)o1).DynamicInvoke(null);
}
示例7: Action2
public static void Action2 (CallSite site, object o1, object o2)
{
((Delegate)o1).DynamicInvoke(new [] { o2 });
}
示例8: FindMethodForType
private MethodInfo FindMethodForType(CallSite site, System.Type otype, string name, bool isStatic, object[] args, out object[] outArgs)
{
BindingFlags bindingFlags = isStatic ? BindingFlags.Static | BindingFlags.FlattenHierarchy : BindingFlags.Instance;
var methods = otype.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | bindingFlags);
var len = methods.Length;
for (var mi = 0; mi < len; mi++) {
var m = methods[mi];
if ((m.IsStatic == isStatic) && m.Name == name) {
// attempt to convert method parameters
if (Dynamic.ConvertMethodParameters(m, args, out outArgs)) {
return m;
}
}
}
// method not found
outArgs = null;
return null;
}
示例9: InvokeAction7
private static void InvokeAction7 (CallSite site, object o, object a1, object a2, object a3, object a4,
object a5, object a6, object a7)
{
var binder = ((CSharpInvokeMemberBinder)site.Binder);
var info = binder.invokeInfo;
object[] args;
if (info == null || !info.InvokeMatches(o, a1, a2, a3, a4, a5, a6, a7)) {
binder.FindMethod (site, o, new [] { a1, a2, a3, a4, a5, a6, a7 });
info = binder.invokeInfo;
args = info.args;
} else {
args = info.args;
args[0] = a1; args[1] = a2; args[2] = a3; args[3] = a4; args[4] = a5; args[5] = a6; args[6] = a7;
}
if (info.method != null)
info.method.Invoke (o, args);
else
info.del.DynamicInvoke(null, args);
}
示例10: Func2
public static object Func2 (CallSite site, object o1, object o2)
{
return ((Delegate)o1).DynamicInvoke(new [] { o2 });
}
示例11: Func7
public static object Func7 (CallSite site, object o1, object o2, object o3, object o4, object o5, object o6, object o7)
{
return ((Delegate)o1).DynamicInvoke(new [] { o2, o3, o4, o5, o6, o7 });
}
示例12: Func2
public static object Func2 (CallSite site, object o1, object o2)
{
return InvokeConstructor((Type)o1, new [] { o2 });
}
示例13: Action10
public static void Action10 (CallSite site, object o1, object o2, object o3, object o4, object o5, object o6, object o7, object o8, object o9, object o10)
{
((Delegate)o1).DynamicInvoke(new [] { o2, o3, o4, o5, o6, o7, o8, o10 });
}
示例14: FindMethod
public void FindMethod (CallSite site, object o, object[] args)
{
if (o == null) {
throw new NullReferenceException ();
}
InvokeInfo info = this.invokeInfo;
if (info == null) {
info = new InvokeInfo();
info.lastObj = new WeakReference (o);
info.lastArgTypes = new Type[args.Length];
this.invokeInfo = info;
} else {
this.invokeInfo.lastObj.Target = o;
}
var arg_len = args.Length;
for (var i = 0; i < arg_len; i++) {
info.lastArgTypes[i] = (args != null && args[i]!=null) ? args[i].GetType () : null;
}
if (o is ExpandoObject) {
var expando = (ExpandoObject)o;
// special case .hasOwnProperty here
if (name == "hasOwnProperty")
{
info.method = o.GetType().GetMethod("hasOwnProperty");
info.args = args;
info.del = null;
info.generation = 0;
}
else
{
object delObj;
expando.TryGetValue(name, out delObj);
Delegate del = delObj as Delegate;
if (del == null) {
throw new Exception ("No delegate found with the name '" + name + "'");
}
info.method = null;
info.del = del;
info.generation = expando.Generation;
}
} else {
MethodInfo method = null;
bool isStatic;
System.Type otype;
if (o is System.Type) {
// this is a static method invocation where o is the class
isStatic = true;
otype = (System.Type)o;
} else {
// this is a non-static method invocation
isStatic = false;
otype = o.GetType();
}
// find method for type that matches argument list
method = FindMethodForType(site, otype, name, isStatic, args, out info.args);
if (method == null) {
if (!isStatic) {
// find extension methods
method = FindExtensionMethodForType(site, otype, name, o, args, out info.args);
}
if (method == null) {
throw new Exception("No matching method found for the type '" + otype.FullName + "' with the name '" + name + "'");
}
}
info.method = method;
info.del = null;
info.generation = 0;
}
}
示例15: Func1
public static object Func1 (CallSite site, object o1)
{
return InvokeConstructor((Type)o1, new object[] {});
}