Skip to content

Commit d868712

Browse files
author
Kody Brown
committed
added missing file
1 parent 32bd45f commit d868712

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_17
2+
{
3+
using System;
4+
5+
public class Thermostat
6+
{
7+
// ...
8+
// Declaring the delegate field to save the
9+
// list of subscribers.
10+
private EventHandler<TemperatureArgs> _OnTemperatureChange;
11+
12+
public void add_OnTemperatureChange(
13+
EventHandler<TemperatureArgs> handler)
14+
{
15+
System.Delegate.Combine(_OnTemperatureChange, handler);
16+
}
17+
18+
public void remove_OnTemperatureChange(
19+
EventHandler<TemperatureArgs> handler)
20+
{
21+
System.Delegate.Remove(_OnTemperatureChange, handler);
22+
}
23+
24+
//public event EventHandler<TemperatureArgs> OnTemperatureChange
25+
//{
26+
// //Would cause a compiler error.
27+
// add
28+
// {
29+
// add_OnTemperatureChange(value);
30+
// }
31+
// //Would cause a compiler error.
32+
// remove
33+
// {
34+
// remove_OnTemperatureChange(value);
35+
// }
36+
//}
37+
38+
public class TemperatureArgs : System.EventArgs
39+
{
40+
public TemperatureArgs(float newTemperature)
41+
{
42+
}
43+
44+
}
45+
}
46+
}

EssentialCSharp/Chapter13/chapter13.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<Compile Include="Listing13.04.InvokingADelegate.cs" />
7171
<Compile Include="Listing13.13.DeclaringAGenericDelegateType.cs" />
7272
<Compile Include="Listing13.16.DeclaringTheOnTemperatureChangeEvent.cs" />
73+
<Compile Include="Listing13.17.CSharpConceptualEquivalentOfEventCILCode.cs" />
7374
<Compile Include="Listing13.18.CustomAddAndRemoveHandlers.cs" />
7475
<Compile Include="Listing13.15.UsingCustomDelegateType.cs" />
7576
<Compile Include="Listing13.14.FiringTheEventNotification.cs" />

0 commit comments

Comments
 (0)