forked from openhardwaremonitor/openhardwaremonitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSensorVisitor.cs
43 lines (32 loc) · 1.14 KB
/
SensorVisitor.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
/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (C) 2009-2010 Michael Möller <[email protected]>
*/
using System;
using System.Collections.Generic;
namespace OpenHardwareMonitor.Hardware {
public class SensorVisitor : IVisitor {
private readonly SensorEventHandler handler;
public SensorVisitor(SensorEventHandler handler) {
if (handler == null)
throw new ArgumentNullException("handler");
this.handler = handler;
}
public void VisitComputer(IComputer computer) {
if (computer == null)
throw new ArgumentNullException("computer");
computer.Traverse(this);
}
public void VisitHardware(IHardware hardware) {
if (hardware == null)
throw new ArgumentNullException("hardware");
hardware.Traverse(this);
}
public void VisitSensor(ISensor sensor) {
handler(sensor);
}
public void VisitParameter(IParameter parameter) { }
}
}