Exemple #1
0
        /// <summary>
        /// Obtains a <see cref="T:System.Web.UI.UserControl"/> object by type
        /// and injects dependencies according to Spring config file.
        /// </summary>
        /// <param name="t">The type of a user control.</param>
        /// <param name="parameters">parameters to pass to the control</param>
        /// <returns>
        /// Returns the specified <see langword="UserControl"/> object, with dependencies injected.
        /// </returns>
        protected virtual new Control LoadControl(Type t, params object[] parameters)
        {
            Control control = base.LoadControl(t, parameters);

            control = WebDependencyInjectionUtils.InjectDependenciesRecursive(defaultApplicationContext, control);
            return(control);
        }
Exemple #2
0
        /// <summary>
        /// Obtains a <see cref="T:System.Web.UI.UserControl"/> object from a user control file
        /// and injects dependencies according to Spring config file.
        /// </summary>
        /// <param name="virtualPath">The virtual path to a user control file.</param>
        /// <returns>
        /// Returns the specified <see langword="UserControl"/> object, with dependencies injected.
        /// </returns>
        protected virtual new Control LoadControl(string virtualPath)
        {
            Control control = base.LoadControl(virtualPath);

            control = WebDependencyInjectionUtils.InjectDependenciesRecursive(defaultApplicationContext, control);
            return(control);
        }
 override protected void AddedControl(Control control, int index)
 {
     if (EnableDependencyInjection)
     {
         control = WebDependencyInjectionUtils.InjectDependenciesRecursive(_defaultApplicationContext, control);
     }
     base.AddedControl(control, index);
 }
Exemple #4
0
 /// <summary>
 /// Injects dependencies into control before adding it.
 /// </summary>
 protected override void AddedControl(Control control, int index)
 {
     if (!_suppressDependencyInjection &&
         _defaultApplicationContext != null)
     {
         control = WebDependencyInjectionUtils.InjectDependenciesRecursive(_defaultApplicationContext, control);
     }
     base.AddedControl(control, index);
 }
Exemple #5
0
 /// <summary>
 /// This method is invoked right before InitRecursive() is called for this Panel and
 /// ensures, that dependencies get injected on child controls before their Init event is raised.
 /// </summary>
 protected virtual void OnPreInitRecursive(EventArgs e)
 {
     if (!_suppressDependencyInjection &&
         _defaultApplicationContext == null)
     {
         // obtain appContext of the closed parent template (.ascx/.aspx) control
         IApplicationContext appCtx = WebApplicationContext.GetContext(this.TemplateSourceDirectory.TrimEnd('/') + "/");
         // NOTE: _defaultApplicationContext will be set during DI!
         WebDependencyInjectionUtils.InjectDependenciesRecursive(appCtx, this);
     }
 }
Exemple #6
0
 /// <summary>
 /// Injects dependencies into control before adding it.
 /// </summary>
 protected override void AddedControl(Control control, int index)
 {
     WebDependencyInjectionUtils.InjectDependenciesRecursive(defaultApplicationContext, control);
     base.AddedControl(control, index);
 }