I'm running into an issue using
System.Runtime.Serialization.Json.DataContractJsonSerializer to
serialize a List<T> of proxied objects.  It works fine with a single
proxied object, but the List makes it blow up.  Something like this:

[DataContract]
public class SimpleViewModel
{
    [DataMember]
    public virtual int ID { get; set; }
}

[Test]
public void TestSerializeArray()
{
    // Generates a proxy of type SimpleViewModelProxy that inherits
SimpleViewModel
    var proxyModel = (new
ProxyGenerator()).CreateClassProxy<SimpleViewModel>();
    proxyModel.ID = 1;

    //Put it into List<T> (it can handle a single item without issue!)
    var list = new List<SimpleViewModel> { proxyModel };

    var serializer = new
System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(List<SimpleViewModel>));
    using (var stringWriter = new MemoryStream())
    {
        serializer.WriteObject(stringWriter, list); //BOOM!
    }
}

I'm able to serialize either a single "SimpleViewModelProxy" object,
or a List<SimpleViewModel>, but not a List<SimpleViewModelProxy>.  Has
anyone had any experience getting this to work?  Can they provide some
pointers on what I'm doing wrong?

-- 
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.

Reply via email to