I have updated my project with the Spring.net Dependency Injection Framwork. Then I continued with integrating AOP to enable a simple logging/trace mechanism. I had some problems with a circular dependendy in my app.config, but I worked it out:
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object id="loggingAroundAdvice" type="SetupBuilder.LoggingAroundAdvice"/>
<object id="myServiceObjectTarget" type="SetupBuilder.SetupBuilderModelView, SetupBuilder">
<!--<object name="Model" type="SetupBuilder.SetupBuilderModelView, SetupBuilder">-->
<constructor-arg index="0" ref="MasterData"/>
<property name="FileSelection" ref="FileSelection"/>
<property name="Persistence" ref="Persistence"/>
<property name="Distributor" ref="Distributor"/>
<property name="Document" ref="Document"/>
<property name="StatusWindow" ref="StatusWindow"/>
</object>
<object name="Model" type="Spring.Aop.Framework.ProxyFactoryObject">
<property name="target" ref="myServiceObjectTarget"/>
<property name="interceptorNames">
<list>
<value>loggingAroundAdvice</value>
</list>
</property>
</object>
<object name="MasterData" type="VMRedistMasterData.Implementation.VMRedistMasterDataImpl, VMRedistMasterData"/>
<object name="FileSelection" type="SetupBuilder.OpenAndSaveDialog, SetupBuilder"/>
<object name="Persistence" type="VMRedistDelivery.Implementation.Persistence.DeliveryPersistence, VMRedistDelivery"/>
<object name="Distributor" type="VMRedistDelivery.Implementation.Distribution.Distributor, VMRedistDelivery"/>
<object name="Document" type="Word2010ReleaseDocument.Word2010ReleaseDocument, Word2010ReleaseDocument"/>
<object name="StatusWindow" type="SetupBuilder.WpfStatusWindow, SetupBuilder">
<constructor-arg index="0" ref="Model"/>
</object>
</objects>
My class looks like this:
public interface ISetupBuilderModelViewDependencies
{
IVMRedistMasterData MasterData { get; set; }
IFileSelection FileSelection { get; set; }
IVMRedistPersistence Persistence { get; set; }
IVMRedistDistributor Distributor { get; set; }
IVMRedistReleaseDocument Document { get; set; }
IStatusWindow StatusWindow { get; set; }
}
public class SetupBuilderModelView : ISetupBuilderModelView, ISetupBuilderModelViewDependencies, INotifyPropertyChanged
{
...
public string Customer
{
get { return customer; }
set
{
customer = value;
FirePropertyChanged("Customer");
}
}
...
}
Here is the Model object assigned to my main WPF window:
public partial class App : Application
{
private void Application_Startup(object sender, StartupEventArgs e)
{
var context = ContextRegistry.GetContext();
var setupBuilderWindow = new SetupBuilderWindow(context.GetObject("Model") as ISetupBuilderModelView);
// SetupBuilderWindow needs an ISetupBuilderModelView argument.
setupBuilderWindow.Show();
}
}
But if changes in the "Model" object occur, my WPF window is not updated anymore! The Property changed. The PropertyChanged event is thrown and someone has subscribed it. But noone tries to get the Property values. The trace/logging mechanism works, get_Customer()
is only called once at startup, then never again. I don't get it. The Spring.Aop.Framework.ProxyFactoryObject
should transfer every event from the target object to all subscribers, shouldn't it? If that's not the problem and the event arrives, is the problem in the property? Is the Proxy object caching the target's properties? I just don't get it.
The commented line in app.config was without AOP. If I comment the line above and uncomment that line, everything works normal.
If you have any idea, please let me know. I hope I provided enough but not too much information. If you need further information, i would be happy to provide it.