2010-03-16 72 views
2

我參觀了一些舊代碼,並有與代表宣佈了不少事件手動而不是使用事件處理<牛逼>,像這樣:XML註釋聲明的事件

/// <summary> 
/// Delegate for event Added 
/// </summary> 
/// <param name="index">Index of the item</param> 
/// <param name="item">The item itself</param> 
public delegate void ItemAdded(int index, T item); 

/// <summary> 
/// Added is raised whenever an item is added to the collection 
/// </summary> 
public event ItemAdded Added; 

一切都很好,直到我來使用sandcastle來記錄庫,因爲它然後找不到由事件聲明生成的專用添加字段的任何XML註釋。我想嘗試和排序了這一點,但我想這樣做有兩種情況:

  • 獲取沙塔忽略自動生成的私有字段沒有告訴它忽略所有私人領域完全

或私有字段

產生

  • 獲取XML註釋是否與實現這一目標的任何方式出重新分解代碼看起來像這樣:

    /// <summary> 
    /// Delegate for event <see cref="Added"/> 
    /// </summary> 
    /// <param name="index">Index of the item</param> 
    /// <param name="item">The item itself</param> 
    public delegate void ItemAdded(int index, T item); 
    
    /// <summary> 
    /// Private storage for the event firing delegate for the <see cref="Added"/> event 
    /// </summary> 
    private ItemAdded _added; 
    
    /// <summary> 
    /// Added is raised whenever an item is added to the collection 
    /// </summary> 
    public event ItemAdded Added 
    { 
        add 
        { 
         _added += value; 
        } 
        remove 
        { 
         _added -= value; 
        } 
    } 
    

回答

0

儘管次優,我找到解決的辦法,這是手工把XML註釋到包含命名空間層次的文件項目的文件,沿着這些線:

<member name="F:myCompany.Common.Collections.Generic.EventableCollection`1.Added"> 
    <summary> 
    Auto-generated backing field for the <see cref="E:myCompany.Common.Collections.Generic.EventableSortedList`1.Added">Added</see> event 
    </summary> 
</member> 

然後,這大致是我所需要的。