Saving an 'object into the Clipboard, and reading it, is not difficult: the one requirement is that the 'object must be serializable. But, remember that the Clipboard is meant to be used by the user, at any time, "inside" or "outside" of your Application. To try and restrict its use is a serious mistake.
Example (in a WinForm) of saving an 'object to the Clipboard, and reading it back; example:
[Serializable]
public class TestClass
{
public int count { set; get; }
public string aString { set; get; }
}
private string TestClassDataFormat = "TestClassList";
private List<testclass> ListOfTestClass;
private void TestClipboardWrite()
{
ListOfTestClass = new List<testclass>
{
new TestClass {aString = "instance 1", count = 300},
new TestClass {aString = "instance 2", count = 400 }
};
DataObject testDataObject = new DataObject(TestClassDataFormat, ListOfTestClass);
Clipboard.SetDataObject(testDataObject);
}
private void TestClipboardRead()
{
IDataObject clipData = Clipboard.GetDataObject();
if (clipData != null)
{
if (clipData.GetDataPresent(TestClassDataFormat))
{
ListOfTestClass = (List<testclass>)clipData.GetData(TestClassDataFormat);
}
}
}</testclass></testclass></testclass>
Comment: note that here a generic List of 'TestClass was written/read to/from the Clipboard: this was successful because the "atomic" elements of the Object, the instances of 'TestClass were all Serializable. So, it was not necessary to create a separate Class marked Serializable that held the List of 'TestClass.