473,796 Members | 2,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5177
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.co m

"Phil Da Lick!" <ph***********@ NOSPAM.hotmail. com> wrote in message
news:42******** *************@p tn-nntp-reader03.plus.n et...
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
4255
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 hashtables. We would like to read this data back into the app and reuse those values and state to compute more new data. Up to this point we just write out comma separated ASCII values for everything. And we read/parse the ascii back in. The ASCII...
2
6214
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 evaluating if we can easily resolve this issue. For example, I have a class MyClass consisting of 100 fields.
2
2511
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 structure supposes to have 2-3 levels. What's easier, to write a serialization method for each class used by the main class and a short method to gather all these XML strings together into one complex string or to use some trick and serialize the...
2
10315
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 Integer Dim Val2 as String End Structure Dim aStruct as myStruct
3
15107
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
3822
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 7 or 10 times then my computer's memory gets flooded and every time I call the Clone() method the processor resources gets consumed 100% for like 30 seconds. And this problem increases as the amount of clones are created increases. I read some...
1
1001
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 7 or 10 times then my computer's memory gets flooded by the aspnet working process, and every time I call the Clone() method the processor resources gets consumed 100% for like 30 seconds. And this problem increases as the amount of clones are...
0
5930
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 problem serializing my stuff to XML when it comes to collections. I'm currently using .net2 with generic lists to prevent users putting all sorts of stuff in the arrays (Although im sure i'll be the only user of the classes but not the game, anyway)....
1
3727
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 default the serialization engine outputs every property it comes across and I was wondering if it would be possible to get it to behave as if everything had the XmlIgnore attribute attached unless another xml serialization attribute with specified? ...
0
9524
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.