public object Process(object target, IContext context) { var type = target.GetType(); _interceptor.ItemCreated(type, _container.Model.For(type).Lifecycle == "Transient"); return(target); }
private void TypeRegistering(object sender, RegisterEventArgs args) { var type = args.TypeTo; if (_interceptor.Match(type)) { _interceptor.ItemCreated(type, args.LifetimeManager is TransientLifetimeManager); } }
public object PostProcessAfterInitialization(object instance, string objectName) { var type = instance.GetType(); if (_interceptor.Match(type)) { _interceptor.ItemCreated(type, !_applicationContext.ObjectFactory.GetObjectDefinition(objectName).IsSingleton); } return(instance); }
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration) { registration.Activating += (sender, e) => { var type = e.Instance.GetType(); if (_interceptor.Match(type)) { _interceptor.ItemCreated(type, e.Component.Lifetime.GetType().Equals(typeof(CurrentScopeLifetime))); } }; }
// interceptor /// <summary> /// Registers the interceptor. /// </summary> /// <param name="interceptor">The interceptor.</param> public void RegisterInterceptor(IServiceLocatorInterceptor interceptor) { _container.Kernel.ComponentModelCreated += model => { if (interceptor.Match(model.Implementation)) { interceptor.ItemCreated(model.Implementation, model.LifestyleType == LifestyleType.Transient); } }; }