Hi! I'm doing a CRUD. I have to do something about user wanting to cancel. We tried use binding with explicit update control to source, but it seems expensive to program going from control to control. Other problem is when you have more than two levels of edit, e.g. you are editing an Order object, which has OrderItems which in turn has some other Thing. Each entity being edited in its own window. If I edit Order/OrderItem/Thing, and commit changes to Thing, but cancel on OrderItem, I have to do something about to make Order consistent.
So I decided to edit a copy of object, or revert to a copy of it. But I'm glad to hear alternatives. :) Cheers. 2010/8/5 Krzysztof Koźmic <[email protected]> > 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]<castle-project-users%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/castle-project-users?hl=en. > -- 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]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
