Contour.Configurator.AppConfigConfigurator.BuildConsumer C# (CSharp) Method

BuildConsumer() private static method

The build consumer.
///
private static BuildConsumer ( Func consumerFactory, Type messageType, Lifestyle lifestyle ) : object
consumerFactory Func /// The consumer factory. ///
messageType System.Type /// The message type. ///
lifestyle Lifestyle /// The lifestyle. ///
return object
        private static object BuildConsumer(Func<object> consumerFactory, Type messageType, Lifestyle? lifestyle)
        {
            Type consumerType;
            switch (lifestyle)
            {
                case null:
                case Lifestyle.Normal:
                    return consumerFactory();
                case Lifestyle.Lazy:
                    consumerType = typeof(LazyConsumerOf<>).MakeGenericType(messageType);
                    return Activator.CreateInstance(consumerType, consumerFactory);
                case Lifestyle.Delegated:
                    consumerType = typeof(FactoryConsumerOf<>).MakeGenericType(messageType);
                    return Activator.CreateInstance(consumerType, consumerFactory);
                default:
                    throw new ConfigurationErrorsException("Unknown or unsupported consumer lifestyle : [{0}].".FormatEx(lifestyle));
            }
        }