473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Serialization of a complex structure

Hello,

Anyone got any good examples of how to serialize a nested class?

My outer class has got ArrayList members for inner classes, each with
their own data. I need to serialise the lot into an xml file for easy
load/save.
Nov 16 '05 #1
2 5152
Phil,

Must the format be human-readable? If not, I recommend using the
BinaryFormatter or SoapFormatter (I believe this is depricated or frozen for
..NET 2.0) instead of the XmlSerializer.

Nested classes are classes whose type definition is located in a class.
It doesn't matter for serialization purposes because an instance of that
type will be like any other type.

If you mean private references in the instance, then XML serialization
isn't going to help, as it only serializes what is publically accessible.

You are better off using traditional serialization for the more complex
structures.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil Da Lick!" <ph***********@NOSPAM.hotmail.com> wrote in message
news:42*********************@ptn-nntp-reader03.plus.net...
Hello,

Anyone got any good examples of how to serialize a nested class?

My outer class has got ArrayList members for inner classes, each with
their own data. I need to serialise the lot into an xml file for easy
load/save.

Nov 16 '05 #2
Nicholas Paldino [.NET/C# MVP] wrote:
Phil,

Must the format be human-readable? If not, I recommend using the
BinaryFormatter or SoapFormatter (I believe this is depricated or frozen for
.NET 2.0) instead of the XmlSerializer.

Nested classes are classes whose type definition is located in a class.
It doesn't matter for serialization purposes because an instance of that
type will be like any other type.

If you mean private references in the instance, then XML serialization
isn't going to help, as it only serializes what is publically accessible.

You are better off using traditional serialization for the more complex
structures.


Perhaps I didnt phrase it right. My collections are what is worrying me.
How would I modify the serialization to include them?

And more importantly, in the deserialization process the right classes
will have to be created. One of the collections in particular will
contain up to eight different classes.
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mountain Bikn' Guy | last post by:
We have an app that computes a lot of numeric data. We would like to save to disk about 1-2 gigabytes of computed data that includes ints, doubles, strings and some complex objects that contain...
2
by: Dominic | last post by:
Hi everybody, I'm planning to use serialization to persist an object (and possibly its child objects) in my application. However, I'm concerned about the backward compatibility issue. I'm...
2
by: Just D | last post by:
Hi, I need to write a serialization (to XML string) and restoring (from XML string) of a very complicated object. The object uses a few classes, one class has two ArrayLists, etc. The general...
2
by: Daryll SHatz | last post by:
Does serialization work on custom data types via structures? Dim bFormatter As New BinaryFormatter() Dim sFile As FileStream = File.Create(FilePath) Dim structure As myStruct Dim val1 as...
3
by: Paulo Morgado [MVP] | last post by:
Hi all ..NET Framework 1.1 I have created several types that are serailized to XML as strings. Someting like this: public struct MyInt32 : IXmlSerializable { int value;
1
by: Alex D. | last post by:
hi guys. I need to clone multiple times an object and I am succesfully cloning using the regular serialization process, using a MemoryStream. My problem is that after cloning the object more that...
1
by: Alex D. | last post by:
hi guys. I need to clone multiple times an object and I am succesfully cloning using the regular serialization process, using a MemoryStream. My problem is that after cloning the object more that...
0
by: crazyone | last post by:
I've got a gaming framework i'm building and i want to save myself the trouble of reading and writting the complete game data to a custom file and load/save it to an XML file but i'm getting...
1
by: Undergrid | last post by:
I have a pretty complex data structure which I want to serialize to and from XML, I have tried the .net 2.0 serialization engine and proved that it will work for my structure. However by...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.