Skip to content

Commit

Permalink
Replace binaryformatter with xmlSerializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Miepee committed Apr 5, 2023
1 parent 880fac8 commit 8574183
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/Eto/Forms/Clipboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Runtime.Serialization.Formatters.Binary;
using System.Diagnostics;
using System.Reflection;
using System.Xml.Serialization;

namespace Eto.Forms;

Expand Down Expand Up @@ -205,8 +206,8 @@ public void SetObject(object value, string type)
{
using (var ms = new MemoryStream())
{
var binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(ms, value);
var xmlFormatter = new XmlSerializer(value.GetType());
xmlFormatter.Serialize(ms, value);
SetDataStream(ms, type);
return;
}
Expand Down Expand Up @@ -273,8 +274,8 @@ public object GetObject(string type)
return null;
try
{
var binaryFormatter = new BinaryFormatter();
return binaryFormatter.Deserialize(stream);
var xmlFormatter = new XmlSerializer(new object().GetType());
return xmlFormatter.Deserialize(stream);
}
catch (Exception ex)
{
Expand Down
10 changes: 5 additions & 5 deletions src/Eto/Forms/DataObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Xml.Serialization;

namespace Eto.Forms;

Expand Down Expand Up @@ -261,9 +262,8 @@ public void SetObject(object value, string type)
{
using (var ms = new MemoryStream())
{
var binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(ms, value);
SetDataStream(ms, type);
var xmlFormatter = new XmlSerializer(value.GetType());
xmlFormatter.Serialize(ms, value);
return;
}
}
Expand Down Expand Up @@ -329,8 +329,8 @@ public object GetObject(string type)
return null;
try
{
var binaryFormatter = new BinaryFormatter();
return binaryFormatter.Deserialize(stream);
var xmlFormatter = new XmlSerializer(new object().GetType());
return xmlFormatter.Deserialize(stream);
}
catch (Exception ex)
{
Expand Down

0 comments on commit 8574183

Please sign in to comment.