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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

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

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

示例

Windsor 實(shí)現(xiàn)IOC容器配制, 暴露接口,通過配制文件指定接口實(shí)現(xiàn),從而降低系統(tǒng)內(nèi)部依賴 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應(yīng)用程序,需要把此配制文件copy到bin目錄。Windsor Schema 是用來定義配制文件結(jié)構(gòu)的

注意:

  • 可以配制生命周期:lifestyle=singleton|thread|transient|pooled|custom|
  • 配制構(gòu)造函數(shù):<parameters>....<參數(shù)名>值</參數(shù)名>....</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}

    ?

    ?

    ?

    ?

    轉(zhuǎn)載于:https://www.cnblogs.com/sgciviolence/archive/2008/06/17/1223691.html

    總結(jié)

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

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。