forked from SharpMap/SharpMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtentSurrogate.cs
More file actions
53 lines (44 loc) · 1.71 KB
/
ExtentSurrogate.cs
File metadata and controls
53 lines (44 loc) · 1.71 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) BruTile developers team. All rights reserved. See License.txt in the project root for license information.
using System.Reflection;
using System.Runtime.Serialization;
using BruTile;
namespace SharpMap.Utilities
{
internal class ExtentSurrogate : ISerializationSurrogate
{
[System.Serializable]
internal class ExtentRef : IObjectReference, ISerializable
{
private readonly Extent _extent;
public ExtentRef(SerializationInfo info, StreamingContext context)
{
_extent = new Extent(
info.GetDouble("minX"), info.GetDouble("minY"),
info.GetDouble("maxX"), info.GetDouble("maxY"));
}
object IObjectReference.GetRealObject(StreamingContext context)
{
return _extent;
}
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
throw new System.NotSupportedException();
}
}
#region Implementation of ISerializationSurrogate
public void GetObjectData(object obj, SerializationInfo info, StreamingContext context)
{
var ex = (Extent)obj;
info.SetType(typeof(ExtentRef));
info.AddValue("minX", ex.MinX);
info.AddValue("minY", ex.MinY);
info.AddValue("maxX", ex.MaxX);
info.AddValue("maxY", ex.MaxY);
}
public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
{
return null;
}
#endregion
}
}