一、 關於IServiceCollection接口的設計
public interface IServiceCollection : IList<ServiceDescriptor> { }
a. 為什么不直接用List<>集合,而要重新定義一個這樣的IServiceCollection接口呢?
1. 為了從IList<>那里得到所有的List集合的可重載方法;
2. 有了自已的名字IServiceCollection,而不是List<>這樣直接使用,如果直接繼承了List<>的話,那么在使用的時候,你用這個List<>根本就不知道這是干啥的,並且還要帶上參數;
二、關於調試時的跟蹤
[DebuggerDisplay("Lifetime = {Lifetime}, ServiceType = {ServiceType}, ImplementationType = {ImplementationType}")] public class ServiceDescriptor
a. 加上DebuggerDisplay特性,然后用{}把屬性名稱顯出來了即可,在跟蹤Stack中你就能看到想要顯示的效果了。
未完.....