AddConnectionIfNeeded() public method

public AddConnectionIfNeeded ( IConnectionInformation connection ) : void
connection IConnectionInformation
return void
 public void Create_Default()
 {
     using (var test = new SqLiteHoldConnection())
     {
         var connection = CreateConnection(GoodConnection);
         var connectionMem = CreateConnection(GoodConnectionInMemory);
         test.AddConnectionIfNeeded(connection);
         test.AddConnectionIfNeeded(connectionMem);
         test.Dispose();
     }
 }
        /// <summary>
        /// Allows the transport to set default configuration settings or other values
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="registrationType">Type of the registration.</param>
        /// <param name="connectionType">Type of the connection.</param>
        public override void SetDefaultsIfNeeded(IContainer container, RegistrationTypes registrationType,
                                                 ConnectionTypes connectionType)
        {
            var init = new RelationalDatabaseMessageQueueInit <long, Guid>();

            init.SetDefaultsIfNeeded(container, "SQLiteMessageQueueTransportOptions",
                                     "SQLiteMessageQueueTransportOptions");

            SetupPolicy(container);

            //create in memory hold
            var getFileName = container.GetInstance <IGetFileNameFromConnectionString>();
            var connection  = container.GetInstance <IConnectionInformation>();
            var fileName    = getFileName.GetFileName(connection.ConnectionString);

            if (!fileName.IsInMemory)
            {
                return;
            }
            var scope  = container.GetInstance <ICreationScope>();
            var holder = new SqLiteHoldConnection(getFileName, container.GetInstance <IDbFactory>());

            holder.AddConnectionIfNeeded(connection);
            scope.AddScopedObject(holder);
        }
        /// <summary>
        /// Allows the transport to set default configuration settings or other values
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="registrationType">Type of the registration.</param>
        /// <param name="connectionType">Type of the connection.</param>
        public override void SetDefaultsIfNeeded(IContainer container, RegistrationTypes registrationType, ConnectionTypes connectionType)
        {
            var factory = container.GetInstance<ISqLiteMessageQueueTransportOptionsFactory>();
            var options = factory.Create();
            var configurationSend = container.GetInstance<QueueProducerConfiguration>();
            var configurationReceive = container.GetInstance<QueueConsumerConfiguration>();

            configurationSend.AdditionalConfiguration.SetSetting("SQLiteMessageQueueTransportOptions", options);
            configurationReceive.AdditionalConfiguration.SetSetting("SQLiteMessageQueueTransportOptions", options);

            var transportReceive = container.GetInstance<TransportConfigurationReceive>();


            transportReceive.HeartBeatSupported = options.EnableHeartBeat && options.EnableStatus;

            transportReceive.MessageExpirationSupported = options.EnableMessageExpiration ||
                                                          options.QueueType == QueueTypes.RpcReceive ||
                                                          options.QueueType == QueueTypes.RpcSend;

            transportReceive.MessageRollbackSupported = options.EnableStatus;

            transportReceive.QueueDelayBehavior.Clear();
            transportReceive.QueueDelayBehavior.Add(DefaultQueueDelay());
            transportReceive.FatalExceptionDelayBehavior.Clear();
            transportReceive.FatalExceptionDelayBehavior.Add(ExceptionDelay());

            transportReceive.LockFeatures();

            SetupHeartBeat(container);
            SetupMessageExpiration(container);

            //create in memory hold
            var connection = container.GetInstance<IConnectionInformation>();
            var fileName = GetFileNameFromConnectionString.GetFileName(connection.ConnectionString);
            if(fileName.IsInMemory)
            {
                var scope = container.GetInstance<ICreationScope>();
                var holder = new SqLiteHoldConnection();
                holder.AddConnectionIfNeeded(connection);
                scope.AddScopedObject(holder);
            }
        }