forked from cschladetsch/CsharpFlow
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTrigger.cs
More file actions
34 lines (27 loc) · 693 Bytes
/
Trigger.cs
File metadata and controls
34 lines (27 loc) · 693 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
31
32
33
34
// (C) 2012 Christian Schladetsch. See http://www.schladetsch.net/flow/license.txt for Licensing information.
namespace Flow
{
/// <summary>
/// A trigger is a group that deletes itself when any of its children are deleted
/// </summary>
internal class Trigger : Group, ITrigger
{
/// <inheritdoc />
public event TriggerHandler Tripped;
/// <inheritdoc />
public ITransient Reason { get; private set; }
internal Trigger()
{
// when an element is removed from this trigger, it fires
Removed += Trip;
}
void Trip(IGroup self, ITransient other)
{
Reason = other;
if (Tripped != null)
Tripped(this, other);
Removed -= Trip;
Complete();
}
}
}