Ejemplo n.º 1
0
        /// <summary>
        /// Adds a new observer to this event
        /// </summary>
        /// <param name="observation">Contains all the information needed</param>
        /// <returns></returns>
        internal IDisposable Add(ThresholdObservation observation)
        {
            // Only add a new observation if not already exists
            if (!_observations.Contains(observation))
            {
                _observations.Add(observation);
            }

            return(new Unsubscriber <ThresholdInfo>(_observations, observation));
        }
Ejemplo n.º 2
0
 protected bool IsSensitivityVarianceMet(ThresholdObservation observation, NewReadingReceivedEventArgs e) => Math.Abs(e.Reading - observation.Threshold.LastNotificationTemperature.Value) >= observation.Threshold.Sensitivity;
Ejemplo n.º 3
0
 protected bool IsReadingDifferentThanLastOne(ThresholdObservation observation, NewReadingReceivedEventArgs e) => e.Reading != observation.Threshold.LastNotificationTemperature;
Ejemplo n.º 4
0
 // Common business logic snippets to all
 protected bool IsFirstReading(ThresholdObservation observation, NewReadingReceivedEventArgs e) => !observation.Threshold.LastNotificationTemperature.HasValue;
Ejemplo n.º 5
0
 /// <summary>
 /// Template method to ask the subclass if the threshold was reached
 /// </summary>
 /// <param name="observation">The observation with all the necessary info</param>
 /// <param name="e">The current reading received</param>
 /// <returns></returns>
 protected abstract bool IsThresholdReached(ThresholdObservation observation, NewReadingReceivedEventArgs e);
Ejemplo n.º 6
0
 // Check if we've hit the threshold
 protected override bool IsThresholdReached(ThresholdObservation observation, NewReadingReceivedEventArgs e) => e.Reading >= observation.Threshold.Temperature;
Ejemplo n.º 7
0
 internal Unsubscriber(List <ThresholdObservation> observations,
                       ThresholdObservation observation)
 {
     _observations = observations;
     _observation  = observation;
 }