473,466 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Multiple Object Serialization seperately in single file (something like olestorages)

Hi,

We have a c++ application that accesses many different modules. Each
of these modules is responsible for it's own
serialization. We have seperate olestorages for each of the
module. The main application hands over these storage
pointers to each module which then do whatever-they-want to
their respective storages. Everything is kept with in a single file.

Seperate storages for each module help tremendously because
they are sharing a single file.

How would i do such a thing in c#? I want a single file in which
each object can be serialized without overwriting another and i
don't want to do it in a sequence. Basically a seperate playing
area for each module without affecting anything else.

ps. i've looked at the general serialization procedure in .net but
it serializes in a sequence and not spreadover as i want.

Thanks,
Ali
Nov 16 '05 #1
6 1744
No takers? Did i post in the wrong group? If so, could any one point
me to the relevant one?
Nov 16 '05 #2
No takers? Did i post in the wrong group? If so, could any one point
me to the relevant one?
Nov 16 '05 #3
No takers? Did i post in the wrong group? If so, could any one point
me to the relevant one?
Nov 16 '05 #4
No takers? Did i post in the wrong group? If so, could any one point
me to the relevant one?
Nov 16 '05 #5
On 03 Jul 2004 08:41, M Ali wrote:
No takers? Did i post in the wrong group? If so, could any one point
me to the relevant one?


Since you haven't quoted your original question I'm taking a guess, but
here goes.
The conditions for serialising a tree of objects are the same for serialising
one object. Each object in the tree must be serialisable: it has to have
a default public constructor (i.e. no parameters) and each property must
expose a serialisable type. Properties which you don't want to serialise
can be prevented by using the [XmlIgnore] attribute.
Some collections are not serialisable (e.g. Hashtable). In this case you
can work-around it by putting [XmlIgnore] on the Hashtable property and
creating another property which gets/sets the contacts of the Hashtable
as an array of the type contained. This of course allows the clients of
the class to access the collection in two ways which may or may not be
a good thing. For example, if the Hashtable contained strings:
<aircode>

[XmlIgnore]
public Hashtable MyStrings {
get { return myStringHashtable; }
set { myStringHashtable = value; }
}

public string[] SerialisableStrings {
get {
int i = myStringHashtable.Values.Count;
string[] strings = new string[i];
i = 0;
foreach (string astring in myStringHashtable.Values) {
strings[i] = astring;
i++;
}
}
set {
myStingHashtable = new Hashtable();
foreach (string astring in value) {
myStringHashtable.Add(astring, astring);
}
}
}

</aircode>

Now all you need to do is serialise the containing object and as long
as all types exposed are serialisable it will work.
I am obviously talking about Xml serialisation here. For anything more
sophisticated you should implement ISerializable. If you want to do that,
read the docs first and then ask any questions.

--
Simon Smith
simon dot s at ghytred dot com
www.ghytred.com/NewsLook - NNTP Client for Outlook
Nov 16 '05 #6
On 03 Jul 2004 08:41, M Ali wrote:
No takers? Did i post in the wrong group? If so, could any one point
me to the relevant one?


Since you haven't quoted your original question I'm taking a guess, but
here goes.
The conditions for serialising a tree of objects are the same for serialising
one object. Each object in the tree must be serialisable: it has to have
a default public constructor (i.e. no parameters) and each property must
expose a serialisable type. Properties which you don't want to serialise
can be prevented by using the [XmlIgnore] attribute.
Some collections are not serialisable (e.g. Hashtable). In this case you
can work-around it by putting [XmlIgnore] on the Hashtable property and
creating another property which gets/sets the contacts of the Hashtable
as an array of the type contained. This of course allows the clients of
the class to access the collection in two ways which may or may not be
a good thing. For example, if the Hashtable contained strings:
<aircode>

[XmlIgnore]
public Hashtable MyStrings {
get { return myStringHashtable; }
set { myStringHashtable = value; }
}

public string[] SerialisableStrings {
get {
int i = myStringHashtable.Values.Count;
string[] strings = new string[i];
i = 0;
foreach (string astring in myStringHashtable.Values) {
strings[i] = astring;
i++;
}
}
set {
myStingHashtable = new Hashtable();
foreach (string astring in value) {
myStringHashtable.Add(astring, astring);
}
}
}

</aircode>

Now all you need to do is serialise the containing object and as long
as all types exposed are serialisable it will work.
I am obviously talking about Xml serialisation here. For anything more
sophisticated you should implement ISerializable. If you want to do that,
read the docs first and then ask any questions.

--
Simon Smith
simon dot s at ghytred dot com
www.ghytred.com/NewsLook - NNTP Client for Outlook
Nov 16 '05 #7

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

Similar topics

66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
2
by: Hollywood | last post by:
After doing a search through google's archives of this list, I didn't see what I was looking for so here goes... Is it possible to serialize/deserialize multiple objects from a single XML file? ...
2
by: films | last post by:
I understand the concept. Serialization of a class will add all the sub-objects of the class to the stream if there are also serializible. So say I have: class Author {
9
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and...
5
by: Matthew | last post by:
I have a nice little Sub that saves data in a class "mySettings" to an XML file. I call it like so: Dim mySettings As mySettings = New mySettings mySettings.value1 = "someText" mySettings.value2...
1
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
5
by: Ahmad Jalil Qarshi | last post by:
Hi! I have a class named CClassToSerialize that contain some boolean, string and few custom variable types. Now when I create only a single Object and Serialize/Deserialize everything is...
7
by: jtbjurstrom | last post by:
Bear with me because we are new to WCF and have been going through documentation and samples trying to absorb as much as possible in a short amount of time. Any suggestions would be much...
6
by: pereges | last post by:
I hae compiled and executed codes of vector.c, reader.c , test.c seperately and they can be execute in proper manner and give correct outputs but when i tried to integrate them all into a single...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
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...
1
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...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.