Skip to content

Commit

Permalink
added missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
Kody Brown committed Feb 11, 2013
1 parent 32bd45f commit d868712
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter13.Listing13_17
{
using System;

public class Thermostat
{
// ...
// Declaring the delegate field to save the
// list of subscribers.
private EventHandler<TemperatureArgs> _OnTemperatureChange;

public void add_OnTemperatureChange(
EventHandler<TemperatureArgs> handler)
{
System.Delegate.Combine(_OnTemperatureChange, handler);
}

public void remove_OnTemperatureChange(
EventHandler<TemperatureArgs> handler)
{
System.Delegate.Remove(_OnTemperatureChange, handler);
}

//public event EventHandler<TemperatureArgs> OnTemperatureChange
//{
// //Would cause a compiler error.
// add
// {
// add_OnTemperatureChange(value);
// }
// //Would cause a compiler error.
// remove
// {
// remove_OnTemperatureChange(value);
// }
//}

public class TemperatureArgs : System.EventArgs
{
public TemperatureArgs(float newTemperature)
{
}

}
}
}
1 change: 1 addition & 0 deletions EssentialCSharp/Chapter13/chapter13.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<Compile Include="Listing13.04.InvokingADelegate.cs" />
<Compile Include="Listing13.13.DeclaringAGenericDelegateType.cs" />
<Compile Include="Listing13.16.DeclaringTheOnTemperatureChangeEvent.cs" />
<Compile Include="Listing13.17.CSharpConceptualEquivalentOfEventCILCode.cs" />
<Compile Include="Listing13.18.CustomAddAndRemoveHandlers.cs" />
<Compile Include="Listing13.15.UsingCustomDelegateType.cs" />
<Compile Include="Listing13.14.FiringTheEventNotification.cs" />
Expand Down

0 comments on commit d868712

Please sign in to comment.