How to serialize domain objects?

  • Thread starter Thread starter echoSwe
  • Start date Start date
E

echoSwe

Hi,

I have rich domain model, in which one entity is the "Page". This
object contains a field; "ChildPages : IList<Page>" and a couple of
data-fields, like description, title, text, etc... It inherits from
AbstractPost which implements the IPost interface. AbstractPost
defines many of the common properties amongst the different types of
pages I have in the domain model.

My question is simple: How do I serialize the collection of pages my
application holds, into an xml-file such as
<pages>
<page>
<title>...</title>
[...]
</page>
<page>
[...]
</page>
</pages>

I don't want it to save to the harddrive and I need to be able to
exclude fields from being included in the xml file; hopefully so with
by using attributes. I need the xml document to do xsl transformations
on...
 
Hi,

I have rich domain model, in which one entity is the "Page". This
object contains a field; "ChildPages : IList<Page>" and a couple of
data-fields, like description, title, text, etc... It inherits from
AbstractPost which implements the IPost interface. AbstractPost
defines many of the common properties amongst the different types of
pages I have in the domain model.

My question is simple: How do I serialize the collection of pages my
application holds, into an xml-file such as
<pages>
<page>
<title>...</title>
[...]
</page>
<page>
[...]
</page>
</pages>

I don't want it to save to the harddrive and I need to be able to
exclude fields from being included in the xml file; hopefully so with
by using attributes. I need the xml document to do xsl transformations
on...

Well until O2X (Object 2 XML, my companies xml serialization library)
are being released there's not really many alternatives other than
SoapFormatter...
google for "dotnet soapformatter" nd you'll be home free...
It carries LOADS of overhead though due to the "SOAP" part... ;)

..t
 
If your hierarchy is indeed serializable and the excluded fields are so
attributed, you should be able to pass it into the XmlSerializer and get what
you want.
Peter
 
Back
Top