1

私は Unity を稼働させていますが、私たちが置き換えようとしている内部開発の DI エンジンのように動作させるために、最後の 1 つのことを見つけようとしています。

オブジェクトをインスタンス化し、1 つの構成ファイルからいくつかのプロパティを設定したら、ルートから数レベル下のフォルダーにある XML ファイルから、オブジェクトのプロパティ/フィールド全体を埋めるにはどうすればよいですか? ?

これに関するいくつかのハウツーの方向性を教えていただければ幸いです。

これは、古いシステムで機能するファイルの 1 つです。

<?xml version="1.0" encoding="utf-8" ?>
<component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:noNamespaceSchemaLocation="http://mamc-sharepoint.army.mil/sites/Informatics/mamcDev/Schemas/MAMC.EnterpriseLibrary/DIComponent_v1.0.0.1.xsd">
  <type name="MAB.Test.Framework.WebTest.WebTestSettings"
        assembly="${Assemblies[MAB.Test.Framework]}"/>
  <properties>
    <!--Some semi active settings. Intended to be used to keep the browser running between test methods.-->
    <add name="StartServerIfNotRunning">true</add>
    <add name="StopServerIfRunning">true</add>
    <add name="ServerLeaveRunning">false</add>

    <!--Instructions on which browser to use for the testing.-->
    <!--iexplorer, firefox, htmlunit-->
    <add name="BrowserString">firefox</add>

    <!--
    BrowserURL is the base URL for the application under test.  
    Remember to include the forward slash at the end of the URL.
    -->
    <add name="BrowserURL">https://www.google.com/</add>

    <!--The default amount of timeout we're going to use for waiting for actions to happen.-->
    <add name="BaseTimeout">4000</add>
    <!--A modifier that slows down or speeds up the playback depending on the environments behavior.-->
    <add name="TimeoutMultiplier">1</add>
  </properties>

</component>

ありがとう、

マーク B.

4

1 に答える 1

0

これは単純なコメントには多すぎるため、次のようになります。

上記で示した XML ファイルの設定によって、どのようなオブジェクトを初期化する必要がありますか?

これは、 のようなオブジェクトの設定ではなく、環境設定のように見えますUser

これらの設定はテスト環境専用ですか? それとも本番環境でも?Visual Studio は、さまざまなデバッグ構成ファイルとリリース構成ファイルをサポートしています異なるビルド構成用に web.config ファイルを変換することも可能です。

そして最後に:これは、カスタム セクション ハンドラを書く手間をかけずに、構成ファイルから設定を読み取る方法の例です。

于 2012-08-09T08:31:22.743 に答える