使用动态代理和 wcf 序列化问题的通用 IPropertyChangedNotifier [英] Generic IPropertyChangedNotifier using Dynamic Proxy and wcf serialization problem

查看:59
本文介绍了使用动态代理和 wcf 序列化问题的通用 IPropertyChangedNotifier的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用城堡动态代理实现了一个通用的 IPropertyChangedNotifier.在这里,我拦截了 Proxy 对象中的 setter 调用,这样我就不必在域对象的 setter 中引发 PropertyChanged 事件.

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.

目的是使用这些代理对象将其 UI 绑定到 silevrlight 应用程序中.

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

问题是 WCF 服务调用中代理对象的序列化失败,这是由于代理对象上缺少 [DataContract].为了解决这个问题,我必须在我的拦截器中保留一个实例的副本并发送这个对象进行序列化.IPropertyChangedNotifier

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

这导致了难以调试或理解的复杂代码.有没有一种简单的方法可以解决 WCF 中的序列化问题,告诉序列化程序在服务调用中发送代理时使用基类(实例)的 [DataContract] 属性.

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.

推荐答案

我们放弃了 DynamicProxies,现在将 PostSharp 用于 Generic IPropertyChangedNotifier.序列化没有问题...

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

这篇关于使用动态代理和 wcf 序列化问题的通用 IPropertyChangedNotifier的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆