[C# 4.0] 1. Dynamic
2010-09-30 21:04:24 来源:WEB开发网我们首先看看 Binder.InvokeMemeber() 到底干了什么。
public static class Binder
{
public static CallSiteBinder InvokeMember(CSharpBinderFlags flags, string name,
IEnumerable<Type> typeArguments, Type context,
IEnumerable<CSharpArgumentInfo> argumentInfo)
{
bool flag = (flags & CSharpBinderFlags.InvokeSimpleName) != CSharpBinderFlags.None;
bool flag2 = (flags & CSharpBinderFlags.InvokeSpecialName) != CSharpBinderFlags.None;
bool flag3 = (flags & CSharpBinderFlags.ResultDiscarded) != CSharpBinderFlags.None;
CSharpCallFlags none = CSharpCallFlags.None;
if (flag)
{
none |= CSharpCallFlags.SimpleNameCall;
}
if (flag2)
{
none |= CSharpCallFlags.EventHookup;
}
if (flag3)
{
none |= CSharpCallFlags.ResultDiscarded;
}
return new CSharpInvokeMemberBinder(none, name, context, typeArguments, argumentInfo);
}
}
internal sealed class CSharpInvokeMemberBinder : InvokeMemberBinder, ICSharpInvokeOrInvokeMemberBinder
{
// Methods
public CSharpInvokeMemberBinder(CSharpCallFlags flags, string name, Type callingContext,
IEnumerable<Type> typeArguments, IEnumerable<CSharpArgumentInfo> argumentInfo);
public override DynamicMetaObject FallbackInvoke(DynamicMetaObject target, DynamicMetaObject[] args,
DynamicMetaObject errorSuggestion);
public override DynamicMetaObject FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args,
DynamicMetaObject errorSuggestion);
// Properties
IList<CSharpArgumentInfo> ICSharpInvokeOrInvokeMemberBinder.ArgumentInfo { get; }
Type ICSharpInvokeOrInvokeMemberBinder.CallingContext { get; }
CSharpCallFlags ICSharpInvokeOrInvokeMemberBinder.Flags { get; }
string ICSharpInvokeOrInvokeMemberBinder.Name { get; }
bool ICSharpInvokeOrInvokeMemberBinder.ResultDiscarded { get; }
bool ICSharpInvokeOrInvokeMemberBinder.StaticCall { get; }
IList<Type> ICSharpInvokeOrInvokeMemberBinder.TypeArguments { get; }
}
更多精彩
赞助商链接