日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

castle 组件化开发应用配制示例

發布時間:2025/3/21 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 castle 组件化开发应用配制示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

示例

Windsor 實現IOC容器配制, 暴露接口,通過配制文件指定接口實現,從而降低系統內部依賴 C# Code:

IWindsorContainer?container?=?
????????????????new?WindsorContainer(
????????????????????new?XmlInterpreter(new?ConfigResource("castle")));

Interface1?myInstance=?container.Resolve<Interface1>("Interface1");
//?or?
myInstance=?container.Resolve<Interface1>();

?App.Config or Web.config 配制

<?xml?version="1.0"?encoding="utf-8"??>
<configuration>
??<configSections>
????<section??name="castle"???type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,?Castle.Windsor"?/>
??</configSections>
??<castle>?????
????<include?uri="file://castleconfiguration.xml"/>????
??</castle>
</configuration>

castleconfiguration.xml? 如果是window應用程序,需要把此配制文件copy到bin目錄。Windsor Schema 是用來定義配制文件結構的

注意:

  • 可以配制生命周期:lifestyle=singleton|thread|transient|pooled|custom|
  • 配制構造函數:<parameters>....<參數名>值</參數名>....</parameters>
  • ?

    <?xml?version="1.0"?encoding="utf-8"??>
    <configuration?xmlns="MyWindsorSchema">
    ??<components>
    ????<component?id="httpservicewatcher"??type="GettingStartedPart1.HttpServiceWatcher,?GettingStartedPart1">
    ??????<parameters>????????
    ????????<notifiers>
    ??????????<array>
    ????????????<item>${email.notifier}</item>
    ????????????<item>${alarm.notifier}</item>
    ??????????</array>
    ????????</notifiers>
    ????????<Url>different?url</Url>
    ??????</parameters>
    ????</component>
    ????<component??id="email.notifier"??service="GettingStartedPart1.IFailureNotifier,?GettingStartedPart1"??type="GettingStartedPart1.EmailFailureNotifier,?GettingStartedPart1"?/>
    ????<component??id="alarm.notifier"??service="GettingStartedPart1.IFailureNotifier,?GettingStartedPart1"??type="GettingStartedPart1.AlarmFailureNotifier,?GettingStartedPart1"?/>
    ????<component??id="form.component"??type="GettingStartedPart1.Form1,?GettingStartedPart1"??/>
    ????<component??id="Interface1"?????service="GettingStartedPart1.Interface1,?GettingStartedPart1"?type?="GettingStartedPart1.Class1,?GettingStartedPart1"?lifestyle="transient"?/>
    ????<component??id="Interface2"?????service="GettingStartedPart1.Interface1,?GettingStartedPart1"?type?="GettingStartedPart1.Class2,?GettingStartedPart1"?lifestyle="transient"?/>??????
    ??</components>??
    </configuration>

    ?

    Service look up notation

    The following notation is used to describe a service reference.

    ${componentid}

    Configuration Property evaluation

    This notation is used with a properties node and allows the developer to expand the value on the properties node to as a node value or attribute value. #{propertyname}

    ?

    ?

    ?

    ?

    轉載于:https://www.cnblogs.com/sgciviolence/archive/2008/06/17/1223691.html

    總結

    以上是生活随笔為你收集整理的castle 组件化开发应用配制示例的全部內容,希望文章能夠幫你解決所遇到的問題。

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