private static MutableInteger ActivationCounter(IObjectContainer container) { var activationCounter = new MutableInteger(); EventRegistryFactory.ForObjectContainer(container) .Activating += (sender, args) => activationCounter.Increment(); return(activationCounter); }