使用 autofac json 配置注册模块时,您可以传入属性和/或参数。
{
"modules": [
{
"type": "MyProject.Core.MyModule, MyProject.Core",
"properties": {
"ModuleProperties": {
"prop1": "value1",
"prop2": "value2"
}
}
]
}
public class MyModule : Autofac.Module
{
public Dictionary<string, string> ModuleProps { get; set; }
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<MyType>.As<IMyInterface>();
}
}
有没有办法传递ModuleProps
给我刚刚注册的类型?