源代码中的“ BuildChildCallback”结构

时间:2018-08-29 20:11:13

标签: c# generics

我正在阅读蒂姆·麦卡锡(Tim MacCarthy)撰写的《使用C#进行.NET域驱动的设计》一书,其中有一种我无法理解的结构。你能解释一下吗?

这是一种方法:

protected override void BuildChildCallbacks()
{
    this.ChildCallbacks.Add("addresses",
        delegate(Company company, object childKeyName)
        {
            this.AppendAddresses(company);
        });
}

这是 ChildCallbacks 属性

private Dictionary<string, AppendChildData> childCallbacks;

protected Dictionary<string, AppendChildData> ChildCallbacks
{
    get { return this.childCallbacks; }
}

这是 AppendChildData 委托

/// <summary>
/// The delegate signature required for callback methods
/// </summary>
/// <param name="entityAggregate"></param>
/// <param name="childEntityKey"></param>
public delegate void AppendChildData(T entityAggregate, object childEntityKeyValue);

0 个答案:

没有答案