It is stated in the documentation that you should always make interceptors transient. If I have this sample code;
//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()
);
Should I worry about releasing SampleInterceptor
, or will it be released automatically once the service in Sample.Component
has been released by the container?