Files
shape_library/Shapes/FileIO.cs
2019-10-25 23:25:50 -06:00

24 lines
698 B
C#

using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.Serialization.Json;
namespace Shapes
{
[ExcludeFromCodeCoverage]
public class FileIO : IFileIO
{
public void SaveShape(Stream stream, Shape shape)
{
var a = new DataContractJsonSerializer(typeof(Shape));
a.WriteObject(stream, shape);
// DataContractJsonSerializer j = new DataContractJsonSerializer(typeof(Shape));
// j.WriteObject(stream, shape);
}
public T GetShapeFromFile<T>(Stream stream)
{
var a = new DataContractJsonSerializer(typeof(T));
return (T) a.ReadObject(stream);
}
}
}