autofac配置文件启用拦截器
The autofac configuration file enables interceptors
代码部分
您可以在使用程序集注入时使用 EnableInterfaceInterceptors()。
使用配置文件注册时如何启用拦截器
var config = new ConfigurationBuilder().AddXmlFile("AutoFac.config").Build();
var module = new ConfigurationModule(config);
var builder = new ContainerBuilder();
builder.RegisterModule(module);
var container = builder.Build();
配置文件
<autofac defaultAssembly="Test.Multilingual.IService">
<components name="0">
<type>Test.Multilingual.Service.TestMessage, Test.Multilingual.Service</type>
<services name="0" type="Test.Multilingual.IService.ITestMessage" />
<injectProperties>true</injectProperties>
<instanceScope>perlifetimescope</instanceScope>
</components>
<components name="1">
<type>Test.Multilingual.LanguageChoiceForm, Test.Multilingual</type>
<injectProperties>true</injectProperties>
</components>
<components name="2">
<type>Test.Multilingual.MainForm, Test.Multilingual</type>
<injectProperties>true</injectProperties>
</components>
<components name="3">
<type>Test.Multilingual.BaseForm, Test.Multilingual</type>
<injectProperties>true</injectProperties>
</components>
<components name="4">
<type>Test.Multilingual.PopForm, Test.Multilingual</type>
<injectProperties>true</injectProperties>
</components>
<components name="5">
<type>Test.Multilingual.Core.MultilingualInterceptor, Test.Multilingual.Core</type>
<injectProperties>true</injectProperties>
</components>
</autofac>
如何启用拦截器?????
Autofac 配置不支持拦截器。
Before diving too deeply into JSON/XML configuration, be sure to read Modules - this explains how to handle more complex scenarios than the basic JSON/XML component registration will allow. Configuration in JSON/XML is not a feature-for-feature replacement for programmatic configuration, so complex scenarios may require a combination of JSON/XML and modules.
代码部分 您可以在使用程序集注入时使用 EnableInterfaceInterceptors()。 使用配置文件注册时如何启用拦截器
var config = new ConfigurationBuilder().AddXmlFile("AutoFac.config").Build();
var module = new ConfigurationModule(config);
var builder = new ContainerBuilder();
builder.RegisterModule(module);
var container = builder.Build();
配置文件
<autofac defaultAssembly="Test.Multilingual.IService">
<components name="0">
<type>Test.Multilingual.Service.TestMessage, Test.Multilingual.Service</type>
<services name="0" type="Test.Multilingual.IService.ITestMessage" />
<injectProperties>true</injectProperties>
<instanceScope>perlifetimescope</instanceScope>
</components>
<components name="1">
<type>Test.Multilingual.LanguageChoiceForm, Test.Multilingual</type>
<injectProperties>true</injectProperties>
</components>
<components name="2">
<type>Test.Multilingual.MainForm, Test.Multilingual</type>
<injectProperties>true</injectProperties>
</components>
<components name="3">
<type>Test.Multilingual.BaseForm, Test.Multilingual</type>
<injectProperties>true</injectProperties>
</components>
<components name="4">
<type>Test.Multilingual.PopForm, Test.Multilingual</type>
<injectProperties>true</injectProperties>
</components>
<components name="5">
<type>Test.Multilingual.Core.MultilingualInterceptor, Test.Multilingual.Core</type>
<injectProperties>true</injectProperties>
</components>
</autofac>
如何启用拦截器?????
Autofac 配置不支持拦截器。
Before diving too deeply into JSON/XML configuration, be sure to read Modules - this explains how to handle more complex scenarios than the basic JSON/XML component registration will allow. Configuration in JSON/XML is not a feature-for-feature replacement for programmatic configuration, so complex scenarios may require a combination of JSON/XML and modules.