文档中指出,您应该始终使拦截器成为瞬态。如果我有这个示例代码;
//register interceptor
container.Register(Classes.FromAssemblyNamed("Sample.Interceptors")
.BasedOn<Castle.DynamicProxy.IInterceptor>()
.LifestyleTransient());
//Configure components to intercept
container.Register(Classes.FromAssemblyNamed("Sample.Component")
.IncludeNonPublicTypes().InNamespace("Sample.Component", true)
.Configure(c=>
c.Interceptors(InterceptorReference.ForType<SampleInterceptor>())
.Anywhere.LifestyleSingleton())
.WithService.DefaultInterfaces()
);
我应该担心释放SampleInterceptor
,还是会Sample.Component
在容器释放服务后自动释放?