How to serialize a complete VERY LARGE class, all but, possibly, NOTone member, at will

P

pamela fluente

I have a class marked serialized. This class has some *thousands*
fields and properties.

Among them there is, in particular, 1 object. Let's call it MyObject.

What I need is being able, at my will, to perform either one of the
following actions:

- Serialize the class including MyObject
- Serialize the class EXCLUDING MyObject (that is, like if
MyObject would not be serializable)

1. I have already looked into ISerializable - of course - but at
first sight seemed impractical to use
because I have thousands properties and fields and clearly I cannot
write a ISerializable.GetObjectData
for all of them. Also it would not be easily maintainable.

2. I do not wish to wrap the other properties and fields in another
class, because that would be awkward.

How can I do that?

Thank you very much for any help.

-P
 
G

Gilbert Tordeur

Hello.

Perhaps you can save MyObject, assign it to Nothing, serialize, and restore
MyObject ?

Gilbert
 
P

pamela fluente

Hello.

Perhaps you can save MyObject, assign it to Nothing, serialize, and restore
MyObject ?

Gilbert

Thank you very much, very helpful idea.

That's seems a simple solution

-P
 
A

Alex Clark

Just out of interest, why do you feel you need thousands of fields and
properties declared within one class?
 
P

pamela fluente

Sometimes on groups you need to exaggerate a little to avoid people be
tempted to give you
answer that you may not be interested in.

Anyway if not thousand, I have worked with classes with so many
properties that
you certainly do not wish embark in the
ISerializable.GetObjectData :)

Big projects here! :)


-P
 
A

Alex Clark

Even if you're talking hundreds, by the time any class got to that state I'd
be re-examining my design and looking to go to key/value attributes instead
of hard-coded properties.

With many hundreds of properties (or more) you're likely to cause yourself
other pains. I can't imagine IntelliSense liking it (nor the rest of VS for
that matter), future maintenance could be problematic, your code files would
likely end up getting rather large (and thus your compiled binary would as
well) and if every one of those properties has a backing-store variable
associated with it then your heap is going to be enormous with just a few
instances of that one class loaded up.

Cheers,
Alex





Sometimes on groups you need to exaggerate a little to avoid people be
tempted to give you
answer that you may not be interested in.

Anyway if not thousand, I have worked with classes with so many
properties that
you certainly do not wish embark in the
ISerializable.GetObjectData :)

Big projects here! :)


-P
 
P

pamela fluente

Yes Alex, that's sounds very reasonable.

Modular design: that's the key to handle complexity !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top