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 =
MyDeepCopyOfTheCollectionViaSerialization();
DataFormats.Format format =
DataFormats.GetFormat(typeof(CollectionBase<IDiagr amEntity>).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!
}
_______________________________________
Francois M.Vanderseypen
The Netron Project - Generic diagramming, graph-drawing and
graph-layout kit for .Net
http://www.netronproject.com