My copy/paste operation results in a MemoryStream full of '\0'
characters on the Clipboard.
Maybe my approach to copy/paste is wrong when handling generic types.
All entries in the CollectionBase are, of course, ISerializable and the
binary serialization to file fully works.
<Thank you so much for you help>
The copy operation:
CollectionBase< IDiagramEntity> copy =
MyDeepCopyOfThe CollectionViaSe rialization();
DataFormats.For mat format =
DataFormats.Get Format(typeof(C ollectionBase<I DiagramEntity>) .FullName);
IDataObject dataObject = new DataObject();
dataObject.SetD ata(format.Name , false, copy);
Clipboard.SetDa taObject(dataOb ject, false);
where the MyDeepCopyOfThe CollectionViaSe rialization() is :
CollectionBase< T> newobj = null;
MemoryStream stream = new MemoryStream();
GenericFormatte r<BinaryFormatt er> f = new
GenericFormatte r<BinaryFormatt er>();
f.Serialize(str eam, this);
stream.Seek(0, SeekOrigin.Begi n);
newobj = f.Deserialize<C ollectionBase<T >>(stream);
stream.Close();
return newobj;
And finally the Paste operation is:
IDataObject data = Clipboard.GetDa taObject();
string format = typeof(Collecti onBase<IDiagram Entity>).FullNa me;
if (data.GetDataPr esent(format))
{
//data.GetData(fo rmat) is a MemoryStream rather than a generic
collection!
}
_______________ _______________ _________
Francois M.Vanderseypen
The Netron Project - Generic diagramming, graph-drawing and
graph-layout kit for .Net
http://www.netronproject.com