Beispiel #1
0
        public static IEnumerable <IValidationResult> ValidateConsumer <TConsumer>(this IConfigurator configurator)
            where TConsumer : class
        {
            if (!typeof(TConsumer).Implements <IConsumer>())
            {
                yield return(configurator.Warning("Consumer",
                                                  string.Format("The consumer class {0} does not implement any IConsumer interfaces",
                                                                typeof(TConsumer).ToShortTypeName())));
            }

            IEnumerable <IValidationResult> warningForMessages = MessageInterfaceTypeReflector <TConsumer>
                                                                 .GetAllTypes()
                                                                 .Distinct()
                                                                 .Where(x => !(HasDefaultProtectedCtor(typeof(TConsumer)) || HasSinglePublicCtor(typeof(TConsumer))))
                                                                 .Select(x => ("The {0} consumer should have a public or protected default constructor." +
                                                                               " Without an available constructor, Burrows will initialize new consumer instances" +
                                                                               " without calling a constructor, which can lead to unpredictable behavior if the consumer" +
                                                                               " depends upon logic in the constructor to be executed.")
                                                                         .FormatWith(x.MessageType.ToShortTypeName()))
                                                                 .Select(message => configurator.Warning("Consumer", message));

            foreach (ValidationResult message in warningForMessages)
            {
                yield return(message);
            }
        }
Beispiel #2
0
 IEnumerable <MessageDistributorConnector> ConsumesSelected()
 {
     return(MessageInterfaceTypeReflector <T> .GetConsumesSelectedTypes()
            .Select(CreateConnector));
 }