There is an attribute you might want to use:
This tells the serializer to skip that property.
You cannot do that. Serialization is based on concrete data, not on abstractions as is an interface.
Look here: Why can XmlSerializer serialize abstract classes but not interfaces?
Or this: XmlSerialization with Interfaces
That said, your solution might be a special separate type (at this point it might as well be a struct) that has a constructor taking in your class and copying the values. You can then serialize that:
public struct WorkOrderConcretized
{
public string Title { get; set; }
public PersonConcretized CreatedBy { get; set; }
public WorkOrderConcretized(WorkOrder w)
{
this.Title = w.Title;
this.CreatedBy = new PersonConcretized(w.CreatedBy);
}
}
Obviously, the PersonConcretized
struct will have to act accordingly.
Deserialization will be another story...