Example #1
0
        private List <IQueueFactory> QueueFactories()
        {
            if (initialized)
            {
                return(queueFactories);
            }

            lock (padlock)
            {
                if (!initialized)
                {
                    var factoryTypes = new List <Type>();

                    reflectionService.GetAssemblies(AppDomain.CurrentDomain.BaseDirectory).ForEach(
                        assembly => factoryTypes.AddRange(reflectionService.GetTypes <IQueueFactory>(assembly)));

                    foreach (var type in factoryTypes.Union(reflectionService.GetTypes <IQueueFactory>()))
                    {
                        try
                        {
                            type.AssertDefaultConstructor(string.Format(ESBResources.DefaultConstructorRequired,
                                                                        "Queue factory", type.FullName));

                            var instance = (IQueueFactory)Activator.CreateInstance(type);

                            if (!ContainsQueueFactory(instance.Scheme))
                            {
                                RegisterQueueFactory(instance);
                            }
                        }
                        catch (Exception ex)
                        {
                            log.Warning(string.Format("Queue factory not instantiated: {0}", ex.Message));
                        }
                    }

                    initialized = true;
                }
            }

            return(queueFactories);
        }