Generic IPropertyChangedNotifier using Dynamic Pro

2019-06-14 08:27发布

问题:

I have implemented a generic IPropertyChangedNotifier using castle dynamic proxy. Here I intercept setter call in Proxy objects so that i don't have to raise PropertyChanged event in setters of my domain objects.

The purpose was to use these proxy objects to bind it UI in a silevrlight application.

The Problem is serialization of proxy object fails in WCF service call which is due to absence of [DataContract] on proxy object. to get around the problem I had to keep a copy of instance in my interceptor and send this object for serialization.IPropertyChangedNotifier

This has resulted in complicated code which is difficult to debug or understand. Is there a simple way to solve the serialization problem in WCF to tell the serializer to use [DataContract] attribute of base class(instance) while sending a proxy in service call.

回答1:

What if you cast to the base class type?



回答2:

We Dropped DynamicProxies and now using PostSharp for Generic IPropertyChangedNotifier. No probs with serialization...