472,342 Members | 1,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,342 software developers and data experts.

extending serialization

Hi,

I'm not sure that if this is the right forum, but any help would be greatly
appreciated.

I am porting some java serialization code to c# and I can't figure out the
correct way to do it. It seems that either I can use default serialization
or implement ISerializable. Is there any way to do both (e.g. extend the
default serialization). In other words, I want to be able to implement my
custom serialization code but call the default serialization code as well.
In java, I can do this:

private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
//implement my custom code
}

It seems there is no .NET equivalent. In particular I have a class that has
a GraphicsPath member. This class implements ISerializable so that it can
correctly serialize the path. But, for the other members including
references to other objects, I would like to use the default serialization.
Is this possible? Moreover this class derives from a serializable class
that does not implement ISerializable. Does the derived class have to
serialize all of the inherited members as well, if it chooses to do custom
serialization.

Thanks so much,
Aaron
Nov 15 '05 #1
3 3049
To add to/refine this question a bit, is it possible to mix and match custom
and default serialization along an inheritance hierarchy. If a base class
uses custom serialization can a derived class use default serialization or
vice-versa? I haven't been able to make either of these work.

If anyone can help here, please respond...

Aaron
"Aaron Clamage" <ac******@nospam.cs.umd.edu> wrote in message
news:#T**************@TK2MSFTNGP11.phx.gbl...
Hi,

I'm not sure that if this is the right forum, but any help would be greatly appreciated.

I am porting some java serialization code to c# and I can't figure out the
correct way to do it. It seems that either I can use default serialization or implement ISerializable. Is there any way to do both (e.g. extend the
default serialization). In other words, I want to be able to implement my
custom serialization code but call the default serialization code as well.
In java, I can do this:

private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
//implement my custom code
}

It seems there is no .NET equivalent. In particular I have a class that has a GraphicsPath member. This class implements ISerializable so that it can
correctly serialize the path. But, for the other members including
references to other objects, I would like to use the default serialization. Is this possible? Moreover this class derives from a serializable class
that does not implement ISerializable. Does the derived class have to
serialize all of the inherited members as well, if it chooses to do custom
serialization.

Thanks so much,
Aaron

Nov 15 '05 #2
Aaron,
If you don't have them the following articles covers every thing you wanted
to know about serialization but were afraid to ask:

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/

One of the articles discusses how to leverage the FormatterServices class
with your own code. (read mix & match ISerializable classes with "default
serialization" classes) FormatterServices is the library that the "default
serialization" code uses to serialization a class that does not implement
ISerializable.

Hope this helps
Jay

"Aaron Clamage" <ac******@nospam.cs.umd.edu> wrote in message
news:eN****************@TK2MSFTNGP09.phx.gbl...
To add to/refine this question a bit, is it possible to mix and match custom and default serialization along an inheritance hierarchy. If a base class
uses custom serialization can a derived class use default serialization or
vice-versa? I haven't been able to make either of these work.

If anyone can help here, please respond...

Aaron
"Aaron Clamage" <ac******@nospam.cs.umd.edu> wrote in message
news:#T**************@TK2MSFTNGP11.phx.gbl...
Hi,

I'm not sure that if this is the right forum, but any help would be

greatly
appreciated.

I am porting some java serialization code to c# and I can't figure out the correct way to do it. It seems that either I can use default

serialization
or implement ISerializable. Is there any way to do both (e.g. extend the default serialization). In other words, I want to be able to implement my custom serialization code but call the default serialization code as well. In java, I can do this:

private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
//implement my custom code
}

It seems there is no .NET equivalent. In particular I have a class that

has
a GraphicsPath member. This class implements ISerializable so that it can correctly serialize the path. But, for the other members including
references to other objects, I would like to use the default

serialization.
Is this possible? Moreover this class derives from a serializable class
that does not implement ISerializable. Does the derived class have to
serialize all of the inherited members as well, if it chooses to do custom serialization.

Thanks so much,
Aaron


Nov 15 '05 #3

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Aaron,
If you don't have them the following articles covers every thing you wanted to know about serialization but were afraid to ask:

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/


They're good articles and I'm grateful to Mr. Richter for writing them, but
they don't take the place of a precise specification like Java's

http://java.sun.com/products/jdk/1.2...alTOC.doc.html

AFAIK, .NET has no equivalent.
Nov 15 '05 #4

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

Similar topics

3
by: Alexander | last post by:
When i store rule on PC with .NET.SP1 i cant restore them from PC without SP1. An i get this Error: ...
1
by: Mark Overstreet | last post by:
Hi, I have several custom collections that inherit from System.Collections.Specialized.NameObjectCollectionBase and I want to serialize and...
8
by: Martin Horn | last post by:
Hi, I am trying to add extra functionality to the standard RichText control, but I've fallen at the first hurdle,can someone take a look at the...
5
by: vbgunz | last post by:
Hello everyone. I own two books. Learning Python and Python in a nutshell. When cross referencing the two books to try and clarify the ideas...
5
by: Gerry Vandermaesen | last post by:
Hi, Does anyone have a freely available JavaScript JSON stringifier. So far my search has been in vain, the one offered on...
4
by: mijalko | last post by:
Hi, I have inherited my class from System.Drawing.Printing.PrintDocument and I wish to serialize this object using XmlSerializer. And I get...
3
by: katis | last post by:
Hi all :) Is it posible in xsd to change only minOccurs value of element in complex type by extending this type? The problem I'm trying to...
1
by: kikisan | last post by:
I am developing a windows service which utilizes the following classes: interface IPersistable; abstract class PersistableObject :...
2
by: mkvenkit.vc | last post by:
Hello, I hope this is the right place to post a question on Boost. If not, please let me know where I can post this message and I will do so. ...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.