Why are you doing this in the first place? sent from my HTC Desire
On 06/08/2010 7:54 AM, "André Werlang" <[email protected]> wrote: Hi! <short history> How serialize and deserialize proxied objects? </short history> I'm having trouble implementing IEditableObject on a DynamicProxy on Silverlight. I'm trying to use DataContractSerializer, with opt-in members marked with DataMember. A problem occurs when trying to deserialize the object from the byte array, because it tries to recreate a proxied object and some members injected by DP aren't streamed. The error occurs precisely when DCS calls Castle.DynamicProxy.AbstractInvocation.SelectMethodInterceptors(IInterceptorSelector selector, IInterceptor[] methodInterceptors, Type targetType), I don't know why, but it does. With XmlSerializer, as it is an opt-out approach, it gives me an error when trying to serialize an interface IInterceptorSelector, it says it's not possible to serialize interfaces. void IEditableObject.BeginEdit() { MemoryStream ms = new MemoryStream(); DataContractSerializer dcs = new DataContractSerializer(MemberToSerialize.GetType()); dcs.WriteObject(ms, MemberToSerialize); _copy = ms.ToArray(); } void IEditableObject.CancelEdit() { if (_copy != null) { MemoryStream ms = new MemoryStream(_copy, false); DataContractSerializer dcs = new DataContractSerializer(MemberToSerialize.GetType()); var newObject = dcs.ReadObject(ms); MemberToSerialize = newObject; _copy = null; } } MemberToSerialize is created with ProxyGenerator.CreateClassProxy<T>(). -- André F. Werlang twitter.com/awerlang programmernotfound.blogspot.com -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]<castle-project-users%[email protected]> . For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
