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

Deserializing object


Hi

Is there any way (at all) that an object beign deserialized from a stream
can know (or figure out) that it has been created because of a deserialize
process rather than by a "normal" object instiantiation ??
TIA

Søren
Sep 14 '06 #1
4 836
"Søren M. Olesen" <sm******@hotmail.comwrote in
news:u1**************@TK2MSFTNGP06.phx.gbl:
Is there any way (at all) that an object beign deserialized from a
stream can know (or figure out) that it has been created because of a
deserialize process rather than by a "normal" object instiantiation ??
Maybe u can create a property "IsDeserialized" and flag the object during
deserialization?
Sep 14 '06 #2
Søren M. Olesen ha scritto:
Hi

Is there any way (at all) that an object beign deserialized from a stream
can know (or figure out) that it has been created because of a deserialize
process rather than by a "normal" object instiantiation ??
How about this :

<Serializable()Class YourObject

<nonserialized()Public HasBeenNormallyInstantiated As Boolean =
True

'Other properties ...

End Class

the flag HasBeenNormallyInstantiated will hold the answer because when
deserialized will be false. Will be true when YourObject "normally"
instantiated.


TIA

Søren
Sep 14 '06 #3

Søren M. Olesen wrote:
Hi

Is there any way (at all) that an object beign deserialized from a stream
can know (or figure out) that it has been created because of a deserialize
process rather than by a "normal" object instiantiation ??
TIA

Søren
Well yes... If you implement the ISerializable interface, then you
will have to add a constructor like:

Public Sub New (ByVal info As SerializationInfo, ByVal context As
StreamingContext)

This constructor will be called when the object is deserialized.

--
Tom Shelton

Sep 14 '06 #4
Thanks a lot for all your replies, they have been very helpfull!!


"Søren M. Olesen" <sm******@hotmail.comwrote in message
news:u1**************@TK2MSFTNGP06.phx.gbl...
>
Hi

Is there any way (at all) that an object beign deserialized from a stream
can know (or figure out) that it has been created because of a deserialize
process rather than by a "normal" object instiantiation ??
TIA

Søren

Sep 15 '06 #5

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

Similar topics

1
by: Justin Armstrong | last post by:
I'm having difficulties deserializing some objects. Consider the following example of what I'm trying to do: ---------------------------------------------------------- class Person { string...
0
by: Kenneth Baltrinic | last post by:
I am getting the following error when deserializing an object that has a couple of dozen dependant objects in its object graph. Anyone who can suggest where I might begin to look to resolve problem...
1
by: Thomas | last post by:
Hi, I implemented a composite pattern which should be serializable to xml. After spending some time in the newsgroups, i finally managed serializing, even with utf-8 instead of utf-16, which...
3
by: Mark McConnell | last post by:
Regarding deserializing XML into a custom object... I've been able to deserialize an XML doc into my custom object and everything works great. The problem I am encountering is when one of the...
4
by: Wayne Wengert | last post by:
Using VB.NET I want to read in an XML file that has an array of objects and then step through the resulting array in code. I build a class to define the structure and I am running code to read in...
5
by: Lucas | last post by:
Well, here's the situation.. It's pretty simple; just that I can't get it to work. I have 2 Executables.. The first one is called CSharp.exe which is a simple WinForm App. I have a single...
0
by: Casey | last post by:
So I'm using XmlSerializer to serialize out a wrapper object that contains an arbitrary number of other objects. The class definitions listed below are made to be very generic. Some of the...
2
by: Phillip Galey | last post by:
I have an object called Place which contains only string properties and has the <Serializable()> flag before the class name declaration. I also have a collection object called Places, which is...
4
by: Andrew E Chapman | last post by:
What happens to an object which is not nothing has another object deserialized into it? I assume that the data in it is completely destroyed by the new object. I am interested because I have...
1
by: =?Utf-8?B?SmVyZW15X0I=?= | last post by:
I am working on an order entry program and have a question related to deserializing nodes with nested elements. The purchase order contains multiple line items which I select using an...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: 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
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: 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...

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.