Mitch,

That's sounds better...I will give it a try...

Later

-----Original Message-----
From: Mitch Denny [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 8:44 PM
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] ISerializable and CollectionBase

Hiya Keith,

You could possibly serialize the InnerList ArrayList instead
and then re-insert using the AddRange(ICollection) method on
de-serialization. That should work fine unless you have a
particular attachment to the List IList property.

----------------------------------------
- Mitch Denny
- [EMAIL PROTECTED]
- +61 (414) 610-141
-

-----Original Message-----
From: The DOTNET list will be retired 7/1/02
[mailto:[EMAIL PROTECTED]] On Behalf Of Keith Franklin
Sent: Tuesday, 11 June 2002 10:35
To: [EMAIL PROTECTED]
Subject: [DOTNET] ISerializable and CollectionBase


Hi All,

Been exploring a technique that utilizes CollectionBase. Because of a
need I need to use manual Serialization and ISerializable rather then
simply the Serializable attribute.

Now the collection (The internal list) normally serializes no problem
with serializable attribute. But with ISerializable I need to use
special constructor and the GetObjectData method of ISerializable
interface to control the serialization and deserialization process.

So I have a constructor like the following one:

public AbstractDataBindingCollection(SerializationInfo info,
StreamingContext context) { BinaryFormatter listDeSerializer = new
BinaryFormatter();
            MemoryStream listStream;

            listStream =
(MemoryStream)info.GetValue("list",listStream.GetType());
this.List= (IList)listDeSerializer.Deserialize(listStream);
}

This does not compile because this.List is not writable it is a read
only property.

The corresponding GetObjectData compiles:

public virtual void
GetObjectData(System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) { BinaryFormatter
listSerializer =  new BinaryFormatter();
            MemoryStream listStream = new MemoryStream();

            listSerializer.Serialize(listStream,this.List);

            info.AddValue("list",listStream);
}

The alternative that I know of works but I don't like it. The
alternative that I have working is to enumerate through the list and add
all of the individual items and then in the constructor rebuild the
list.


Anyone else have a better way of doing this.


Keith A Franklin
Chief Software Architect
Empowered Software Solutions
Microsoft Gold Certified Partner for Ecommerce Solutions
www.empowered.com

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to