Пример #1
0
 public Global()
 {
     // We create an instance of OnePerRequestModule and initialize it with our HttpApplication so it can handle
     // deactivation of instances created via the Kernel when the Http request is done
     this.onePerRequestModule = new OnePerRequestModule();
     this.onePerRequestModule.Init(this);
 }
Пример #2
0
        public void InstancesAreDisposedViaOnePerRequestModule()
        {
            var settings = new NinjectSettings {
                CachePruningInterval = TimeSpan.MaxValue
            };
            var kernel = new StandardKernel(settings);

            kernel.Bind <ITool>().To <Hammer>().InRequestScope();

            StartNewHttpRequest();

            var instance = kernel.Get <ITool>();

            instance.ShouldNotBeNull();
            instance.ShouldBeInstanceOf <Hammer>();

            var opr = new OnePerRequestModule();

            opr.DeactivateInstancesForCurrentHttpRequest();

            instance.IsDisposed.ShouldBeTrue();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NinjectHttpApplication"/> class.
 /// </summary>
 protected NinjectHttpApplication()
 {
     this.onePerRequestModule = new OnePerRequestModule();
     this.onePerRequestModule.Init(this);
 }