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. The collection is, to sketch the context, a set of shapes and connections of a diagram (application), see the Netron project[^] for details. Thank you so much for you help. :rose: The copy operation:
CollectionBase<IDiagramEntity> copy = MyDeepCopyOfTheCollectionViaSerialization();
DataFormats.Format format =
DataFormats.GetFormat(typeof(CollectionBase<IDiagramEntity> ).FullName);
IDataObject dataObject = new DataObject();
dataObject.SetData(format.Name, false, copy);
Clipboard.SetDataObject(dataObject, false);
where the MyDeepCopyOfTheCollectionViaSerialization() is :
CollectionBase<T> newobj = null;
MemoryStream stream = new MemoryStream();
GenericFormatter<BinaryFormatter> f = new
GenericFormatter<BinaryFormatter>();
f.Serialize(stream, this);
stream.Seek(0, SeekOrigin.Begin);
newobj = f.Deserialize<CollectionBase<T>>(stream);
stream.Close();
return newobj;
And finally the Paste operation is:
IDataObject data = Clipboard.GetDataObject();
string format = typeof(CollectionBase<IDiagramEntity> ).FullName;
if (data.GetDataPresent(format))
{
//data.GetData(format) is a MemoryStream rather than a generic collection! X|
}
I thought about it,
I stood up
and I did it.
The Netron Project
-- modified at 10:59 Saturday 18th March, 2006