private List <T> FilterDeclarables <T>(IEnumerable <T> declarables, IEnumerable <IDeclarableCustomizer> customizers) where T : IDeclarable { var results = new List <T>(); var customizerCounts = customizers.Count(); foreach (var dec in declarables) { if (ShouldDeclare(dec)) { if (customizerCounts == 0) { results.Add(dec); } else { IDeclarable customized = dec; foreach (var customizer in customizers) { customized = customizer.Apply(customized); } if (customized != null) { results.Add((T)customized); } } } } return(results); }
private void LogOrRethrowDeclarationException(IDeclarable element, string elementType, Exception exception) { PublishDeclarationExceptionEvent(element, exception); if (IgnoreDeclarationExceptions || (element != null && element.IgnoreDeclarationExceptions)) { _logger?.LogDebug(exception, "Failed to declare " + elementType + ": " + (element == null ? "broker-generated" : element.ToString()) + ", continuing..."); var cause = exception; if (exception.InnerException != null) { cause = exception.InnerException; } _logger?.LogWarning( exception, "Failed to declare {elementType}: {element}, continuing... {cause} ", elementType, element == null ? "broker-generated" : element.ToString(), cause); } else { throw exception; } }
private void PublishDeclarationExceptionEvent(IDeclarable element, Exception exception) { var ev = new DeclarationExceptionEvent(this, element, exception); this.LastDeclarationExceptionEvent = ev; // if (this.applicationEventPublisher != null) { // this.applicationEventPublisher.publishEvent(event); // } }
public DeclarationExceptionEvent(object source, IDeclarable declarable, Exception exception) : base(source) { Declarable = declarable; Exception = exception; }