I am going to answer this question with a solution that I have been using for more than a year with Immediacy 6.x. Theoretically, this should work with Alterian CMC 7.x (the successor to Immediacy) with some modification.
The problem here is that Immediacy already has a handler defined in web.config that deals with all aspx pages. However, I have found that this can be replaced by the entry for Spring.NET PageHandlerFactoryin web.config, as in most web applications!
However, some settings are still needed, as out of the box there are still problems with the preview. The process of obtaining Spring.NET for enjoyable playback using Immediacy Control:
Add regular entries to web.config for Spring.NET as indicated in the documentation . In this case, I have my object definitions in Spring.config.
Create the following abstract base class that will handle all Injection Dependency work:
SpringImmediacyControl.cs
public abstract class SpringImmediacyControl : ImmediacyControl, ISupportsWebDependencyInjection
{
#region ISupportsWebDependencyInjection Members
public IApplicationContext DefaultApplicationContext
{
get;
set;
}
#endregion
protected override void OnInit(EventArgs e)
{
if (DefaultApplicationContext == null)
{
DefaultApplicationContext = ContextRegistry.GetContext() as WebApplicationContext;
DefaultApplicationContext.ConfigureObject(this, this.GetType().FullName);
}
base.OnInit(e);
}
protected override void AddedControl(Control control, int index)
{
this.EnableViewState = false;
if (DefaultApplicationContext != null)
WebDependencyInjectionUtils.InjectDependenciesRecursive(DefaultApplicationContext, control);
base.AddedControl(control, index);
}
}
Spring.NET. OnInit , HTTP- Immediacy. , Spring .NET.
, Spring.NET Inversion of Control, reclvant Spring.config, :
SampleControl.cs
public class SampleControl : SpringImmediacyControl, INamingContainer
{
public string Text
{
get;
set;
}
protected string InjectedText
{
get;
set;
}
public SampleControl()
: base()
{
Text = "Hello world";
}
protected override void RenderContents(HtmlTextWriter output)
{
output.Write(string.Format("{0} {1}", Text, InjectedText));
}
}
Spring.config
<objects xmlns="http://www.springframework.net">
<object type="MyProject.SampleControl, MyAssembly" abstract="true">
<property name="InjectedText" value="from Spring.NET" />
</object>
</objects>
, , "Hello world from Spring.NET!". .
, , .
, , Spring.NET, ButtonPluginConfig, , HTTP- Immediacy , Spring.NET. , ButtonPluginConfig gist.