Example #1
0
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="next">
        /// The next.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task Execute(IOwinContext context, Func <Task> next)
        {
            if (this.bootstrapper == null)
            {
                lock (this.modules)
                {
                    if (this.bootstrapper == null)
                    {
                        this.bootstrapper = new Bootstrapper();
                        this.bootstrapper.Initialize(this.CreateKernel);
                    }
                }
            }

            using (var scope = new OwinRequestScope())
            {
                context.Set(NinjectOwinRequestScope, scope);
                await next();
            }
        }
Example #2
0
        /// <summary>
        /// Handles the owin context.
        /// </summary>
        /// <param name="next">The next moddleware factory.</param>
        /// <returns>
        /// The Ninject moddleware factory.
        /// </returns>
        public Func <IDictionary <string, object>, Task> Execute(Func <IDictionary <string, object>, Task> next)
        {
            this.bootstrapper.Initialize(() =>
            {
                var kernel = this.createKernelCallback();
                lock (this.modules)
                {
                    kernel.Load(this.modules);
                }
                return(kernel);
            });

            return(async context =>
            {
                using (var scope = new OwinRequestScope())
                {
                    context[NinjectOwinRequestScope] = scope;
                    await next(context);
                }
            });
        }
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="next">The next.</param>
        /// <returns>
        /// The <see cref="Func{IDictionary{string, object}, Task}"/>.
        /// </returns>
        public Func <IDictionary <string, object>, Task> Execute(Func <IDictionary <string, object>, Task> next)
        {
            if (this.bootstrapper == null)
            {
                lock (this.modules)
                {
                    if (this.bootstrapper == null)
                    {
                        var initializingBootstrapper = new Bootstrapper();
                        initializingBootstrapper.Initialize(this.CreateKernel);
                        this.bootstrapper = initializingBootstrapper;
                    }
                }
            }

            return(async(context) => {
                using (var scope = new OwinRequestScope())
                {
                    context[NinjectOwinRequestScope] = scope;
                    await next(context);
                }
            });
        }
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="next">
        /// The next.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task Execute(IOwinContext context, Func<Task> next)
        {
            if (this.bootstrapper == null)
            {
                lock (this.modules)
                {
                    if (this.bootstrapper == null)
                    {
                        this.bootstrapper = new Bootstrapper();
                        this.bootstrapper.Initialize(this.CreateKernel);
                    }
                }
            }

            using (var scope = new OwinRequestScope())
            {
                context.Set(NinjectOwinRequestScope, scope);
                await next();
            }
        }