日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

castle windsor学习-----XML Inline Parameters 内联参数

發布時間:2025/6/17 67 豆豆
生活随笔 收集整理的這篇文章主要介紹了 castle windsor学习-----XML Inline Parameters 内联参数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

當使用XML配置的時候,可能要給組件指定各種各樣的依賴

1。簡單的參數

  參數名稱不區分大小寫

<componentid="ping"type="Acme.Crm.Services.PingService, Acme.Crm"><parameters><pingServer>http://acme.org</pingServer><pingInterval>00:00:30</pingInterval><pingRetries>3</pingRetries><pingNotificator>${emailSender}</pingNotificator></parameters> </component>

?

簡單的參數是指簡單的類型,如基元類型,Uri,DateTime,TimeSpan,Type,Enum 或者 服務的重寫,這些參數有它們值表達(簡單的名稱標簽)

參數類型怎么匹配呢?

Windsor不要求你指定參數的類型,而是當解析組件的時候,它將試圖通過名稱去匹配組件的依賴,并檢查是否可以將進行轉換

2.復雜的參數

  復雜的參數有多個元素組成

  例如你想指定如下的參數

[Convertible] public class ServerInfo {private readonly Uri address;public ServerInfo(Uri address){this.address = address;}public Uri Address{get { return address; }}public int Port { get; set; } }

?

應該做如下配置

<parameters><pingServerInfo><parameters><address>http://localhost</address><port>80</port></parameters></pingServerInfo> </parameters>

?

3。List參數

public class MyComponent {public MyComponent(IEnumerable<Uri> info){Info = info;}public IEnumerable<Uri> Info { get; private set; } } <parameters><info><list><item>http://localhost:80</item><item>http://castleproject.org</item></list></info> </parameters>

?

4.數組

<parameters><info><array><item>http://localhost:80</item><item>http://castleproject.org</item></array></info> </parameters>

?

5.字典

<parameters><info><dictionary><entry key="local">http://localhost:80</entry><entry key="castle">http://castleproject.org</entry></dictionary></info> </parameters>

?

轉載于:https://www.cnblogs.com/lanpingwang/p/6535821.html

總結

以上是生活随笔為你收集整理的castle windsor学习-----XML Inline Parameters 内联参数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。