1

Unity 2.0 ポリシー インジェクションを設定して、設定ファイルでカスタム属性一致ルールを使用するにはどうすればよいですか?

私が望むのは、unity 構成ファイル内の次のコード スニペットを翻訳することです。

myContainer.Configure<Interception>()
       .AddPolicy("MyPolicy")
       .AddMatchingRule<CustomAttributeMatchingRule>
           (new InjectionConstructor(typeof(MyAttributeType), true))
       .AddCallHandler<MyCallHandler>
            ("MyValidator", 
            new ContainerControlledLifetimeManager());
4

1 に答える 1

-1

次のように構成できます[TypeName]。アセンブリに応じて正しく構成する必要があります。

.....。

<sectionExtension type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration"/>

<container>
  <extension type="Interception"/>
  <interception>
    <policy name="MyPolicy">
      <matchingRule name="customAttribute" type="CustomAttributeMatchingRule">
        <constructor>
          <param name="attributeType" type="[MyAttributeType]"/>
          <param name="inherited" value="true"/>
        </constructor>
      </matchingRule>
      <callHandler name="MyValidator" type="[MyCallHandler]">
        <lifetime type="transient"/>
      </callHandler>
    </policy>
  </interception>
</container>

.....。

于 2012-01-11T06:49:33.910 に答える