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

Serialisation - whats coming over?

Using serialisation can anyone tell me how i can use it to work out what
object was serialised?

For example i have a class Ball and another class Bat.

i serialise the first class Ball and send it over the wire via sockets.

The receiving end receives the data and deserialises. But how do i know
after deserialising it to an object whether the Ball object was sent across
or the Bat object was sent across?

c# code please
Feb 25 '06 #1
5 1141
Hello, Daniel!

D> For example i have a class Ball and another class Bat.

D> i serialise the first class Ball and send it over the wire via sockets.

D> The receiving end receives the data and deserialises. But how do i know
D> after deserialising it to an object whether the Ball object was sent
D> across or the Bat object was sent across?

Did you try to call object.GetType() method on deserialized object?

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Feb 25 '06 #2
Thought it would be to do with that but how do i use it?

object myObject = bf.Deserialise();

myObject.GetType(); ?how do i do this bit?

"Vadym Stetsyak" <va*****@ukr.net> wrote in message
news:eM**************@TK2MSFTNGP09.phx.gbl...
Hello, Daniel!

D> For example i have a class Ball and another class Bat.

D> i serialise the first class Ball and send it over the wire via sockets.

D> The receiving end receives the data and deserialises. But how do i know
D> after deserialising it to an object whether the Ball object was sent
D> across or the Bat object was sent across?

Did you try to call object.GetType() method on deserialized object?

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Feb 25 '06 #3
Hello, Daniel!

D> object myObject = bf.Deserialise();

D> myObject.GetType(); ?how do i do this bit?

If I understood you correctly...

the pseudo code will be like this
objType = deserializedObj.GetType();

switch objType
case Type1
DoStuffWithType1
case Type2
DoStuffWithType2
etc


--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Feb 25 '06 #4
Daniel wrote:
Using serialisation can anyone tell me how i can use it to work out what
object was serialised?

For example i have a class Ball and another class Bat.

i serialise the first class Ball and send it over the wire via sockets.

The receiving end receives the data and deserialises. But how do i know
after deserialising it to an object whether the Ball object was sent across
or the Bat object was sent across?


object obj = bf.Deserialize(...);

if (obj is Bat) {
// obj is a Bat
} else if (obj is Ball) {
// obj is a Ball
}

does that help?

Max
Feb 25 '06 #5
Turns out i cant do a swtich on an objecttype.

So i had to change the type to string then do the switch against that. Works
now, thanks for the help

"Vadym Stetsyak" <va*****@ukr.net> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hello, Daniel!

D> object myObject = bf.Deserialise();

D> myObject.GetType(); ?how do i do this bit?

If I understood you correctly...

the pseudo code will be like this
objType = deserializedObj.GetType();

switch objType
case Type1
DoStuffWithType1
case Type2
DoStuffWithType2
etc
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Feb 25 '06 #6

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

Similar topics

7
by: Jorge Schramm | last post by:
Hi, a collegue of mine is trying to write a serialisable container (reads at construction, writes at destruction). The writing part is pretty easy: simply iterate through the container and...
4
by: Nick Gilbert | last post by:
Hi, I'm developing a webservice that will accept an Order and forward it to a backend system, but I'm having a problem with transferring my "Order" class over a webservice. When I try and...
11
by: Crirus | last post by:
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...
7
by: Danny Tuppeny | last post by:
Hi All, I've been going through Google Groups, but nothing seems to quite match my problem. It's hard to post a WSDL or anything at the moment (it's not my service, I'm just using it), but maybe...
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...
26
by: Muzammil | last post by:
whats the beauty of "malloc" over "new" why its helpful for programmer.for its own memory area.??
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...

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.