I would like to know if one can conditionally exclude items in a list from being serialized using the ShouldSerialize*
pattern. For example take the two classes:
public class Product{
public int ID {get; set;}
public List<Styles> ProductSyles {get; set;}
}
public class Styles{
public int ID {get; set;}
public bool Selected {get; set;}
public string StyleName {get; set;}
}
Can I go about only serializing the items in the ProductStyles
property with .Selected = true
? Is this possible using the ShouldSerialize*
pattern