Hi,
I want to deserialize an XML string into two classes. My main class is called Images se below and that class shall reference to another class called Image. As you can see I want a List of Image connected to the Images class. When I deserialize my XML string the List will not be assigned to the values in my XML string. I don't know why. Maybe someone can help me with this problem?
- namespace DataContractSample.DataContract.Model
- {
- using System.Collections.Generic;
- using System.Runtime.Serialization;
-
- [DataContract(Name="objects", Namespace = "", IsReference = true)]
- [KnownType(typeof(IList<Image>))]
-
- public class Images
- {
- [DataMember(Name = "object")]
- public IList<Image> ImageList { get; set; }
- }
- }
- namespace DataContractSample.DataContract.Model
- {
- using System;
- using System.Runtime.Serialization;
- [DataContract(Name = "object", Namespace = "")]
- public class Image
- {
- [DataMember(Name = "id")]
- public Guid Id { get; set; }
- }
- }
This is my XML string:
- <objects>
- <object>
- <id>CF7E7B22-1D3A-4CFE-91F9-F8C5C2DB4069</id>
- </object>
- <object>
- <id>CF7E7B22-1D3A-4CFE-91F9-F8C5C2DB4070</id>
- </object>
- </objects>