Created
December 22, 2011 16:06
-
-
Save SimonRice/1510815 to your computer and use it in GitHub Desktop.
Immediacy 6.x Control & Server-Side Button Plugin Configuration with Spring.NET support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Web.UI; | |
using Immediacy.Web.UI; | |
using Spring.Context; | |
using Spring.Context.Support; | |
using Spring.Web.Support; | |
namespace Immediacy.Spring | |
{ | |
public abstract class SpringImmediacyControl : ImmediacyControl, ISupportsWebDependencyInjection | |
{ | |
// You can do the same thing for other control classes, like LiteralControl | |
#region ISupportsWebDependencyInjection Members | |
public IApplicationContext DefaultApplicationContext | |
{ | |
get; | |
set; | |
} | |
#endregion | |
protected override void OnInit(EventArgs e) | |
{ | |
// Required for page preview, which is executed using Immediacy's page preview handler | |
if (DefaultApplicationContext == null) | |
{ | |
DefaultApplicationContext = WebApplicationContext.GetRootContext(); | |
DefaultApplicationContext.ConfigureObject(this, this.GetType().FullName); | |
} | |
base.OnInit(e); | |
} | |
protected override void AddedControl(Control control, int index) | |
{ | |
this.EnableViewState = false; | |
// Handle DI for children ourselves - defaults to a call to InjectDependenciesRecursive | |
if (DefaultApplicationContext != null) | |
WebDependencyInjectionUtils.InjectDependenciesRecursive(DefaultApplicationContext, control); | |
base.AddedControl(control, index); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment