Last active
December 4, 2018 06:17
-
-
Save JohanLarsson/a44ebad3ef122a366c022e0747721928 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct Temperature : IEquatable<Temperature> | |
{ | |
public Temperature(double celcius) | |
{ | |
this.Celcius = celcius; | |
} | |
public double Celcius { get; } | |
public static bool operator ==(Temperature left, Temperature right) | |
{ | |
return left.Equals(right); | |
} | |
public static bool operator !=(Temperature left, Temperature right) | |
{ | |
return !left.Equals(right); | |
} | |
public bool Equals(Temperature other) | |
{ | |
return this.Celcius.Equals(other.Celcius); | |
} | |
public override bool Equals(object obj) | |
{ | |
if (ReferenceEquals(null, obj)) | |
{ | |
return false; | |
} | |
return obj is Temperature && this.Equals((Temperature) obj); | |
} | |
public override int GetHashCode() | |
{ | |
return this.Celcius.GetHashCode(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TemperatureChangedEventArgs : EventArgs | |
{ | |
public TemperatureChangedEventArgs(Temperature temperature) | |
{ | |
this.Temperature = temperature; | |
this.Time = DateTime.UtcNow; | |
} | |
public Temperature Temperature { get; } | |
public DateTime Time { get; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TemperatureDevice | |
{ | |
public event EventHandler<TemperatureChangedEventArgs> TemperatureChanged; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment