本文整理汇总了C#中DynamicMetaObjectBinder类的典型用法代码示例。如果您正苦于以下问题:C# DynamicMetaObjectBinder类的具体用法?C# DynamicMetaObjectBinder怎么用?C# DynamicMetaObjectBinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DynamicMetaObjectBinder类属于命名空间,在下文中一共展示了DynamicMetaObjectBinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeStandardDotNetTypeCall
/// <summary>
/// Creating a standard .NET type is easy - we just call it's constructor with the provided
/// arguments.
/// </summary>
private DynamicMetaObject/*!*/ MakeStandardDotNetTypeCall(DynamicMetaObjectBinder/*!*/ call, Expression/*!*/ codeContext, DynamicMetaObject/*!*/[]/*!*/ args) {
CallSignature signature = BindingHelpers.GetCallSignature(call);
BinderState state = BinderState.GetBinderState(call);
MethodBase[] ctors = CompilerHelpers.GetConstructors(Value.UnderlyingSystemType, state.Binder.PrivateBinding);
if (ctors.Length > 0) {
return state.Binder.CallMethod(
new ParameterBinderWithCodeContext(state.Binder, codeContext),
ctors,
args,
signature,
Restrictions.Merge(BindingRestrictions.GetInstanceRestriction(Expression, Value))
);
} else {
return new DynamicMetaObject(
Ast.Throw(
Ast.New(
typeof(ArgumentTypeException).GetConstructor(new Type[] { typeof(string) }),
Ast.Constant("Cannot create instances of " + Value.Name)
)
),
Restrictions.Merge(BindingRestrictions.GetInstanceRestriction(Expression, Value))
);
}
}
示例2: ConvertWorker
public DynamicMetaObject ConvertWorker(DynamicMetaObjectBinder binder, Type toType, ConversionResultKind kind) {
if (toType.IsSubclassOf(typeof(Delegate))) {
return MakeDelegateTarget(binder, toType, Restrict(typeof(Method)));
}
return FallbackConvert(binder);
}
示例3: IsNoThrow
internal static bool IsNoThrow(DynamicMetaObjectBinder action) {
PythonGetMemberBinder gmb = action as PythonGetMemberBinder;
if (gmb != null) {
return gmb.IsNoThrow;
}
return false;
}
示例4: Dynamic
public Expression Dynamic(DynamicMetaObjectBinder binder, Type retType, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
{
if(retType == typeof(object))
return new TotemDynamicExpression4(binder, this, arg0, arg1, arg2, arg3);
else if(retType == typeof(bool))
return new TotemDynamicExpression4<bool>(binder, this, arg0, arg1, arg2, arg3);
return ReduceDynamic(binder, retType, arg0, arg1, arg2, arg3);
}
示例5: ConvertWorker
public DynamicMetaObject ConvertWorker(DynamicMetaObjectBinder binder, Type toType, ConversionResultKind kind) {
PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "BuiltinFunc Convert " + toType);
PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "BuiltinFunc Convert");
if (toType.IsSubclassOf(typeof(Delegate))) {
return MakeDelegateTarget(binder, toType, Restrict(LimitType));
}
return FallbackConvert(binder);
}
示例6: ConvertWorker
public DynamicMetaObject ConvertWorker(DynamicMetaObjectBinder binder, Type type, Type retType, ConversionResultKind kind) {
PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "Conversion " + type.FullName);
PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "Conversion");
ValidationInfo typeTest = BindingHelpers.GetValidationInfo(this, Value.PythonType);
return BindingHelpers.AddDynamicTestAndDefer(
binder,
TryPythonConversion(binder, type) ?? FallbackConvert(binder),
new DynamicMetaObject[] { this },
typeTest,
retType
);
}
示例7: Dynamic
/*!*/
public MSAst.Expression Dynamic(DynamicMetaObjectBinder/*!*/ binder, Type/*!*/ retType, MSAst.Expression/*!*/ arg0)
{
if (retType == typeof(object))
{
throw new NotImplementedException();
//return new TotemDynamicExpression1(binder, this, arg0);
}
else if (retType == typeof(bool))
{
throw new NotImplementedException();
//return new TotemDynamicExpression1<bool>(binder, this, arg0);
}
return ReduceDynamic(binder, retType, arg0);
}
示例8: InvokeWorker
private DynamicMetaObject/*!*/ InvokeWorker(DynamicMetaObjectBinder/*!*/ call, Expression/*!*/ codeContext, DynamicMetaObject/*!*/[] args) {
PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "BuiltinMethodDesc Invoke " + Value.DeclaringType + "." + Value.__name__ + " w/ " + args.Length + " args");
PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "BuiltinMethodDesc Invoke");
CallSignature signature = BindingHelpers.GetCallSignature(call);
BindingRestrictions selfRestrict = BindingRestrictions.GetInstanceRestriction(Expression, Value).Merge(Restrictions);
selfRestrict = selfRestrict.Merge(
BindingRestrictions.GetExpressionRestriction(
MakeFunctionTest(
Ast.Call(
typeof(PythonOps).GetMethod("GetBuiltinMethodDescriptorTemplate"),
Ast.Convert(Expression, typeof(BuiltinMethodDescriptor))
)
)
)
);
return Value.Template.MakeBuiltinFunctionCall(
call,
codeContext,
this,
args,
false, // no self
selfRestrict,
(newArgs) => {
BindingTarget target;
PythonContext state = PythonContext.GetPythonContext(call);
DynamicMetaObject res = state.Binder.CallMethod(
new PythonOverloadResolver(
state.Binder,
newArgs,
signature,
codeContext
),
Value.Template.Targets,
selfRestrict,
Value.Template.Name,
NarrowingLevel.None,
Value.Template.IsBinaryOperator ? PythonNarrowing.BinaryOperator : NarrowingLevel.All,
out target
);
return BindingHelpers.CheckLightThrow(call, res, target);
});
}
示例9: InvokeWorker
private DynamicMetaObject/*!*/ InvokeWorker(DynamicMetaObjectBinder/*!*/ call, DynamicMetaObject/*!*/[]/*!*/ args, Expression/*!*/ codeContext) {
if (this.NeedsDeferral()) {
return call.Defer(ArrayUtils.Insert(this, args));
}
for (int i = 0; i < args.Length; i++) {
if (args[i].NeedsDeferral()) {
return call.Defer(ArrayUtils.Insert(this, args));
}
}
if (IsStandardDotNetType(call)) {
return MakeStandardDotNetTypeCall(call, codeContext, args);
}
return MakePythonTypeCall(call, codeContext, args);
}
示例10: FunctionBinderHelper
public FunctionBinderHelper(DynamicMetaObjectBinder call, MetaTotemFunction function, Expression codeContext, DynamicMetaObject[] args)
{
PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "TotemFunction Invoke " + function.Value.FunctionCompatibility + " w/ " + args.Length + " args");
PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "TotemFunction");
_call = call;
_func = function;
_args = args;
_originalArgs = args;
_temps = new List<ParameterExpression>();
_codeContext = codeContext;
// Remove the passed in instance argument if present
int instanceIndex = Signature.IndexOf(ArgumentType.Instance);
if (instanceIndex > -1)
_args = ArrayUtils.RemoveAt(_args, instanceIndex);
}
示例11: FilterShowCls
internal static DynamicMetaObject/*!*/ FilterShowCls(Expression/*!*/ codeContext, DynamicMetaObjectBinder/*!*/ action, DynamicMetaObject/*!*/ res, Expression/*!*/ failure) {
if (action is IPythonSite) {
return new DynamicMetaObject(
Ast.Condition(
Ast.Call(
typeof(PythonOps).GetMethod("IsClsVisible"),
codeContext
),
AstUtils.Convert(res.Expression, typeof(object)),
AstUtils.Convert(failure, typeof(object))
),
res.Restrictions
);
}
return res;
}
示例12: InvokeWorker
private DynamicMetaObject/*!*/ InvokeWorker(DynamicMetaObjectBinder/*!*/ call, DynamicMetaObject/*!*/[]/*!*/ args, Expression/*!*/ codeContext) {
PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "Type Invoke " + Value.UnderlyingSystemType.FullName + args.Length);
PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "Type Invoke");
if (this.NeedsDeferral()) {
return call.Defer(ArrayUtils.Insert(this, args));
}
for (int i = 0; i < args.Length; i++) {
if (args[i].NeedsDeferral()) {
return call.Defer(ArrayUtils.Insert(this, args));
}
}
if (IsStandardDotNetType(call)) {
return MakeStandardDotNetTypeCall(call, codeContext, args);
}
return MakePythonTypeCall(call, codeContext, args);
}
示例13: FilterShowCls
internal static DynamicMetaObject/*!*/ FilterShowCls(Expression/*!*/ codeContext, DynamicMetaObjectBinder/*!*/ action, DynamicMetaObject/*!*/ res, Expression/*!*/ failure) {
if (action is IPythonSite) {
Type resType = BindingHelpers.GetCompatibleType(res.Expression.Type, failure.Type);
return new DynamicMetaObject(
Ast.Condition(
Ast.Call(
typeof(PythonOps).GetMethod("IsClsVisible"),
codeContext
),
AstUtils.Convert(res.Expression, resType),
AstUtils.Convert(failure, resType)
),
res.Restrictions
);
}
return res;
}
示例14: InvokeWorker
private DynamicMetaObject/*!*/ InvokeWorker(DynamicMetaObjectBinder/*!*/ call, Expression/*!*/ codeContext, DynamicMetaObject/*!*/[]/*!*/ args) {
PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "BuiltinFunc Invoke " + Value.DeclaringType.FullName + "." + Value.Name + " with " + args.Length + " args " + Value.IsUnbound);
PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "BuiltinFunction " + Value.Targets.Count + ", " + Value.Targets[0].GetParameters().Length);
PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, "BuiltinFunction " + BindingHelpers.GetCallSignature(call));
if (this.NeedsDeferral()) {
return call.Defer(ArrayUtils.Insert(this, args));
}
for (int i = 0; i < args.Length; i++) {
if (args[i].NeedsDeferral()) {
return call.Defer(ArrayUtils.Insert(this, args));
}
}
if (Value.IsUnbound) {
return MakeSelflessCall(call, codeContext, args);
} else {
return MakeSelfCall(call, codeContext, args);
}
}
示例15: MakeConvertToBool
private DynamicMetaObject/*!*/ MakeConvertToBool(DynamicMetaObjectBinder/*!*/ conversion) {
DynamicMetaObject self = Restrict(typeof(OldInstance));
ParameterExpression tmp = Ast.Variable(typeof(bool?), "tmp");
DynamicMetaObject fallback = FallbackConvert(conversion);
Type resType = BindingHelpers.GetCompatibleType(typeof(bool), fallback.Expression.Type);
return new DynamicMetaObject(
Ast.Block(
new ParameterExpression[] { tmp },
Ast.Condition(
Ast.NotEqual(
Ast.Assign(
tmp,
Ast.Call(
typeof(PythonOps).GetMethod("OldInstanceConvertToBoolNonThrowing"),
AstUtils.Constant(PythonContext.GetPythonContext(conversion).SharedContext),
self.Expression
)
),
AstUtils.Constant(null)
),
AstUtils.Convert(tmp, resType),
AstUtils.Convert(fallback.Expression, resType)
)
),
self.Restrictions
);
}