国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
IComponent、IContainer、ISite

[ComVisible(true)]

public interface ISite : IServiceProvider

{

// Properties

IComponent Component { get; }

IContainer Container { get; }

bool DesignMode { get; }

string Name { getset; }

}

public interface IComponent : IDisposable

{

// Events

event EventHandler Disposed;

// Properties

ISite Site { getset; }

}

  public interface IContainer : IDisposable

{

// Methods

void Add(IComponent component);

void Add(IComponent component, string name);

void Remove(IComponent component);

// Properties

ComponentCollection Components { get; }

}

兩篇參考:

設(shè)計(jì)思考之IComponent-ISite-IContainer 組合還是繼承,這是個(gè)問題

 System.ComponentModel.Component入門

 

在第2篇中提出了“IComponent使用了注入依賴(DI)的思想”。


我們看一下他們?nèi)齻€(gè)的缺省實(shí)現(xiàn):Component,Container.Site,Container

Container內(nèi)部持有IComponentSite的數(shù)組,當(dāng)一個(gè)Component加入到container,實(shí)際上是先構(gòu)建了一個(gè)包含ComponentSite對象,再加入到IComponentSite數(shù)組的

當(dāng)將component加入到Container,Container會調(diào)用IComponent接口的setComponentSite方法,傳入一個(gè)IComponentSite實(shí)例。這時(shí),你可以在setComponentSite方法中,通過IComponentSitegetContainer方法獲得Container對象,然后調(diào)用ContainergetComponent方法按名獲得其它組件來解決依賴問題。
也可以調(diào)用IComponentSitegetService(class)方法按類型來獲取其它組件(ComponentgetService(class)方法,只是簡單的調(diào)用IComponentSite上的getService(class)。

這種設(shè)計(jì)其一解決了組件的生命周期問題,即當(dāng)容器dispose時(shí),將依次調(diào)用組件的dispose方法 ;其二是引入了Site這個(gè)中間層:站點(diǎn)將 Component 綁定到 Container 并啟用它們之間的通訊,同時(shí)為該容器提供了一種管理其組件的方法。站點(diǎn)也可以用作容器特定信息、基于組件信息(如組件名)的儲存庫。


重要參考:

TSS Featured Entry: Lightweight Containers and Plugin Architectures: Dependency Injection and Dynamic Service Locators in .NET

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
控件和組件的區(qū)別
組件類與普通類的區(qū)別
通過用 .NET 生成自定義窗體設(shè)計(jì)器來定制應(yīng)用程序
Flex4相對于Flex3的變化 - 唐@朝 - JavaEye技術(shù)網(wǎng)站
Life in container apartments in suburban Shanghai
一個(gè)基于組件的動態(tài)對象系統(tǒng)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服