DocumentBuilder documentBuilder = new DocumentBuilder(documentModel, p => Container.AddPage(p));红色部分是个委托。类(class)DocumentBuilder的部分源代码是
 public DocumentBuilder(Model.Document documentModel, Action<PageControl> addPageToParent)
    {
      if (documentModel == null)
        throw new ArgumentNullException("documentModel");
      if (addPageToParent == null)
        throw new ArgumentNullException("addPageToParent");      _documentModel = documentModel;
      _addPageToParent = addPageToParent;
    }明显的构造函数的第2个参数是委托。我想问的问题是,这个委托时发生在DocumentBulider构造之前,还是构造之后。
谢谢。

解决方案 »

  1.   

    http://msdn.microsoft.com/zh-cn/library/ms173172(VS.80).aspx自己断点跟一下。
      

  2.   

    好像根本不会触发吧弄不明白一点:
    你的p是什么东西?
    是Action<PageControl>吗?
    那几句编译能通过吗?
      

  3.   

    这个委托是在别的地方构造好了,作为参数传进来填充DocumentBuilder
    但委托构造好了不会执行,只有事件触发后才会执行
      

  4.   

    " 这个委托时发生在DocumentBulider构造之前,还是构造之后。 "
    我不清楚你要实现什么,这里其都没有调用的, 因为你的构造中根本没有调用你的委拖,Action的用意放在这里应是想让DocumentBuilder构造完成后再去执行一件事,而这件事是在构造时才确定的,所以才有这样的设计,如:
     public DocumentBuilder(Model.Document documentModel, Action<PageControl> addPageToParent)
        {
          if (documentModel == null)
            throw new ArgumentNullException("documentModel");
          if (addPageToParent == null)
            throw new ArgumentNullException("addPageToParent");      _documentModel = documentModel;
          _addPageToParent = addPageToParent;      addPageToParent.Invoke(you PageControl instance object);
        }