forked from jperson2000/GPS.Net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VirtualDevice.cs
78 lines (64 loc) · 1.95 KB
/
VirtualDevice.cs
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using GeoFramework.Gps.IO;
using GeoFramework.Gps.Emulators;
namespace GeoFramework.Gps.IO
{
/// <summary>
/// Represents a simulated GPS device.
/// </summary>
public sealed class VirtualDevice : Device
{
private Emulator _Emulator;
#region Constructors
/// <summary>
/// Creates a new instance using the specified emulator.
/// </summary>
/// <param name="emulator"></param>
public VirtualDevice(Emulator emulator)
{
if(emulator == null)
throw new ArgumentNullException("emulator", "The emulator of a virtual device cannot be null.");
_Emulator = emulator;
// These devices are always GPS devices
SetIsGpsDevice(true);
}
#endregion
#region Overrides
public override string Name
{
get
{
return _Emulator.Name;
}
}
protected override void OnCacheRemove()
{
/* Since emulators don't qualify as detected devices, this
* method has no behavior.
*/
}
protected override void OnCacheWrite()
{
/* Since emulators don't qualify as detected devices, this
* method has no behavior.
*/
}
protected override void OnCacheRead()
{
/* Since emulators don't qualify as detected devices, this
* method has no behavior.
*/
}
protected override Stream OpenStream(FileAccess access, FileShare sharing)
{
// Start the emulation thread
_Emulator.Open();
// Return the emulator
return _Emulator;
}
#endregion
}
}