28 lines
801 B
C#
28 lines
801 B
C#
using System;
|
|
using System.IO;
|
|
using System.Runtime.Serialization;
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
|
|
namespace BCG
|
|
{
|
|
public class GenericFormatter<F> : IGenericFormatter where F : IFormatter, new ()
|
|
{
|
|
IFormatter myFormatter = new F ();
|
|
|
|
public T Deserialize<T> (Stream serializationStream)
|
|
{
|
|
#pragma warning disable
|
|
return (T) myFormatter.Deserialize (serializationStream);
|
|
#pragma warning restore SYSLIB0011
|
|
}
|
|
public void Serialize<T> (Stream serializationStream, T graph)
|
|
{
|
|
#pragma warning disable
|
|
myFormatter.Serialize (serializationStream, graph);
|
|
#pragma warning restore SYSLIB0011
|
|
}
|
|
}
|
|
|
|
public class GenericBinaryFormatter : GenericFormatter<BinaryFormatter> { }
|
|
}
|