private static bool IsValidProperty(PropertyInfo prop, IKinesisAppenderFilter filter) { if (!(prop.GetCustomAttributes(typeof(IPropertyValidationAttribute), true).FirstOrDefault() is IPropertyValidationAttribute validation)) { return(true); } return(validation.IsValid(prop.GetValue(filter, null))); }
public static void ValidateFilterProperties(IKinesisAppenderFilter filter) { var invalidProperties = filter.GetType().GetProperties() .Where(prop => !IsValidProperty(prop, filter)) .Select(p => p.Name).ToList(); if (invalidProperties.Any()) { var properties = string.Join(",", invalidProperties.ToArray()); throw new InvalidFilterConfigurationException( string.Format("The properties ({0}) of {1} are invalid.", properties, filter.GetType().Name)); } }
public void AddFilter(IKinesisAppenderFilter filter) { _filters.Add(filter); }