Apache.NMS.NMSConnectionFactory.CreateConnectionFactory C# (CSharp) Method

CreateConnectionFactory() public static method

Create a connection factory that can create connections for the given scheme in the URI.
public static CreateConnectionFactory ( Uri uriProvider ) : IConnectionFactory
uriProvider System.Uri The URI for the ActiveMQ provider.
return IConnectionFactory
        public static IConnectionFactory CreateConnectionFactory(Uri uriProvider, params object[] constructorParams)
        {
            IConnectionFactory connectionFactory = null;

            try
            {
                Type factoryType = GetTypeForScheme(uriProvider.Scheme);

                // If an implementation was found, try to instantiate it.
                if(factoryType != null)
                {
            #if NETCF
                    // Compact framework does not allow the activator ta pass parameters to a constructor.
                    connectionFactory = (IConnectionFactory) Activator.CreateInstance(factoryType);
                    connectionFactory.BrokerUri = uriProvider;
            #else
                    object[] parameters = MakeParameterArray(uriProvider, constructorParams);
                    connectionFactory = (IConnectionFactory) Activator.CreateInstance(factoryType, parameters);
            #endif
                }

                if(null == connectionFactory)
                {
                    throw new NMSConnectionException("No IConnectionFactory implementation found for connection URI: " + uriProvider);
                }
            }
            catch(NMSConnectionException)
            {
                throw;
            }
            catch(Exception ex)
            {
                throw new NMSConnectionException("Could not create the IConnectionFactory implementation: " + ex.Message, ex);
            }

            return connectionFactory;
        }