本文整理汇总了C#中System.Runtime.CompilerServices.CallSite类的典型用法代码示例。如果您正苦于以下问题:C# CallSite类的具体用法?C# CallSite怎么用?C# CallSite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CallSite类属于System.Runtime.CompilerServices命名空间,在下文中一共展示了CallSite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IOWrapper
public IOWrapper(RubyContext/*!*/ context, object io, bool canRead, bool canWrite, bool canSeek, bool canFlush, bool canBeClosed, int bufferSize) {
Assert.NotNull(context);
_writeSite = CallSite<Func<CallSite, object, object, object>>.Create(
RubyCallAction.Make(context, "write", RubyCallSignature.WithImplicitSelf(1))
);
_readSite = CallSite<Func<CallSite, object, object, object>>.Create(
RubyCallAction.Make(context, "read", RubyCallSignature.WithImplicitSelf(1))
);
_seekSite = CallSite<Func<CallSite, object, object, object, object>>.Create(
RubyCallAction.Make(context, "seek", RubyCallSignature.WithImplicitSelf(2))
);
_tellSite = CallSite<Func<CallSite, object, object>>.Create(
RubyCallAction.Make(context, "tell", RubyCallSignature.WithImplicitSelf(0))
);
_obj = io;
_canRead = canRead;
_canWrite = canWrite;
_canSeek = canSeek;
_canFlush = canFlush;
_canBeClosed = canBeClosed;
_buffer = new byte[bufferSize];
_writePos = 0;
_readPos = 0;
_readLen = 0;
}
示例2: DynamicInstructionN
public DynamicInstructionN(Type delegateType, CallSite site) {
var methodInfo = delegateType.GetMethod("Invoke");
_target = ReflectedCaller.Create(methodInfo);
_targetField = site.GetType().GetField("Target");
_site = site;
_argCount = methodInfo.GetParameters().Length;
}
示例3: RubyRepresenter
public RubyRepresenter(RubyContext/*!*/ context, Serializer/*!*/ serializer, YamlOptions/*!*/ opts)
: base(serializer, opts) {
_context = context;
_objectToYamlMethod = context.GetClass(typeof(object)).ResolveMethod("to_yaml", VisibilityContext.AllVisible).Info;
_TagUri =
CallSite<Func<CallSite, object, object>>.Create(
RubyCallAction.Make(context, "taguri", RubyCallSignature.WithImplicitSelf(0))
);
_ToYamlStyle =
CallSite<Func<CallSite, object, object>>.Create(
RubyCallAction.Make(context, "to_yaml_style", RubyCallSignature.WithImplicitSelf(0))
);
_ToYamlNode =
CallSite<Func<CallSite, object, RubyRepresenter, object>>.Create(
RubyCallAction.Make(context, "to_yaml_node", RubyCallSignature.WithImplicitSelf(1))
);
_ToYaml =
CallSite<Func<CallSite, object, RubyRepresenter, object>>.Create(
RubyCallAction.Make(context, "to_yaml", RubyCallSignature.WithImplicitSelf(0))
);
_ToYamlProperties =
CallSite<Func<CallSite, object, object>>.Create(
RubyCallAction.Make(context, "to_yaml_properties", RubyCallSignature.WithImplicitSelf(0))
);
}
示例4: DynamicInstructionN
public DynamicInstructionN(Type delegateType, CallSite site)
{
MethodInfo method = delegateType.GetMethod("Invoke");
ParameterInfo[] parameters = method.GetParameters();
this._target = CallInstruction.Create(method, parameters);
this._site = site;
this._argumentCount = parameters.Length - 1;
this._targetDelegate = site.GetType().GetField("Target").GetValue(site);
}
示例5: DynamicInstructionN
public DynamicInstructionN(Type delegateType, CallSite site) {
var methodInfo = delegateType.GetMethod("Invoke");
var parameters = methodInfo.GetParameters();
_target = CallInstruction.Create(methodInfo, parameters);
_targetField = site.GetType().GetField("Target");
_site = site;
_argCount = parameters.Length;
}
示例6: DynamicInstructionN
public DynamicInstructionN(Type delegateType, CallSite site) {
var methodInfo = delegateType.GetMethod("Invoke");
var parameters = methodInfo.GetParameters();
// <Delegate>.Invoke is ok to target by a delegate in partial trust (SecurityException is not thrown):
_targetInvocationInstruction = CallInstruction.Create(methodInfo, parameters);
_site = site;
_argumentCount = parameters.Length - 1;
_targetDelegate = site.GetType().GetInheritedFields("Target").First().GetValue(site);
}
示例7: RubyConstructor
public RubyConstructor(RubyGlobalScope/*!*/ scope, NodeProvider/*!*/ nodeProvider)
: base(nodeProvider, scope) {
_newSite = CallSite<Func<CallSite, RubyModule, object, object, object, object>>.Create(
RubyCallAction.Make(scope.Context, "new", RubyCallSignature.WithImplicitSelf(3))
);
_yamlInitializeSite = CallSite<Func<CallSite, object, object, Hash, object>>.Create(
RubyCallAction.Make(scope.Context, "yaml_initialize", RubyCallSignature.WithImplicitSelf(3))
);
}
示例8: 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);
}
示例9: CastToPath
/// <summary>
/// Converts an object to string using to_path-to_str protocol.
/// Protocol:
/// ? to_path => to_path() and to_str conversion on the result
/// ? to_str => to_str()
/// </summary>
public static MutableString/*!*/ CastToPath(CallSite<Func<CallSite, object, MutableString>>/*!*/ toPath, object obj) {
MutableString result = toPath.Target(toPath, obj);
if (result == null) {
throw RubyExceptions.CreateTypeConversionError("nil", "String");
}
return result;
}
示例10: FinalizerInvoker
public FinalizerInvoker(CallSite<Func<CallSite, object, object, object>>/*!*/ callSite, object finalizer)
{
Assert.NotNull(callSite);
_callSite = callSite;
_finalizer = finalizer;
}
示例11: defaultdict
public defaultdict(CodeContext/*!*/ context) {
_missingSite = CallSite<Func<CallSite, CodeContext, object, object>>.Create(
new PythonInvokeBinder(
PythonContext.GetContext(context),
new CallSignature(0)
)
);
}
示例12: LessThanObjUInt
public static object LessThanObjUInt (CallSite site, object a, uint b)
{
#if BINDERS_RUNTIME_STATS
Stats.Increment(StatsCounter.BinaryOperationBinderInvoked);
#endif
if (a is uint)
{
return (uint)a < b;
}
if ((a == null) || (a == PlayScript.Undefined._undefined))
{
return false;
}
return Convert.ToDouble(a) < (double)b;
}
示例13: ShiftRightDoubleObj
public static object ShiftRightDoubleObj (CallSite site, double a, object b)
{
#if BINDERS_RUNTIME_STATS
Stats.Increment(StatsCounter.BinaryOperationBinderInvoked);
#endif
if ((b == null) || (b == PlayScript.Undefined._undefined))
{
return a;
}
return (int)a >> Convert.ToInt32(b);
}
示例14: XorObjBool
public static object XorObjBool (CallSite site, object a, bool b)
{
#if BINDERS_RUNTIME_STATS
Stats.Increment(StatsCounter.BinaryOperationBinderInvoked);
#endif
return Dynamic.CastObjectToBool(a) ^ b;
}
示例15: XorUIntObj
public static object XorUIntObj (CallSite site, uint a, object b)
{
#if BINDERS_RUNTIME_STATS
Stats.Increment(StatsCounter.BinaryOperationBinderInvoked);
#endif
if ((b == null) || (b == PlayScript.Undefined._undefined))
{
return a;
}
return a ^ Convert.ToUInt32(b);
}