Hi,
Firstly datatables, I have an object which stores its data internally
as a dataset (ease of use of relational and filtering operations) and
I want to serialize it, so looking at code on the web I did the
following:

namespace Processor
{
    [XmlRoot("HoldingData")]
    public class Holding
    {
        [XmlElement("holdings")]
        private DataSet _holdings;

        ....
    }
}

Then in a webservice I added the following code to serialize my
object:

            XmlSerializer s = new XmlSerializer(typeof(Holding));
            TextWriter w = new StreamWriter(@"c:\list.xml");
            s.Serialize(w, holding);  // holding is a Holding object
with data internally!
            w.Close();

When this runs it creates the XML file for the object however it just
creates an empty HoldingData tag and no data is present from the
dataset at all...  What am I doing wrong?

Next up, I have a hierarchial data structure where I have an object
called HierarchyNode which contains a collection of child nodes, this
is implemented as follows:

public class HierarchyNode : IEnumerable
{
    private List<HierarchyNode> child;

    private Holding data;

    ...

    public IEnumerator<HierarchyNode> GetEnumerator()
    {
        ....
    }
}

In this case there is always one root node to the hierarchy with
potentially multiple child nodes hanging on each branch of the
hierarchy.  Each node also has holdings data which from above is
stored in a dataset.  I want to be able to serialize this object and
send it over the wire - it is bit heavyweight!

The problems I am having here are:

1) The Holding object with the dataset internally does not serialize
(see above)

2) Because the HierarchyNode implements IEnumerable the serialization
requires the method Add(Object ...) to be added to the class.  When I
add this object and try serializing it I get a stack overflow error,
looking at the call stack does not show anything as the calls were
external to my class.  I have no idea what is happening here!

Thoughts, suggestions, help???

Thanks


Jeremy.

Reply via email to