forked from SharpMap/SharpMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseSerializationTest.cs
More file actions
30 lines (28 loc) · 1013 Bytes
/
BaseSerializationTest.cs
File metadata and controls
30 lines (28 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using SharpMap.Utilities;
namespace UnitTests.Serialization
{
public abstract class BaseSerializationTest
{
protected static T SandD<T>(T input, IFormatter formatter)
{
using (var ms = new MemoryStream())
{
formatter.Serialize(ms, input);
ms.Seek(0, SeekOrigin.Begin);
return (T)formatter.Deserialize(ms);
}
}
protected static IFormatter GetFormatter()
{
var formatter = new BinaryFormatter();
if (formatter.SurrogateSelector == null)
formatter.SurrogateSelector = new SurrogateSelector();
formatter.SurrogateSelector.ChainSelector(SharpMap.Utilities.Surrogates.GetSurrogateSelectors());
Utility.AddBruTileSurrogates(formatter);
return formatter;
}
}
}