473,395 Members | 1,756 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,395 software developers and data experts.

Serialisation

I need to save a quite big structure of classes... but only some members
that I need to recondtruct the whole ierarchy.
I want to ask how serialisation work... is a efficient way? Or should I deal
myself with persistent members in my format?

Thanks,
Crirus

--

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------
Nov 20 '05 #1
11 1266
Depends on what you want serialized. The easy way is to use a Datatable,
adding in the info as you get it, then calling
MyDataSet.WriteXML("SomePath\SomeFile.xml")

You can also use a SOAP formatter or a Binary Formatter, but the method
you'd use really depends on the finer details. can you give me some more
info about the ultimate goal?
"Crirus" <Cr****@datagroup.ro> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
I need to save a quite big structure of classes... but only some members
that I need to recondtruct the whole ierarchy.
I want to ask how serialisation work... is a efficient way? Or should I deal myself with persistent members in my format?

Thanks,
Crirus

--

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

Nov 20 '05 #2
The problem is like this:

I have a top class called Game
Game have one instance of GameData
Game have a collection of Player class
Each Player have a collection of GroupUnit class
Each GroupUnit have 4 collections of HumanUnit, AutoUnit, NavalUnit and
AirUnit and so on
Now, I need to save all this when I close the game, so later I can reload
them as they were before closing
Of course, there are another members in each of the above classes that I
need to be saved, but for a general ideea...

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"William Ryan" <do********@nospam.comcast.net> wrote in message
news:e7**************@TK2MSFTNGP10.phx.gbl...
Depends on what you want serialized. The easy way is to use a Datatable,
adding in the info as you get it, then calling
MyDataSet.WriteXML("SomePath\SomeFile.xml")

You can also use a SOAP formatter or a Binary Formatter, but the method
you'd use really depends on the finer details. can you give me some more
info about the ultimate goal?
"Crirus" <Cr****@datagroup.ro> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
I need to save a quite big structure of classes... but only some members
that I need to recondtruct the whole ierarchy.
I want to ask how serialisation work... is a efficient way? Or should I

deal
myself with persistent members in my format?

Thanks,
Crirus

--

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------


Nov 20 '05 #3
Hi Crirus,

Ahah. So now we know what those maps are for! ;-))

Just a thought. If you serialise to a readable text file, eg xml, some of
your users are definitely going to hack that file. Best case - they've altered
their game play. Worst case - Exceptions on reading it back in. You might care
about that.

Regards,
Fergus

Good morning (night) Bill.
I've got something to mullah, I mean mull over. ;-)
Speak to you later.
Nov 20 '05 #4
>Ahah. So now we know what those maps are for! ;-))

LOL

I have a server for that... clients cant acces that saves

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Fergus Cooney" <fi****@post.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi Crirus,

Ahah. So now we know what those maps are for! ;-))

Just a thought. If you serialise to a readable text file, eg xml, some of your users are definitely going to hack that file. Best case - they've altered their game play. Worst case - Exceptions on reading it back in. You might care about that.

Regards,
Fergus

Good morning (night) Bill.
I've got something to mullah, I mean mull over. ;-)
Speak to you later.

Nov 20 '05 #5
Any important differences between Binary and Soap?

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"William Ryan" <do********@nospam.comcast.net> wrote in message
news:e7**************@TK2MSFTNGP10.phx.gbl...
Depends on what you want serialized. The easy way is to use a Datatable,
adding in the info as you get it, then calling
MyDataSet.WriteXML("SomePath\SomeFile.xml")

You can also use a SOAP formatter or a Binary Formatter, but the method
you'd use really depends on the finer details. can you give me some more
info about the ultimate goal?
"Crirus" <Cr****@datagroup.ro> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
I need to save a quite big structure of classes... but only some members
that I need to recondtruct the whole ierarchy.
I want to ask how serialisation work... is a efficient way? Or should I

deal
myself with persistent members in my format?

Thanks,
Crirus

--

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------


Nov 20 '05 #6
Crirus,
In case you don't have them the following MSDN Magazine articles are useful
for understanding Serialization.

http://msdn.microsoft.com/msdnmag/issues/02/04/net/
http://msdn.microsoft.com/msdnmag/issues/02/07/net/
http://msdn.microsoft.com/msdnmag/issues/02/09/net/

Binary serialization is going to use less space then SOAP Serialization.
SOAP serialization is really intended for Web Services (SOAP). There is also
XML serialization which is not tied directly to SOAP Serialization, however
you get a similar result.

I would recommend Binary Serialization as the framework does most of the
work for you, and it is reasonably efficient.

Serialization supports the ISerializable interface where you have total
control over what will be serialized & how for a class, plus it has a
NotSerializable attribute that you can use to flag just certain fields to
avoid serializing them. The above articles cover the details.

Hope this helps
Jay

"Crirus" <Cr****@datagroup.ro> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
I need to save a quite big structure of classes... but only some members
that I need to recondtruct the whole ierarchy.
I want to ask how serialisation work... is a efficient way? Or should I deal myself with persistent members in my format?

Thanks,
Crirus

--

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

Nov 20 '05 #7
Here's one other good article:

http://msdn.microsoft.com/library/de...et07082003.asp
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Crirus,
In case you don't have them the following MSDN Magazine articles are useful for understanding Serialization.

http://msdn.microsoft.com/msdnmag/issues/02/04/net/
http://msdn.microsoft.com/msdnmag/issues/02/07/net/
http://msdn.microsoft.com/msdnmag/issues/02/09/net/

Binary serialization is going to use less space then SOAP Serialization.
SOAP serialization is really intended for Web Services (SOAP). There is also XML serialization which is not tied directly to SOAP Serialization, however you get a similar result.

I would recommend Binary Serialization as the framework does most of the
work for you, and it is reasonably efficient.

Serialization supports the ISerializable interface where you have total
control over what will be serialized & how for a class, plus it has a
NotSerializable attribute that you can use to flag just certain fields to
avoid serializing them. The above articles cover the details.

Hope this helps
Jay

"Crirus" <Cr****@datagroup.ro> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
I need to save a quite big structure of classes... but only some members
that I need to recondtruct the whole ierarchy.
I want to ask how serialisation work... is a efficient way? Or should I

deal
myself with persistent members in my format?

Thanks,
Crirus

--

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------


Nov 20 '05 #8
Thanks, all..I made it... anyway, I had no thime for a hard testing, nut I
noticed that a shared field was not serialised...I may be wrong, but do you
know if that members can be serialised

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Crirus" <Cr****@datagroup.ro> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
I need to save a quite big structure of classes... but only some members
that I need to recondtruct the whole ierarchy.
I want to ask how serialisation work... is a efficient way? Or should I deal myself with persistent members in my format?

Thanks,
Crirus

--

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

Nov 20 '05 #9
Crirus,
Is this a shared field of the class you are serializing or a shared field
referenced by a class that you are serializing (a Singleton). The articles I
gave earlier discusses how to handle the Singleton correctly.

If its a shared field of the class you are serializing, you would need to
use the ISerializable interface to explicitly serialize it.

However be careful in your thinking you want a shared field serialized, as a
shared field is shared by all instances!!! If you have 100 instances of the
class, the Shared Field will be serialized 100 times! If you have 1000
instances of the class, the Shared field will be serialized 1000 times!!
Depending on the Shared field, this may not really be what you want!

Hope this helps
Jay

"Crirus" <Cr****@datagroup.ro> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Thanks, all..I made it... anyway, I had no thime for a hard testing, nut I
noticed that a shared field was not serialised...I may be wrong, but do you know if that members can be serialised

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Crirus" <Cr****@datagroup.ro> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
I need to save a quite big structure of classes... but only some members
that I need to recondtruct the whole ierarchy.
I want to ask how serialisation work... is a efficient way? Or should I

deal
myself with persistent members in my format?

Thanks,
Crirus

--

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------


Nov 20 '05 #10
Well, that shared field is a class member, long, kind if an unique ID like
in a database that is inceremented everytime a new instance of that object
is created. I need to store it only once to reset it when all graph is
deserialized.. I may consider to save it with other shared fields of another
types in a separate xml.. seems nicer :)

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:eC*************@tk2msftngp13.phx.gbl...
Crirus,
Is this a shared field of the class you are serializing or a shared field
referenced by a class that you are serializing (a Singleton). The articles I gave earlier discusses how to handle the Singleton correctly.

If its a shared field of the class you are serializing, you would need to
use the ISerializable interface to explicitly serialize it.

However be careful in your thinking you want a shared field serialized, as a shared field is shared by all instances!!! If you have 100 instances of the class, the Shared Field will be serialized 100 times! If you have 1000
instances of the class, the Shared field will be serialized 1000 times!!
Depending on the Shared field, this may not really be what you want!

Hope this helps
Jay

"Crirus" <Cr****@datagroup.ro> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Thanks, all..I made it... anyway, I had no thime for a hard testing, nut I noticed that a shared field was not serialised...I may be wrong, but do

you
know if that members can be serialised

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Crirus" <Cr****@datagroup.ro> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
I need to save a quite big structure of classes... but only some members that I need to recondtruct the whole ierarchy.
I want to ask how serialisation work... is a efficient way? Or should
I deal
myself with persistent members in my format?

Thanks,
Crirus

--

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------



Nov 20 '05 #11
Crirus,
Do you need to store the current value when you serialize? Or have you
considered setting its value to the max value +1 when you deserialize? I'm
presuming you are using the shared value to assign each object a unique ID.

I would consider using the former, especially if I already implemented the
ISerializable interface otherwise I would consider implementing the
IDeserializationCallback interface.

In either the special constructor for ISerializable or the
IDeserializationCallback.OnDeserialization method I would save the max of
the shared unique ID and the instance ID.

The other option I would consider is in my 'document' class (the object that
you pass to the Formatter.Serialize Method I would serialize the shared
member of this second class, yes its coupling, but the ID sounds like a
'document' level value.

Hope this helps
Jay

"Crirus" <Cr****@datagroup.ro> wrote in message
news:Oi**************@TK2MSFTNGP10.phx.gbl...
Well, that shared field is a class member, long, kind if an unique ID like
in a database that is inceremented everytime a new instance of that object
is created. I need to store it only once to reset it when all graph is
deserialized.. I may consider to save it with other shared fields of another types in a separate xml.. seems nicer :)

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:eC*************@tk2msftngp13.phx.gbl...
Crirus,
Is this a shared field of the class you are serializing or a shared field
referenced by a class that you are serializing (a Singleton). The articles
I
gave earlier discusses how to handle the Singleton correctly.

If its a shared field of the class you are serializing, you would need
to use the ISerializable interface to explicitly serialize it.

However be careful in your thinking you want a shared field serialized, as a
shared field is shared by all instances!!! If you have 100 instances of the
class, the Shared Field will be serialized 100 times! If you have 1000
instances of the class, the Shared field will be serialized 1000 times!!
Depending on the Shared field, this may not really be what you want!

Hope this helps
Jay

"Crirus" <Cr****@datagroup.ro> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Thanks, all..I made it... anyway, I had no thime for a hard testing,

nut I noticed that a shared field was not serialised...I may be wrong, but
do you
know if that members can be serialised

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Crirus" <Cr****@datagroup.ro> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
> I need to save a quite big structure of classes... but only some
members > that I need to recondtruct the whole ierarchy.
> I want to ask how serialisation work... is a efficient way? Or
should I deal
> myself with persistent members in my format?
>
> Thanks,
> Crirus
>
> --
>
> ------------------------------
> If work were a good thing, the boss would take it all from you
>
> ------------------------------
>
>



Nov 20 '05 #12

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

Similar topics

2
by: unknow | last post by:
I want to do a serialisation in pure C++ but i don't know how. Do you have some useful links ? Thanks
2
by: msnews.microsoft.com | last post by:
Hi Here is another EASY question When you serialise an object in .NET, serialisation adds defaut attributes that I dont care EXEMPLE : <root_test...
1
by: lobrys | last post by:
Hi everybody here is a question I have this class that a want to serialize : Public Class BOO <XmlAttributeAttribute()> Public THING As String <XmlElementAttribute("param")> Public p() As...
2
by: lobrys | last post by:
Hi everybody what are the objets for the folowing XML serialisation : (I have problem with "name" and "datatype") <vehicule type="car"> <name datatype="String">Megane</name> </inventory> ...
0
by: Ollie | last post by:
I have been able to get simple circular references to be serialized in xml by using the ImportTypeMapping method on the SoapReflectionImporter class. But I am unable to serialise circular...
1
by: McGiv | last post by:
Hi, I'm trying to serialise some objects and I've can't get the built in serialisation to output exactly what I want. For the moment I'm implementing the IXmlSerializable interface and doing it...
1
by: BrentonMCA | last post by:
I want to be able to serialise an object and then pass the serialisation text as a string to a Web service without serialising to a file first. I also want to be able to deserialise from the text...
2
by: Greg | last post by:
I have a bizarre situation in which serialisation is failing routinely under a specific condition, and I'm wondering if the details ring a bell with anyone here. I have 2 classes that my...
2
by: ashwinij | last post by:
Hello The steps which i am doing in my program 1) I am having an xml file. 2) I am performing some updations in the file using XQueryUtil class from nux package. 3)After that i am...
1
by: OrionLee | last post by:
I am using C# to work with a 3rd party DLL (Nevron Charts), and attempting to serialise it. The serialisation itself is handled somewhere inside the DLL, so to get it to happen you call the Nevron's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.