Ejemplo n.º 1
0
        /// <summary>
        /// Registers the message queue, its creation specified via the factory method
        /// MessageQueueCreatorDelegate, with the provided name in the application context
        /// </summary>
        /// <param name="messageQueueObjectName">Name of the message queue object.</param>
        /// <param name="messageQueueCreatorDelegate">The message queue creator delegate.</param>
        public void RegisterMessageQueue(string messageQueueObjectName,
                                         MessageQueueCreatorDelegate messageQueueCreatorDelegate)
        {
            MessageQueueFactoryObject mqfo = new MessageQueueFactoryObject();

            mqfo.MessageCreatorDelegate = messageQueueCreatorDelegate;
            applicationContext.ObjectFactory.RegisterSingleton(messageQueueObjectName, mqfo);
            IDictionary caches = applicationContext.GetObjectsOfType(typeof(MessageQueueMetadataCache));

            foreach (DictionaryEntry entry in caches)
            {
                ((MessageQueueMetadataCache)entry.Value).Insert(mqfo.Path, new MessageQueueMetadata(mqfo.RemoteQueue, mqfo.RemoteQueueIsTransactional));
            }
        }
        public void Initialize()
        {
            IDictionary messageQueueDictionary = configurableApplicationContext.GetObjectsOfType(typeof(MessageQueueFactoryObject));

            lock (itemStore.SyncRoot)
            {
                foreach (DictionaryEntry entry in messageQueueDictionary)
                {
                    MessageQueueFactoryObject mqfo = entry.Value as MessageQueueFactoryObject;
                    if (mqfo != null)
                    {
                        if (mqfo.Path != null)
                        {
                            Insert(mqfo.Path,
                                   new MessageQueueMetadata(mqfo.RemoteQueue, mqfo.RemoteQueueIsTransactional));
                        }
                        else
                        {
                            #region Logging
                            if (LOG.IsWarnEnabled)
                            {
                                LOG.Warn(
                                    "Path for MessageQueueFactoryObject named [" +
                                    mqfo.ObjectName + "] is null, so can't cache its metadata.");
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        // This would indicate some bug in GetObjectsOfType
                        LOG.Error("Unexpected type of " + entry.Value.GetType() + " was given as candidate for caching MessageQueueMetadata.");
                    }
                }
                isInitialized = true;
            }
        }
Ejemplo n.º 3
0
 public bool CanResolve(Type type)
 {
     return(applicationContext.GetObjectsOfType(type).Count > 0);
 }
Ejemplo n.º 4
0
        public static IEnumerable <T> GetAll <T>(this IConfigurableApplicationContext context)
        {
            IDictionary objectsOfType = context.GetObjectsOfType(typeof(T));

            return(objectsOfType.Values.Cast <T>());
        }