/// <summary>
        /// Get all (usually one) of the latest alerts from the given component.
        /// </summary>
        /// <typeparam name="TModel">The type of the model.</typeparam>
        /// <typeparam name="TProp">The type of the member to check the alert for.</typeparam>
        /// <param name="component">The component.</param>
        /// <param name="selector">A lambda method returning the property to get the alerts for.</param>
        /// <returns></returns>
        public static Alert GetLatestAlert <TModel, TProp>(this IMonitoredComponent <TModel> component, Expression <Func <TModel, TProp> > selector) where TModel : class, IAlertableModel
        {
            string name = ((MemberExpression)selector.Body).Member.Name;

            return(component.GetLatestAlerts().SingleOrDefault(a => a.PropertyName == name));
        }
Ejemplo n.º 2
0
 public void AddMonitoredComponent(IMonitoredComponent comp)
 {
     _monitoredComponents.Add(comp);
 }
        public static IEnumerable <Alert> GetLatestAlerts <TModel>(this IMonitoredComponent <TModel> component) where TModel : class, IAlertableModel
        {
            var report = component.GetLatestReport();

            return(report?.GenerateAlerts() ?? Enumerable.Empty <Alert>());
        }