Windsor Castle - Liberation Interceptor Transitional

The documentation states that you should always make interceptors transitional. 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 freeing up the SampleInterceptor , or will it be released automatically as soon as the service in Sample.Component been released by the container?

+6
source share
1 answer

Your transient interceptor will have its life expectancy associated with the object with which you associate it, and will be released when this object is released like any other part of this object graph

+9
source

Source: https://habr.com/ru/post/919819/


All Articles