Chinchilla.ConsumerSubscriber.Connect C# (CSharp) Метод

Connect() публичный Метод

public Connect ( ) : ISubscription
Результат ISubscription
        public ISubscription Connect()
        {
            var interfaces = consumer
                .GetType()
                .GetInterfaces()
                .Where(i => typeof(IConsumer).IsAssignableFrom(i) && i != typeof(IConsumer));

            if (!interfaces.Any())
            {
                throw new ChinchillaException(
                    "Could not find any interfaces that are assignable to IConsumer, did you implement IConsumer<T>?");
            }

            if (interfaces.Count() > 1)
            {
                throw new ChinchillaException(
                    "An consumer cannot consume more than one type of message.");
            }

            var consumerType = interfaces.Single();

            return ConnectConsumerInterface(consumerType);
        }

Usage Example

Пример #1
0
        public ISubscription Subscribe(IConsumer consumer)
        {
            logger.DebugFormat("Registering consumer {0}", consumer.GetType().Name);
            var instance = new ConsumerSubscriber(this, consumer);

            return(instance.Connect());
        }