我是 Autofac 的初学者。有谁知道如何在模块中使用 container.Resolve?
public class MyClass
{
public bool Test(Type type)
{
if( type.Name.Begin("My") ) return true;
return false;
}
}
public class MyModule1 : Autofac.Module
{
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
{
var type = registration.Activator.LimitType;
MyClass my = container.Resolve<MyClass>(); //How to do it in Module?
my.Test(type);
...
}
}
如何在模块中获取容器?