Ejemplo n.º 1
0
        /*----------------------------------------------------------------------------------------*/
        #region Lifecycle Event Handlers
        /// <summary>
        /// Initializes the application.
        /// </summary>
        public void Application_Start()
        {
            // Create the Ninject kernel and store it in the static container.
            KernelContainer.Kernel = CreateKernel();

            // Request injections for the application itself.
            KernelContainer.Inject(this);

            OnApplicationStarted();
        }
Ejemplo n.º 2
0
        /*----------------------------------------------------------------------------------------*/
        /// <summary>
        /// Injects dependencies into web pages and subscribes to their InitComplete
        /// Event to inject usercontrols with their dependencies.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void OnPreRequestHandlerExecute(object sender, EventArgs e)
        {
            var page = _application.Context.CurrentHandler as Page;

            if (page == null)
            {
                return;
            }

            KernelContainer.Inject(page);
            page.InitComplete += (src, args) => InjectUserControls(page);
        }
Ejemplo n.º 3
0
        /*----------------------------------------------------------------------------------------*/
        /// <summary>
        /// Search for usercontrols within the parent control
        /// and inject their dependencies using KernelContainer.
        /// </summary>
        /// <param name="parent">The parent control.</param>
        private static void InjectUserControls(Control parent)
        {
            if (parent == null || parent.Controls == null)
            {
                return;
            }

            foreach (Control control in parent.Controls)
            {
                if (control is UserControl)
                {
                    KernelContainer.Inject(control);
                }

                InjectUserControls(control);
            }
        }
Ejemplo n.º 4
0
 /*----------------------------------------------------------------------------------------*/
 /// <summary>
 /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"></see> interface.
 /// </summary>
 /// <param name="context">An <see cref="T:System.Web.HttpContext"></see> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
 public void ProcessRequest(HttpContext context)
 {
     KernelContainer.Inject(this);
     DoProcessRequest(context);
 }
Ejemplo n.º 5
0
 /*----------------------------------------------------------------------------------------*/
 /// <summary>
 /// Initializes a new instance of the <see cref="WebServiceBase"/> class.
 /// </summary>
 protected WebServiceBase()
 {
     KernelContainer.Inject(this);
 }
Ejemplo n.º 6
0
 /*----------------------------------------------------------------------------------------*/
 /// <summary>
 /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event to initialize the page.
 /// </summary>
 /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param>
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     KernelContainer.Inject(this);
 }
Ejemplo n.º 7
0
 /*----------------------------------------------------------------------------------------*/
 /// <summary>
 /// Asks the kernel to inject this instance.
 /// </summary>
 protected virtual void RequestActivation()
 {
     KernelContainer.Inject(this);
 }