WEB开发网
开发学院软件开发C语言 [C# 4.0] 1. Dynamic 阅读

[C# 4.0] 1. Dynamic

 2010-09-30 21:04:24 来源:WEB开发网   
核心提示: 我们首先看看 Binder.InvokeMemeber() 到底干了什么。publicstaticclassBinder{publicstaticCallSiteBinderInvokeMember(CSharpBinderFlagsflags,stringname,IEnumerable<

我们首先看看 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; }
}

上一页  1 2 3 4 5 6 7 8  下一页

Tags:Dynamic

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接